File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from thirdparty import six
2121
2222# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23- VERSION = "1.10.7.232 "
23+ VERSION = "1.10.7.233 "
2424TYPE = "dev" if VERSION .count ('.' ) > 2 and VERSION .split ('.' )[- 1 ] != '0' else "stable"
2525TYPE_COLORS = {"dev" : 33 , "stable" : 90 , "pip" : 34 }
2626VERSION_STRING = "sqlmap/%s#%s" % ('.' .join (VERSION .split ('.' )[:- 1 ]) if VERSION .count ('.' ) > 2 and VERSION .split ('.' )[- 1 ] == '0' else VERSION , TYPE )
Original file line number Diff line number Diff line change 1414def dependencies ():
1515 pass
1616
17+ def _unwrap (expr ):
18+ """
19+ Strips only FULLY-wrapping outer parentheses (e.g. '(1=1)' -> '1=1'), leaving a bare function
20+ call such as 'SLEEP(5)' intact - unlike str.strip('()') which would drop its trailing ')'
21+ """
22+
23+ expr = expr .strip ()
24+
25+ while len (expr ) > 1 and expr [0 ] == '(' and expr [- 1 ] == ')' :
26+ depth = 0
27+ wrapper = True
28+
29+ for i in xrange (len (expr )):
30+ if expr [i ] == '(' :
31+ depth += 1
32+ elif expr [i ] == ')' :
33+ depth -= 1
34+ if depth == 0 and i != len (expr ) - 1 : # the opening '(' closes before the end
35+ wrapper = False
36+ break
37+
38+ if not wrapper :
39+ break
40+
41+ expr = expr [1 :- 1 ].strip ()
42+
43+ return expr
44+
1745def tamper (payload , ** kwargs ):
1846 """
1947 Replaces instances like 'IF(A, B, C)' with 'CASE WHEN (A) THEN (B) ELSE (C) END' counterpart
@@ -62,9 +90,9 @@ def tamper(payload, **kwargs):
6290 depth -= 1
6391
6492 if len (commas ) == 2 and end :
65- a = payload [index + len ("IF(" ):commas [0 ]]. strip ( "()" )
66- b = payload [commas [0 ] + 1 :commas [1 ]]. lstrip (). strip ( "()" )
67- c = payload [commas [1 ] + 1 :end ]. lstrip (). strip ( "()" )
93+ a = _unwrap ( payload [index + len ("IF(" ):commas [0 ]])
94+ b = _unwrap ( payload [commas [0 ] + 1 :commas [1 ]])
95+ c = _unwrap ( payload [commas [1 ] + 1 :end ])
6896 newVal = "CASE WHEN (%s) THEN (%s) ELSE (%s) END" % (a , b , c )
6997 payload = payload [:index ] + newVal + payload [end + 1 :]
7098 else :
You can’t perform that action at this time.
0 commit comments