From efa3c3e4515764d13890f183519d9db3fa3c88f3 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 22 Apr 2014 11:04:28 +0200 Subject: [PATCH] Minor improvement of between tamper script --- tamper/between.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tamper/between.py b/tamper/between.py index a508ae40e..e7f3d4014 100644 --- a/tamper/between.py +++ b/tamper/between.py @@ -17,6 +17,7 @@ def dependencies(): def tamper(payload, **kwargs): """ Replaces greater than operator ('>') with 'NOT BETWEEN 0 AND #' + Replaces equals operator ('=') with 'BETWEEN # AND #' Tested against: * Microsoft SQL Server 2005 @@ -32,6 +33,8 @@ def tamper(payload, **kwargs): >>> tamper('1 AND A > B--') '1 AND A NOT BETWEEN 0 AND B--' + >>> tamper('1 AND A = B--') + '1 AND A BETWEEN B AND B--' """ retVal = payload @@ -45,4 +48,12 @@ def tamper(payload, **kwargs): else: retVal = re.sub(r"\s*>\s*(\d+|'[^']+'|\w+\(\d+\))", " NOT BETWEEN 0 AND \g<1>", payload) + if retVal == payload: + match = re.search(r"(?i)(\b(AND|OR)\b\s+)(?!.*\b(AND|OR)\b)([^=]+?)\s*=\s*(\w+)\s*", payload) + + if match: + _ = "%s %s BETWEEN %s AND %s" % (match.group(2), match.group(4), match.group(5), match.group(5)) + retVal = retVal.replace(match.group(0), _) + + return retVal