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

Skip to content

Commit efa3c3e

Browse files
committed
Minor improvement of between tamper script
1 parent 6fd3c27 commit efa3c3e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tamper/between.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def dependencies():
1717
def tamper(payload, **kwargs):
1818
"""
1919
Replaces greater than operator ('>') with 'NOT BETWEEN 0 AND #'
20+
Replaces equals operator ('=') with 'BETWEEN # AND #'
2021
2122
Tested against:
2223
* Microsoft SQL Server 2005
@@ -32,6 +33,8 @@ def tamper(payload, **kwargs):
3233
3334
>>> tamper('1 AND A > B--')
3435
'1 AND A NOT BETWEEN 0 AND B--'
36+
>>> tamper('1 AND A = B--')
37+
'1 AND A BETWEEN B AND B--'
3538
"""
3639

3740
retVal = payload
@@ -45,4 +48,12 @@ def tamper(payload, **kwargs):
4548
else:
4649
retVal = re.sub(r"\s*>\s*(\d+|'[^']+'|\w+\(\d+\))", " NOT BETWEEN 0 AND \g<1>", payload)
4750

51+
if retVal == payload:
52+
match = re.search(r"(?i)(\b(AND|OR)\b\s+)(?!.*\b(AND|OR)\b)([^=]+?)\s*=\s*(\w+)\s*", payload)
53+
54+
if match:
55+
_ = "%s %s BETWEEN %s AND %s" % (match.group(2), match.group(4), match.group(5), match.group(5))
56+
retVal = retVal.replace(match.group(0), _)
57+
58+
4859
return retVal

0 commit comments

Comments
 (0)