@@ -273,46 +273,55 @@ def unionUse(expression, unpack=True, dump=False):
273273 threadData .shared .value = ""
274274
275275 def unionThread ():
276- threadData = getCurrentThreadData ()
277-
278- while threadData .shared .limits and kb .threadContinue :
279- kb .locks .limits .acquire ()
280- num = threadData .shared .limits [- 1 ]
281- del threadData .shared .limits [- 1 ]
282- kb .locks .limits .release ()
283-
284- if Backend .getIdentifiedDbms () in (DBMS .MSSQL , DBMS .SYBASE ):
285- field = expressionFieldsList [0 ]
286- elif Backend .isDbms (DBMS .ORACLE ):
287- field = expressionFieldsList
288- else :
289- field = None
290-
291- limitedExpr = agent .limitQuery (num , expression , field )
292- output = resume (limitedExpr , None )
293-
294- if not output :
295- output = __oneShotUnionUse (limitedExpr , unpack )
296-
297- if output :
298- kb .locks .value .acquire ()
299- threadData .shared .value += output
300- kb .locks .value .release ()
301-
302- if conf .verbose == 1 :
303- if all (map (lambda x : x in output , [kb .misc .start , kb .misc .stop ])):
304- items = extractRegexResult (r'%s(?P<result>.*?)%s' % (kb .misc .start , kb .misc .stop ), output , re .DOTALL | re .IGNORECASE ).split (kb .misc .delimiter )
305- else :
306- items = output .replace (kb .misc .start , "" ).replace (kb .misc .stop , "" ).split (kb .misc .delimiter )
307-
308- status = "[%s] [INFO] retrieved: %s\r \n " % (time .strftime ("%X" ), safecharencode ("," .join (map (lambda x : "\" %s\" " % x , items ))))
309-
310- if len (status ) > width :
311- status = "%s..." % status [:width - 3 ]
312-
313- kb .locks .ioLock .acquire ()
314- dataToStdout (status , True )
315- kb .locks .ioLock .release ()
276+ try :
277+ threadData = getCurrentThreadData ()
278+
279+ while threadData .shared .limits and kb .threadContinue :
280+ kb .locks .limits .acquire ()
281+ num = threadData .shared .limits [- 1 ]
282+ del threadData .shared .limits [- 1 ]
283+ kb .locks .limits .release ()
284+
285+ if Backend .getIdentifiedDbms () in (DBMS .MSSQL , DBMS .SYBASE ):
286+ field = expressionFieldsList [0 ]
287+ elif Backend .isDbms (DBMS .ORACLE ):
288+ field = expressionFieldsList
289+ else :
290+ field = None
291+
292+ limitedExpr = agent .limitQuery (num , expression , field )
293+ output = resume (limitedExpr , None )
294+
295+ if not output :
296+ output = __oneShotUnionUse (limitedExpr , unpack )
297+
298+ if not kb .threadContinue :
299+ break
300+
301+ if output :
302+ kb .locks .value .acquire ()
303+ threadData .shared .value += output
304+ kb .locks .value .release ()
305+
306+ if conf .verbose == 1 :
307+ if all (map (lambda x : x in output , [kb .misc .start , kb .misc .stop ])):
308+ items = extractRegexResult (r'%s(?P<result>.*?)%s' % (kb .misc .start , kb .misc .stop ), output , re .DOTALL | re .IGNORECASE ).split (kb .misc .delimiter )
309+ else :
310+ items = output .replace (kb .misc .start , "" ).replace (kb .misc .stop , "" ).split (kb .misc .delimiter )
311+
312+ status = "[%s] [INFO] retrieved: %s\r \n " % (time .strftime ("%X" ), safecharencode ("," .join (map (lambda x : "\" %s\" " % x , items ))))
313+
314+ if len (status ) > width :
315+ status = "%s..." % status [:width - 3 ]
316+
317+ kb .locks .ioLock .acquire ()
318+ dataToStdout (status , True )
319+ kb .locks .ioLock .release ()
320+
321+ except KeyboardInterrupt :
322+ kb .threadContinue = False
323+ kb .threadException = True
324+ raise
316325
317326 runThreads (numThreads , unionThread )
318327
0 commit comments