-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspace2null.py
54 lines (38 loc) · 1.17 KB
/
space2null.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
#!/usr/bin/env python
"""
Copyright (c) 2023 sunw4r (https://github.com/sunw4r)
"""
from lib.core.compat import xrange
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def dependencies():
pass
def tamper(payload, **kwargs):
"""
Replaces space character (' ') with a null byte '\0'
Tested against:
* Microsoft SQL Server 2019
Notes:
* Useful to bypass a protection that i dont know what is.
>>> tamper('SELECT id FROM users')
'SELECT\0id\0FROM\0users'
"""
retVal = payload
if payload:
retVal = ""
quote, doublequote, firstspace = False, False, False
for i in xrange(len(payload)):
if not firstspace:
if payload[i].isspace():
firstspace = True
retVal += "\0"
continue
elif payload[i] == '\'':
quote = not quote
elif payload[i] == '"':
doublequote = not doublequote
elif payload[i] == " " and not doublequote and not quote:
retVal += "\0"
continue
retVal += payload[i]
return retVal