We put here some ways to protect yourself against heckarilor using shell and different ways
I hope to be useful these little protection
PHP Code:
///////////////////// Anti SQL injection through the Browser
function connectdb()
{
global $dbname, $dbuser, $dbhost, $dbpass;
$conms = @mysql_connect($dbhost,$dbuser,$dbpass); //connect mysql
if(!$conms) return false;
$condb = @mysql_select_db($dbname);
if(!$condb) return false;
global $_SERVER, $HTTP_USER_AGENT, $HTTP_X_DEVICE_USER_AGENT;
$HTTP_USER_AGENT = mysql_real_escape_string($HTTP_USER_AGENT);
$HTTP_X_DEVICE_USER_AGENT = mysql_real_escape_string($HTTP_X_DEVICE_USER_AGENT);
$_SERVER["HTTP_USER_AGENT"] = mysql_real_escape_string($_SERVER["HTTP_USER_AGENT"]);
$_SERVER["HTTP_X_DEVICE_USER_AGENT"] = mysql_real_escape_string($_SERVER["HTTP_X_DEVICE_USER_AGENT"]);
return true;
}
PHP Code:
///////////////////// Anti-Shell
class secure
{
function secureSuperGlobalGET(&$value, $key)
{
$_GET[$key] = htmlspecialchars(stripslashes($_GET[$key]));
$_GET[$key] = str_ireplace("shell", "blocked", $_GET[$key]);
$_GET[$key] = mysql_real_escape_string($_GET[$key]);
return $_GET[$key];
}
function secureSuperGlobalPOST(&$value, $key)
{
$_POST[$key] = htmlspecialchars(stripslashes($_POST[$key]));
$_POST[$key] = str_ireplace("schell", "blocked", $_POST[$key]);
$_POST[$key] = mysql_real_escape_string($_POST[$key]);
return $_POST[$key];
}
function secureGlobals()
{
array_walk($_GET, array($this, "secureSuperGlobalGET"));
array_walk($_POST, array($this, "secureSuperGlobalPOST"));
}
}
PHP Code:
///////////////////////// Browser & IP Injection
$brws = explode(" / ",$HTTP_USER_AGENT);
$cerere_server = $_SERVER["REQUEST_URI"];
if( ( ciuflea_injection_2($brws[0])) || (ciuflea_injection_2($cerere_server)) || ( (ciuflea_injection_2(getip()))) ){require("detectare_injectii_sql.html");
exit();
}
function ciuflea_injection_2($cerere)
{
$text = "$cerere";
$sfil[0] = "drop";
$sfil[1] = "perm";
$sfil[2] = "'";
$sfil[3] = "validated";
$sfil[4] = "update";
$sfil[5] = "drop";
$sfil[6] = "empty";
$sfil[7] = "union";
$sfil[8] = "md665";
$sfil[9] = "plusses";
$sfil[10] = "_users";
$sfil[11] = "ciufleachat_";
$text = str_replace(" ", "", $text);
$text = strtolower($text);
for($i=0;$i<count($sfil);$i++)
{
$nosf = substr_count($text,$sfil[$i]);
if($nosf>0)
{
return true;
}
}
}
Comment