mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-26 11:33:47 +03:00
some code refactoring and beautification
This commit is contained in:
parent
13e93f564a
commit
5269cb8c08
|
@ -1245,7 +1245,7 @@ def parseXmlFile(xmlFile, handler):
|
||||||
|
|
||||||
def readCachedFileContent(filename, mode='rb'):
|
def readCachedFileContent(filename, mode='rb'):
|
||||||
if filename not in kb.cache.content:
|
if filename not in kb.cache.content:
|
||||||
kb.data.cacheLock.acquire()
|
kb.locks.cacheLock.acquire()
|
||||||
|
|
||||||
if filename not in kb.cache.content:
|
if filename not in kb.cache.content:
|
||||||
checkFile(filename)
|
checkFile(filename)
|
||||||
|
@ -1254,7 +1254,7 @@ def readCachedFileContent(filename, mode='rb'):
|
||||||
kb.cache.content[filename] = content
|
kb.cache.content[filename] = content
|
||||||
xfile.close()
|
xfile.close()
|
||||||
|
|
||||||
kb.data.cacheLock.release()
|
kb.locks.cacheLock.release()
|
||||||
|
|
||||||
return kb.cache.content[filename]
|
return kb.cache.content[filename]
|
||||||
|
|
||||||
|
|
|
@ -1028,8 +1028,6 @@ def __setKnowledgeBaseAttributes():
|
||||||
kb.commonOutputs = None
|
kb.commonOutputs = None
|
||||||
|
|
||||||
kb.data = advancedDict()
|
kb.data = advancedDict()
|
||||||
kb.data.cacheLock = threading.Lock()
|
|
||||||
kb.data.seqLock = None
|
|
||||||
|
|
||||||
# Basic back-end DBMS fingerprint
|
# Basic back-end DBMS fingerprint
|
||||||
kb.dbms = None
|
kb.dbms = None
|
||||||
|
@ -1053,6 +1051,11 @@ def __setKnowledgeBaseAttributes():
|
||||||
kb.keywords = set(getFileItems(paths.SQL_KEYWORDS))
|
kb.keywords = set(getFileItems(paths.SQL_KEYWORDS))
|
||||||
kb.lastErrorPage = None
|
kb.lastErrorPage = None
|
||||||
kb.lastRequestUID = 0
|
kb.lastRequestUID = 0
|
||||||
|
|
||||||
|
kb.locks = advancedDict()
|
||||||
|
kb.locks.cacheLock = threading.Lock()
|
||||||
|
kb.locks.seqLock = None
|
||||||
|
|
||||||
kb.nullConnection = None
|
kb.nullConnection = None
|
||||||
|
|
||||||
# Back-end DBMS underlying operating system fingerprint via banner (-b)
|
# Back-end DBMS underlying operating system fingerprint via banner (-b)
|
||||||
|
|
|
@ -58,8 +58,8 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None):
|
||||||
else:
|
else:
|
||||||
page = re.sub('(?s)%s.+%s' % (prefix, postfix), '%s%s' % (prefix, postfix), page)
|
page = re.sub('(?s)%s.+%s' % (prefix, postfix), '%s%s' % (prefix, postfix), page)
|
||||||
|
|
||||||
if kb.data.seqLock:
|
if kb.locks.seqLock:
|
||||||
kb.data.seqLock.acquire()
|
kb.locks.seqLock.acquire()
|
||||||
|
|
||||||
if not conf.eRegexp and not conf.eString and kb.nullConnection:
|
if not conf.eRegexp and not conf.eString and kb.nullConnection:
|
||||||
ratio = 1. * pageLength / len(conf.seqMatcher.a)
|
ratio = 1. * pageLength / len(conf.seqMatcher.a)
|
||||||
|
@ -69,8 +69,8 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None):
|
||||||
conf.seqMatcher.set_seq2(page if not conf.textOnly else getFilteredPageContent(page))
|
conf.seqMatcher.set_seq2(page if not conf.textOnly else getFilteredPageContent(page))
|
||||||
ratio = round(conf.seqMatcher.ratio(), 3)
|
ratio = round(conf.seqMatcher.ratio(), 3)
|
||||||
|
|
||||||
if kb.data.seqLock:
|
if kb.locks.seqLock:
|
||||||
kb.data.seqLock.release()
|
kb.locks.seqLock.release()
|
||||||
|
|
||||||
# If the url is stable and we did not set yet the match ratio and the
|
# If the url is stable and we did not set yet the match ratio and the
|
||||||
# current injected value changes the url page content
|
# current injected value changes the url page content
|
||||||
|
|
|
@ -251,7 +251,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||||
idxlock = threading.Lock()
|
idxlock = threading.Lock()
|
||||||
iolock = threading.Lock()
|
iolock = threading.Lock()
|
||||||
valuelock = threading.Lock()
|
valuelock = threading.Lock()
|
||||||
kb.data.seqLock = threading.Lock()
|
kb.locks.seqLock = threading.Lock()
|
||||||
conf.threadContinue = True
|
conf.threadContinue = True
|
||||||
|
|
||||||
def downloadThread():
|
def downloadThread():
|
||||||
|
@ -415,7 +415,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||||
if conf.verbose >= 1 and not showEta and infoMsg:
|
if conf.verbose >= 1 and not showEta and infoMsg:
|
||||||
dataToStdout(infoMsg)
|
dataToStdout(infoMsg)
|
||||||
|
|
||||||
kb.data.seqLock = None
|
kb.locks.seqLock = None
|
||||||
|
|
||||||
# No multi-threading (--threads = 1)
|
# No multi-threading (--threads = 1)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user