Файл: gamele.ru/lastdays_mod/abc/class.sqlinj.php
Строк: 46
<?php
class sql_i
{
private $sql;
private $strongsql;
private $type;
private $symbol;
public function __construct()
{
$this->sql=array('SELECT ','select ','delete ','DELETE ','from ','FROM ','DROP ','drop ','UPDATE ','update ',' if',' IF', 'WHERE ','where ');
$this->strongsql=array('SELECT','select','delete','DELETE','from','FROM','DROP','drop','`',''','UPDATE','update','if','IF', 'WHERE','where', ' ', '(', ')', '{', '}', '=', '`', ''', '"', '-', '<', '>');
//$this->strongsql=addslashes($this->strongsql); //,'in','IN'
}
public function getlist()
{
return $this->sql;
}
public function getstronglist()
{
return $this->strongsql;
}
}
class sqlinj
{
private $status;
private $array;
private function compare($value)
{
$o=new sql_i();
foreach ($o->getlist() as $sqloperator)
{
if (preg_match('/'.$sqloperator.'/', $value))
{
$this->symbol=strstr($value, $sqloperator);
return 1;
}
}
return 0;
}
private function strongcompare($value)
{
$o=new sql_i();
foreach ($o->getstronglist() as $sqloperator)
{
if (preg_match('/'.$sqloperator.'/', $value))
{
$this->symbol=strstr($value, $sqloperator);
return 1;
}
}
return 0;
}
public function __construct()
{
$this->status=0;
if ($_POST)
{
foreach ($_POST as $value)
{
$result=$this->compare($value);
if ($result==1)
{
$this->status=1;
$this->type='POST';
}
}
}
if ($_GET)
{
foreach ($_GET as $value)
{
$result=$this->strongcompare($value);
if ($result==1)
{
$this->status=1;
$this->type='GET';
}
}
}
if (isset($_COOKIE))
{
foreach ($_COOKIE as $value)
{
$result=$this->compare($value);
if ($result==1)
{
$this->status=1;
$this->type='COOKIE';
}
}
}
if ($_SESSION)
{
foreach ($_SESSION as $value)
{
$result=$this->strongcompare($value);
if ($result==1)
{
$this->status=1;
$this->type='SESSION';
}
}
}
}
public function getstatus()
{
return $this->status;
}
public function alert()
{
header("Location: hacker.html");
exit;
//echo "Haack syka";
}
public function gettype()
{
return 'sql injection, заблокирован на линии ['.$this->type.':'.$this->symbol.']';
}
}
?>