minor update

This commit is contained in:
Miroslav Stampar 2011-05-29 23:33:34 +00:00
parent 86455ceb9c
commit 6fd8602f01
2 changed files with 46 additions and 31 deletions

View File

@ -341,13 +341,19 @@ def errorUse(expression, expected=None, resumeValue=True, dump=False):
output = __errorFields(expression, expressionFields, expressionFieldsList, expected, num, resumeValue) output = __errorFields(expression, expressionFields, expressionFieldsList, expected, num, resumeValue)
if not kb.threadContinue:
break
if output and isinstance(output, list) and len(output) == 1: if output and isinstance(output, list) and len(output) == 1:
output = output[0] output = output[0]
kb.locks.outputs.acquire() kb.locks.outputs.acquire()
threadData.shared.outputs.append(output) threadData.shared.outputs.append(output)
kb.locks.outputs.release() kb.locks.outputs.release()
except KeyboardInterrupt: except KeyboardInterrupt:
kb.threadContinue = False
kb.threadException = True
raise raise
runThreads(numThreads, errorThread) runThreads(numThreads, errorThread)

View File

@ -273,46 +273,55 @@ def unionUse(expression, unpack=True, dump=False):
threadData.shared.value = "" threadData.shared.value = ""
def unionThread(): def unionThread():
threadData = getCurrentThreadData() try:
threadData = getCurrentThreadData()
while threadData.shared.limits and kb.threadContinue: while threadData.shared.limits and kb.threadContinue:
kb.locks.limits.acquire() kb.locks.limits.acquire()
num = threadData.shared.limits[-1] num = threadData.shared.limits[-1]
del threadData.shared.limits[-1] del threadData.shared.limits[-1]
kb.locks.limits.release() kb.locks.limits.release()
if Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE): if Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
field = expressionFieldsList[0] field = expressionFieldsList[0]
elif Backend.isDbms(DBMS.ORACLE): elif Backend.isDbms(DBMS.ORACLE):
field = expressionFieldsList field = expressionFieldsList
else: else:
field = None field = None
limitedExpr = agent.limitQuery(num, expression, field) limitedExpr = agent.limitQuery(num, expression, field)
output = resume(limitedExpr, None) output = resume(limitedExpr, None)
if not output: if not output:
output = __oneShotUnionUse(limitedExpr, unpack) output = __oneShotUnionUse(limitedExpr, unpack)
if output: if not kb.threadContinue:
kb.locks.value.acquire() break
threadData.shared.value += output
kb.locks.value.release()
if conf.verbose == 1: if output:
if all(map(lambda x: x in output, [kb.misc.start, kb.misc.stop])): kb.locks.value.acquire()
items = extractRegexResult(r'%s(?P<result>.*?)%s' % (kb.misc.start, kb.misc.stop), output, re.DOTALL | re.IGNORECASE).split(kb.misc.delimiter) threadData.shared.value += output
else: kb.locks.value.release()
items = output.replace(kb.misc.start, "").replace(kb.misc.stop, "").split(kb.misc.delimiter)
status = "[%s] [INFO] retrieved: %s\r\n" % (time.strftime("%X"), safecharencode(",".join(map(lambda x: "\"%s\"" % x, items)))) if conf.verbose == 1:
if all(map(lambda x: x in output, [kb.misc.start, kb.misc.stop])):
items = extractRegexResult(r'%s(?P<result>.*?)%s' % (kb.misc.start, kb.misc.stop), output, re.DOTALL | re.IGNORECASE).split(kb.misc.delimiter)
else:
items = output.replace(kb.misc.start, "").replace(kb.misc.stop, "").split(kb.misc.delimiter)
if len(status) > width: status = "[%s] [INFO] retrieved: %s\r\n" % (time.strftime("%X"), safecharencode(",".join(map(lambda x: "\"%s\"" % x, items))))
status = "%s..." % status[:width - 3]
kb.locks.ioLock.acquire() if len(status) > width:
dataToStdout(status, True) status = "%s..." % status[:width - 3]
kb.locks.ioLock.release()
kb.locks.ioLock.acquire()
dataToStdout(status, True)
kb.locks.ioLock.release()
except KeyboardInterrupt:
kb.threadContinue = False
kb.threadException = True
raise
runThreads(numThreads, unionThread) runThreads(numThreads, unionThread)