minor update

This commit is contained in:
Miroslav Stampar 2010-12-20 23:21:01 +00:00
parent 518b3e094c
commit 29001a4fce
2 changed files with 48 additions and 15 deletions

View File

@ -287,7 +287,7 @@ class Connect:
if silent or (ignoreTimeout and "timeout" in tbMsg): if silent or (ignoreTimeout and "timeout" in tbMsg):
return None, None return None, None
elif kb.retriesCount < conf.retries: elif kb.retriesCount < conf.retries and not conf.threadException:
kb.retriesCount += 1 kb.retriesCount += 1
warnMsg += ", sqlmap is going to retry the request" warnMsg += ", sqlmap is going to retry the request"

View File

@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
See the file 'doc/COPYING' for copying permission See the file 'doc/COPYING' for copying permission
""" """
import threading
import time import time
from lib.core.common import clearConsoleLine from lib.core.common import clearConsoleLine
@ -29,27 +30,59 @@ def tableExists(tableFile):
infoMsg = "checking table existence using items from '%s'" % tableFile infoMsg = "checking table existence using items from '%s'" % tableFile
logger.info(infoMsg) logger.info(infoMsg)
count = 0 count = [0]
length = len(tables) length = len(tables)
threads = []
tbllock = threading.Lock()
iolock = threading.Lock()
kb.locks.seqLock = threading.Lock()
kb.threadContinue = True
for table in tables: def tableExistsThread():
if conf.db and not conf.db.endswith(METADB_SUFFIX): while count[0] < length and kb.threadContinue:
table = "%s.%s" % (conf.db, table) tbllock.acquire()
result = inject.checkBooleanExpression("%s" % safeStringFormat("EXISTS(SELECT %d FROM %s)", (randomInt(1), table))) table = tables[count[0]]
count[0] += 1
tbllock.release()
if result: if conf.db and not conf.db.endswith(METADB_SUFFIX):
retVal.append(table) table = "%s.%s" % (conf.db, table)
result = inject.checkBooleanExpression("%s" % safeStringFormat("EXISTS(SELECT %d FROM %s)", (randomInt(1), table)))
iolock.acquire()
if result:
retVal.append(table)
if conf.verbose in (1, 2):
clearConsoleLine(True)
infoMsg = "\r[%s] [INFO] retrieved: %s\n" % (time.strftime("%X"), table)
dataToStdout(infoMsg, True)
if conf.verbose in (1, 2): if conf.verbose in (1, 2):
clearConsoleLine(True) status = '%d/%d items (%d%s)' % (count[0], length, round(100.0*count[0]/length), '%')
infoMsg = "\r[%s] [INFO] retrieved: %s\n" % (time.strftime("%X"), table) dataToStdout("\r[%s] [INFO] tried: %s" % (time.strftime("%X"), status), True)
dataToStdout(infoMsg, True) iolock.release()
count += 1 # Start the threads
for numThread in range(conf.threads):
thread = threading.Thread(target=tableExistsThread, name=str(numThread))
thread.start()
threads.append(thread)
if conf.verbose in (1, 2): # And wait for them to all finish
status = '%d/%d items (%d%s)' % (count, length, round(100.0*count/length), '%') try:
dataToStdout("\r[%s] [INFO] tried: %s" % (time.strftime("%X"), status), True) alive = True
while alive:
alive = False
for thread in threads:
if thread.isAlive():
alive = True
thread.join(5)
except KeyboardInterrupt:
kb.threadContinue = False
raise
finally:
kb.locks.seqLock = None
clearConsoleLine(True) clearConsoleLine(True)