9000 - Fastcgi
💡 学习提示: 本文档介绍 9000 - FastCGI 的渗透测试方法,适合信息安全初学者和从业人员参考。
⚠️ 法律声明: 本文档仅供学习和授权测试使用。未经授权的系统测试可能违反法律法规。
⚠️ 法律声明: 本文档仅供学习和授权测试使用。未经授权的系统测试可能违反法律法规。
9000 渗透测试 FastCGI
基本信息
If you want to learn what is FastCGI check the following page:
pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-fpm-fastcgi.md
By default FastCGI run in port 9000 and isn’t recognized by nmap. Usually FastCGI only listen in localhost.
信息收集 / Quick checks
- 端口 scan:
nmap -sV -p9000 <target>(will often show “unknown” service; manually test). - Probe FPM status page:
SCRIPT_FILENAME=/status SCRIPT_NAME=/status REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000(default php-fpmpm.status_path). - Find reachable sockets via SSRF: if an HTTP service is exploitable for SSRF, try
gopher://127.0.0.1:9000/_...payloads to hit the FastCGI listener. - Nginx misconfigs:
cgi.fix_pathinfo=1withfastcgi_split_path_infoerrors let you append/.phpto static files and reach PHP (code exec via traversal).
远程代码执行
It’s quite easy to make FastCGI execute arbitrary code:
or you can also use the following python script: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75
SSRF/gopher to FastCGI (when 9000 is not directly reachable)
If you only control an SSRF primitive, you can still hit FastCGI using the gopher scheme and craft a full FastCGI request. 示例 payload builder:
Convert payload to URL-safe base64/percent-encoding and send via gopher://host:9000/_<payload> in your SSRF.
Notes on recent issues
- libfcgi <= 2.4.4 integer overflow (2024): crafted
nameLen/valueLenin FastCGI records can overflow on 32‑bit builds (common in embedded/IoT), yielding heap 远程代码执行 when the FastCGI socket is reachable (directly or via SSRF). - PHP-FPM log manipulation (CVE-2024-9026): when
catch_workers_output = yes, attackers who can send FastCGI requests may truncate or inject up to 4 bytes per log line to erase indicators or poison logs. - Classic Nginx + cgi.fix_pathinfo misconfig: still widely seen; if
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;is used without file existence checks, any path ending in.phpgets executed, enabling path traversal or source overwrite style gadgets.