Bl0wf1sh
New Member
- Nov 28, 2011
- 9
- 4
You can protect your site from XSS and SQLi attack with this little script.
You can test it if you just add ?foo=bar' in your link.
Hope you like it
PHP:
$bad = array("0x", "'", "(", ")", "union", "<", ">", "SELECT", "FROM");
$ip = $_SERVER["REMOTE_ADDR"];
$site = $_SERVER['REQUEST_URI'];
$date = date("m.d.Y");
$time = date("H:i:s");
foreach($_REQUEST as $req)
{
foreach($bad as $vuln)
{
if(@preg_match('/'.$vuln.'/',$req))
{
echo "<b>Blocked attack</b><br>";
echo "Your IP: $ip <br>Attacked site: $site<br>Date: $date<br>Time: $time";
exit;
}
}
}
You can test it if you just add ?foo=bar' in your link.
Hope you like it