How can i replace my queries with mysql-proxy or any possible way?

637 views Asked by At

I have succesfully installed mysql-proxy and understood the way working and lua scripting. But I am not good at writing lua.

So my problem is the software I use for web hosting keep creating mysql users with OLD_PASSWORD('') in the queries. I think mysql-proxy should easyly replace OLD_PASSWORD('') with new PASSWORD('') value.

I have recently seen some tutorials on youtube some ppl manage to replace queries via phpmyadmin. If there is any other way to replace queries please let me now.

Not: I can not change queries from software because it is encoded and some files exe.

Example query:

INSERT INTO mysql.user (Host, User, Password) VALUES ('localhost', 'safaf', OLD_PASSWORD('123456'))

Expected query :

INSERT INTO mysql.user (Host, User, Password) VALUES ('localhost', 'safaf', PASSWORD('123456'))
1

There are 1 answers

0
Dali On BEST ANSWER

After some search on the internet i found the solution.

 function read_query( packet )
   if string.byte(packet) == proxy.COM_QUERY then
     local query = string.sub(packet, 2)
     local replacing = false
     -- matches "OLD" as first word of the query
     if string.match(string.upper(query), 'OLD_PASSWORD') then
         query = string.gsub(query,'OLD_PASSWORD', 'PASSWORD')
         replacing = true
     end
     if (replacing) then
         proxy.queries:append(1, string.char(proxy.COM_QUERY) .. query )
         return proxy.PROXY_SEND_QUERY
     end
   end
 end