LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   how to get the query by setting up a proxy like greensql (https://www.linuxquestions.org/questions/linux-security-4/how-to-get-the-query-by-setting-up-a-proxy-like-greensql-791976/)

tanveer 02-27-2010 11:01 AM

how to get the query by setting up a proxy like greensql
 
Hi,

I was willing to create proxy in between the web app. and MySQL database so that I can do some modification before sending the query to the DB. But how to grep the query in the middle isn't working in the head yet.

I found a tool named 'greensql' which captures the query in the middle but couldn't get how they are doing it.

Thanks.

nowonmai 03-02-2010 09:59 AM

GreenSQL works like any other proxy... you point your client at the proxy port, and the proxy itself points at the server port.

The way I have it set up is as follows...

Apache/PHP -> GreenSQL (3305) -> MySQL (3306)

GreenSQL parses the incoming queries and looks for obvious injection attempts, escapes and so on, and either sanitises them or blocks them accordingly. You will not notice any slowdown, unless your server is already at or near capacity.

I highly recommend it.

nowonmai 03-02-2010 10:02 AM

Ah... I think I misinterpreted the point of your post. You want to modify queries yourself, before they hit the server, right?
I suppose you could string together a listener/stream editor/connector using netcat and grep/sed/awk. Or you could write one in Perl/Ruby/<ILoC>. Not hugely difficult.

tanveer 03-09-2010 10:32 PM

great. Thanks for your reply.

I was just looking is there any other way besides listening in the stream or how the greensql is using for this. What if the mysql in setup using SSL so that way it will be hard to get the query as it won't be in plain text.

nowonmai 03-10-2010 05:10 AM

In order to do any of this, access to the box would be necessary. GreenSQL simply proxies connections between 3305 and 3306. Any solution you come up with would have to do something similar.
Given that you have access to the box, SSL is no barrier, as you would have access to the keys too and setting up an SSL proxy (man in the middle) would be trivial.


All times are GMT -5. The time now is 07:01 PM.