1616from lib .core .common import dataToStdout
1717from lib .core .common import decodeHexValue
1818from lib .core .common import extractRegexResult
19+ from lib .core .common import firstNotNone
1920from lib .core .common import getConsoleWidth
2021from lib .core .common import getPartRun
2122from lib .core .common import getUnicode
@@ -102,7 +103,7 @@ def _oneShotErrorUse(expression, field=None, chunkTest=False):
102103 try :
103104 while True :
104105 check = r"(?si)%s(?P<result>.*?)%s" % (kb .chars .start , kb .chars .stop )
105- trimcheck = r"(?si)%s(?P<result>[^<\n]*)" % kb .chars .start
106+ trimCheck = r"(?si)%s(?P<result>[^<\n]*)" % kb .chars .start
106107
107108 if field :
108109 nulledCastedField = agent .nullAndCastField (field )
@@ -133,22 +134,21 @@ def _oneShotErrorUse(expression, field=None, chunkTest=False):
133134
134135 # Parse the returned page to get the exact error-based
135136 # SQL injection output
136- output = reduce ( lambda x , y : x if x is not None else y , (
137+ output = firstNotNone (
137138 extractRegexResult (check , page ),
138139 extractRegexResult (check , threadData .lastHTTPError [2 ] if wasLastResponseHTTPError () else None ),
139140 extractRegexResult (check , listToStrValue ((headers [header ] for header in headers if header .lower () != HTTP_HEADER .URI .lower ()) if headers else None )),
140- extractRegexResult (check , threadData .lastRedirectMsg [1 ] if threadData .lastRedirectMsg and threadData .lastRedirectMsg [0 ] == threadData .lastRequestUID else None )),
141- None
141+ extractRegexResult (check , threadData .lastRedirectMsg [1 ] if threadData .lastRedirectMsg and threadData .lastRedirectMsg [0 ] == threadData .lastRequestUID else None )
142142 )
143143
144144 if output is not None :
145145 output = getUnicode (output )
146146 else :
147- trimmed = (
148- extractRegexResult (trimcheck , page ) or
149- extractRegexResult (trimcheck , threadData .lastHTTPError [2 ] if wasLastResponseHTTPError () else None ) or
150- extractRegexResult (trimcheck , listToStrValue ((headers [header ] for header in headers if header .lower () != HTTP_HEADER .URI .lower ()) if headers else None )) or
151- extractRegexResult (trimcheck , threadData .lastRedirectMsg [1 ] if threadData .lastRedirectMsg and threadData .lastRedirectMsg [0 ] == threadData .lastRequestUID else None )
147+ trimmed = firstNotNone (
148+ extractRegexResult (trimCheck , page ),
149+ extractRegexResult (trimCheck , threadData .lastHTTPError [2 ] if wasLastResponseHTTPError () else None ),
150+ extractRegexResult (trimCheck , listToStrValue ((headers [header ] for header in headers if header .lower () != HTTP_HEADER .URI .lower ()) if headers else None )),
151+ extractRegexResult (trimCheck , threadData .lastRedirectMsg [1 ] if threadData .lastRedirectMsg and threadData .lastRedirectMsg [0 ] == threadData .lastRequestUID else None )
152152 )
153153
154154 if trimmed :
@@ -163,7 +163,7 @@ def _oneShotErrorUse(expression, field=None, chunkTest=False):
163163 output = extractRegexResult (check , trimmed , re .IGNORECASE )
164164
165165 if not output :
166- check = "(?P<result>[^\s<>'\" ]+)"
166+ check = r "(?P<result>[^\s<>'\"]+)"
167167 output = extractRegexResult (check , trimmed , re .IGNORECASE )
168168 else :
169169 output = output .rstrip ()
0 commit comments