Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55a9f91

Browse files
committed
Refactoring between.py script
1 parent f2512d0 commit 55a9f91

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

tamper/between.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,10 @@ def tamper(payload, **kwargs):
3838
retVal = payload
3939

4040
if payload:
41-
retVal = ""
42-
quote, doublequote, firstspace = False, False, False
41+
match = re.search(r"(?i)(\b(AND|OR)\b\s+)(?!.*\b(AND|OR)\b)([^>]+?)\s*>\s*([^>]+)\s*\Z", payload)
4342

44-
for i in xrange(len(payload)):
45-
if not firstspace:
46-
if payload[i].isspace():
47-
firstspace = True
48-
retVal += " "
49-
continue
50-
51-
elif payload[i] == '\'':
52-
quote = not quote
53-
54-
elif payload[i] == '"':
55-
doublequote = not doublequote
56-
57-
elif payload[i] == ">" and not doublequote and not quote:
58-
retVal += " " if i > 0 and not payload[i - 1].isspace() else ""
59-
retVal += "NOT BETWEEN %s AND" % ('0' if re.search(r"\A[^\w]*\d", payload[i + 1:]) else "NULL")
60-
retVal += " " if i < len(payload) - 1 and not payload[i + 1:i + 2].isspace() else ""
61-
62-
continue
63-
64-
retVal += payload[i]
43+
if match:
44+
_ = "%s %s NOT BETWEEN 0 AND %s" % (match.group(2), match.group(4), match.group(5))
45+
retVal = retVal.replace(match.group(0), _)
6546

6647
return retVal

0 commit comments

Comments
 (0)