forked from client9/libinjection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfingerprints2sqli.py
executable file
·60 lines (52 loc) · 1.31 KB
/
fingerprints2sqli.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
#!/usr/bin/env python
"""
Small script to convert fingerprints back to SQL or SQLi
"""
import subprocess
RMAP = {
'1': '1',
'f': 'convert',
'&': 'and',
'v': '@version',
'n': 'aname',
's': "\"1\"",
'(': '(',
')': ')',
'o': '*',
'E': 'select',
'U': 'union',
'k': "JOIN",
't': 'binary',
',': ',',
';': ';',
'c': ' -- comment',
'T': 'DROP',
':': ':',
'A': 'COLLATE',
'B': 'group by',
'X': '/* /* nested comment */ */'
}
def fingerprint_to_sqli():
"""
main code, expects to be run in main libinjection/src directory
and hardwires "fingerprints.txt" as input file
"""
mode = 'print'
fingerprints = []
with open('fingerprints.txt', 'r') as openfile:
for line in openfile:
fingerprints.append(line.strip())
for fingerprint in fingerprints:
sql = []
for char in fingerprint:
sql.append(RMAP[char])
sqlstr = ' '.join(sql)
if mode == 'print':
print fingerprint, ' '.join(sql)
else:
args = ['./fptool', '-0', sqlstr]
actualfp = subprocess.check_output(args).strip()
if fingerprint != actualfp:
print fingerprint, actualfp, ' '.join(sql)
if __name__ == '__main__':
fingerprint_to_sqli()