Minor code refactoring and cosmetics

This commit is contained in:
Bernardo Damele 2011-01-11 21:46:21 +00:00
parent e3146464da
commit 06230e4d92
5 changed files with 14 additions and 44 deletions

View File

@ -114,14 +114,13 @@ def __urllib2Opener():
# Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
if conf.keepAlive: if conf.keepAlive:
warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
warnMsg += "been disabled because of it's incompatibility "
if conf.proxy: if conf.proxy:
warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
warnMsg += "been disabled because of it's incompatibility "
warnMsg += "with HTTP(s) proxy" warnMsg += "with HTTP(s) proxy"
logger.warn(warnMsg) logger.warn(warnMsg)
elif conf.aType: elif conf.aType:
warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
warnMsg += "been disabled because of it's incompatibility "
warnMsg += "with authentication methods" warnMsg += "with authentication methods"
logger.warn(warnMsg) logger.warn(warnMsg)
else: else:
@ -507,38 +506,6 @@ def __setWriteFile():
conf.wFileType = getFileType(conf.wFile) conf.wFileType = getFileType(conf.wFile)
def __setUnion():
if isinstance(conf.uCols, basestring) and conf.uChar != "1-20":
debugMsg = "setting the UNION query SQL injection range of columns"
logger.debug(debugMsg)
if "-" not in conf.uCols or len(conf.uCols.split("-")) != 2:
raise sqlmapSyntaxException, "--union-cols must be a range with hyphon (e.g. 1-10)"
conf.uCols = conf.uCols.replace(" ", "")
conf.uColsStart, conf.uColsStop = conf.uCols.split("-")
if not conf.uColsStart.isdigit() or not conf.uColsStop.isdigit():
raise sqlmapSyntaxException, "--union-cols must be a range of integers"
conf.uColsStart = int(conf.uColsStart)
conf.uColsStop = int(conf.uColsStop)
if conf.uColsStart > conf.uColsStop:
errMsg = "--union-cols range has to be from lower to "
errMsg += "higher number of columns"
raise sqlmapSyntaxException, errMsg
if isinstance(conf.uChar, basestring) and conf.uChar != "NULL":
debugMsg = "setting the UNION query SQL injection character to '%s'" % conf.uChar
logger.debug(debugMsg)
if not conf.uChar.isdigit() and ( not conf.uChar.startswith("'") or not conf.uChar.endswith("'") ):
debugMsg = "forcing the UNION query SQL injection character to '%s'" % conf.uChar
logger.debug(debugMsg)
conf.uChar = "'%s'" % conf.uChar
def __setOS(): def __setOS():
""" """
Force the back-end DBMS operating system option. Force the back-end DBMS operating system option.
@ -1406,7 +1373,6 @@ def init(inputOptions=advancedDict()):
__setHTTPAuthentication() __setHTTPAuthentication()
__setHTTPProxy() __setHTTPProxy()
__setSafeUrl() __setSafeUrl()
__setUnion()
__setGoogleDorking() __setGoogleDorking()
__urllib2Opener() __urllib2Opener()
__findPageForms() __findPageForms()

View File

@ -36,4 +36,3 @@ def getCurrentThreadData():
if threadUID not in kb.threadData: if threadUID not in kb.threadData:
kb.threadData[threadUID] = ThreadData() kb.threadData[threadUID] = ThreadData()
return kb.threadData[threadUID] return kb.threadData[threadUID]

View File

@ -463,6 +463,7 @@ class Connect:
if kb.testMode: if kb.testMode:
kb.testQueryCount += 1 kb.testQueryCount += 1
if conf.cj: if conf.cj:
conf.cj.clear() conf.cj.clear()

View File

@ -320,13 +320,14 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
if (endCharIndex - startCharIndex == conf.progressWidth) and (endCharIndex < length-1): if (endCharIndex - startCharIndex == conf.progressWidth) and (endCharIndex < length-1):
output = output[:-2] + '..' output = output[:-2] + '..'
output += '_' * (min(length, conf.progressWidth) - len(output)) if conf.verbose in (1, 2) and not showEta:
status = ' %d/%d (%d%s)' % (count, length, round(100.0*count/length), '%') output += '_' * (min(length, conf.progressWidth) - len(output))
output += status if count != length else " "*len(status) status = ' %d/%d (%d%s)' % (count, length, round(100.0*count/length), '%')
output += status if count != length else " "*len(status)
iolock.acquire() iolock.acquire()
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), filterControlChars(output))) dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), filterControlChars(output)))
iolock.release() iolock.release()
if not kb.threadContinue: if not kb.threadContinue:
if int(threading.currentThread().getName()) == numThreads - 1: if int(threading.currentThread().getName()) == numThreads - 1:

View File

@ -744,6 +744,7 @@ class Enumeration:
if bruteForce: if bruteForce:
resumeAvailable = False resumeAvailable = False
for db, table in kb.brute.tables: for db, table in kb.brute.tables:
if db == conf.db: if db == conf.db:
resumeAvailable = True resumeAvailable = True
@ -919,6 +920,7 @@ class Enumeration:
if bruteForce: if bruteForce:
resumeAvailable = False resumeAvailable = False
for db, table, colName, colType in kb.brute.columns: for db, table, colName, colType in kb.brute.columns:
if db == conf.db and table == conf.tbl: if db == conf.db and table == conf.tbl:
resumeAvailable = True resumeAvailable = True
@ -931,6 +933,7 @@ class Enumeration:
columns[colName] = colType columns[colName] = colType
kb.data.cachedColumns[conf.db] = {conf.tbl: columns} kb.data.cachedColumns[conf.db] = {conf.tbl: columns}
return kb.data.cachedColumns return kb.data.cachedColumns
message = "do you want to use common columns existance check? [Y/n/q]" message = "do you want to use common columns existance check? [Y/n/q]"