February 8th, 2005, 08:43 PM
SQL Injection - XSS Preventor.. Need
Finally i have got an idea of an script to do this JOB.. well i know it have alot of LAME things but thats my first script mmmm maybe i need to get SHOOTED for it .. i dont know it need your opinion >> Professionals
+ there is something last that Can Bypass the Script Check..
ok the script checks the Requested URL for any Metacharacter Used in SQL Injection or XSS exploits.. so i have made that.. and it BAN the person that Does try it..
there is 2 problems i have faced and didn't find a solution for it..
1st : the $REMOTE_ADDR doesn't get the Real IP sometimes if a user is using a proxy. so if anybody can tell me how to get the REAL ip of the person.. or i may Disable the BAN IP thing
2nd : the script can be bypassed by 1 thing... if i made a HTML page in my pc that POST a value with THE SQL INJECTIONS it passes the Script check
so can any1 tell me how to check the POST VARS..
thanks in advance
// SCRIPT CODED By : rOCk-MaStEr //
// Any Comments contact me : //
// [email]firstname.lastname@example.org[/email] //
// For more Security and Scripts Visit : //
// [url]http://www.securitygurus.net[/url] //
$banchk = strpos($data,$REMOTE_ADDR);
if($banchk != false )
echo ": You Are BANNED from This website :";
$checktheurl = $_SERVER['REQUEST_URI'];
$metacharacter = array("UNION","SELECT","WHERE","INSERT","union","select","insert","where",";","*","%3c","%3e","<",">",",","'");
$checker = strpos($checktheurl, $metacharacter[$count]);
if($checker != false)
echo ": Sorry! You attemping Banned Operation.. ! :";
February 9th, 2005, 09:20 PM
This might point you in the right direction...
Or...you can go here...but you'll have to scroll down to get to it...
February 9th, 2005, 09:32 PM
Thx for ur reply
but i need that for PHP
February 9th, 2005, 10:32 PM
If you're looking for a coding site I hope this fits the bill...
it says it has what you're looking for.
February 9th, 2005, 10:53 PM
Instead of detecting it in the URI, how about sanitizing your fields in the script?
Search this site for an PHP owasp filters tutorial
You can grab fields from the url with $_GET and $_POST, and sanitize($string, HTML) those fields using that tut.
February 9th, 2005, 10:59 PM
i dont get u totally
i need for an example to INCLUDE the script in Forum files so it can check for sql injections !!
February 9th, 2005, 11:09 PM
Ok I see what you're doing. You search for XSS or SQL in the URI and if it appears, you log and ban them automatically.
Depending on the enviroment you are working on, heres a possibly big vulnerability:
I use an open relay, spoof your addy and email this link to everyone in your intranet or website:
All of a sudden, I've banned everyone that clicked that link from viewing your site. If you run a forum, that could be an issue.
There are PHP arrays that contain all fields (I think), you would have to loop through and sanitize each one and put it right back if you want to prevent an attack, instead of detect it and keep your drop in solution working.
February 10th, 2005, 12:30 AM
So i May Remove the BAN issue because it doesn't get the real IP if a user is over a proxy
but what about the POST VARS i need to check a value in all POSTED
any ideas !
February 10th, 2005, 08:31 AM
Try a foreach loop with your $_POST, it will run through each variable, but you still need to find a way to stick it back into the array.
I don't know how to loop through and reassign in PHP 4.
As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value.
February 15th, 2005, 06:20 AM
well i got a solution in my mind and did it
i will put all the Vars in a 1 variable as String then use it
$vars = each($HTTP_POST_VARS);
$varsext = $varsext . $vars["value"];
i removed the IP BAN THING bcoz no use of it
i converted the Variables to Lowercase to Get any Tricking in playin with it