-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspeedtest.py
executable file
·94 lines (81 loc) · 2.35 KB
/
speedtest.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
from libinjection import sqli_state
from words import *
import time
import sys
if sys.version_info > (3, 7):
from time import process_time as clock
else:
from time import clock as clock
def lookup_null(state, style, keyword):
return ''
def lookup_c(state, style, keyword):
return ''
#return sqli_lookup_word(state, style, keyword)
def lookup_upcase(state, stype, keyword):
if stype == libinjection.LOOKUP_FINGERPRINT:
return words.get('0' + keyword.upper(), '')
else:
return words.get(keyword.upper(), '')
def main():
inputs = (
"123 LIKE -1234.5678E+2;",
"APPLE 19.123 'FOO' \"BAR\"",
"/* BAR */ UNION ALL SELECT (2,3,4)",
"1 || COS(+0X04) --FOOBAR",
"dog apple @cat banana bar",
"dog apple cat \"banana \'bar",
"102 TABLE CLOTH"
)
imax = 100000
t0 = clock()
sfilter = sqli_state()
for i in range(imax):
s = inputs[i % 7]
sqli_init(sfilter, s, 0)
is_sqli(sfilter)
t1 = clock()
total = imax / (t1 - t0)
print(("python->c TPS = {0}".format(total)))
t0 = clock()
sfilter = sqli_state()
for i in range(imax):
s = inputs[i % 7]
sqli_init(sfilter, s, 0)
sqli_callback(sfilter, lookup_null)
is_sqli(sfilter)
t1 = clock()
total = imax / (t1 - t0)
print(("python lookup_null TPS = {0}".format(total)))
t0 = clock()
sfilter = sqli_state()
for i in range(imax):
s = inputs[i % 7]
sqli_init(sfilter, s, 0)
sqli_callback(sfilter, lookup_upcase)
is_sqli(sfilter)
t1 = clock()
total = imax / (t1 - t0)
print(("python lookup_upcase TPS = {0}".format(total)))
t0 = clock()
sfilter = sqli_state()
for i in range(imax):
s = inputs[i % 7]
sqli_init(sfilter, s, 0)
sqli_callback(sfilter, lookup_c)
is_sqli(sfilter)
t1 = clock()
total = imax / (t1 - t0)
print(("python lookup_c TPS = {0}".format(total)))
t0 = clock()
sfilter = sqli_state()
for i in range(imax):
s = inputs[i % 7]
sqli_init(sfilter, s, 0)
sqli_callback(sfilter, lookup)
is_sqli(sfilter)
t1 = clock()
total = imax / (t1 - t0)
print(("python lookup TPS = {0}".format(total)))
if __name__ == '__main__':
main()