A function testing for SQL injection?
Posted: Sat Apr 22, 2006 9:35 am
Hi everyone,
I recently launched a website, and it took my friend a little over three hours to inject SQL into it. While this guy is a professional programmer and knows more than your typical 14 year old 1337 haxx0r, I'm a little bit dissappointed with the result. So I had an idea. Where do 99.9% of sql injections come from? GET and POST, right? What if there were a function that would use regex to test for a mysql query that is being passed through those channels? It wouldn't even be that hard right? Test for a few of the common MySQL keywords (SELECT, DELETE, DROP, WHERE, maybe the backticks, etc.). If it finds something, it just silently unsets the variable (or array element), and continues execution of the script. Run that function in every script (I have a central include file, so putting that in would be a matter of seconds)...I'm just curious as to what you think about this idea, what I should consider, etc.
Cheers!
I recently launched a website, and it took my friend a little over three hours to inject SQL into it. While this guy is a professional programmer and knows more than your typical 14 year old 1337 haxx0r, I'm a little bit dissappointed with the result. So I had an idea. Where do 99.9% of sql injections come from? GET and POST, right? What if there were a function that would use regex to test for a mysql query that is being passed through those channels? It wouldn't even be that hard right? Test for a few of the common MySQL keywords (SELECT, DELETE, DROP, WHERE, maybe the backticks, etc.). If it finds something, it just silently unsets the variable (or array element), and continues execution of the script. Run that function in every script (I have a central include file, so putting that in would be a matter of seconds)...I'm just curious as to what you think about this idea, what I should consider, etc.
Cheers!