Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5269cb8

Browse files
committed
some code refactoring and beautification
1 parent 13e93f5 commit 5269cb8

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def parseXmlFile(xmlFile, handler):
12451245

12461246
def readCachedFileContent(filename, mode='rb'):
12471247
if filename not in kb.cache.content:
1248-
kb.data.cacheLock.acquire()
1248+
kb.locks.cacheLock.acquire()
12491249

12501250
if filename not in kb.cache.content:
12511251
checkFile(filename)
@@ -1254,7 +1254,7 @@ def readCachedFileContent(filename, mode='rb'):
12541254
kb.cache.content[filename] = content
12551255
xfile.close()
12561256

1257-
kb.data.cacheLock.release()
1257+
kb.locks.cacheLock.release()
12581258

12591259
return kb.cache.content[filename]
12601260

lib/core/option.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,6 @@ def __setKnowledgeBaseAttributes():
10281028
kb.commonOutputs = None
10291029

10301030
kb.data = advancedDict()
1031-
kb.data.cacheLock = threading.Lock()
1032-
kb.data.seqLock = None
10331031

10341032
# Basic back-end DBMS fingerprint
10351033
kb.dbms = None
@@ -1053,6 +1051,11 @@ def __setKnowledgeBaseAttributes():
10531051
kb.keywords = set(getFileItems(paths.SQL_KEYWORDS))
10541052
kb.lastErrorPage = None
10551053
kb.lastRequestUID = 0
1054+
1055+
kb.locks = advancedDict()
1056+
kb.locks.cacheLock = threading.Lock()
1057+
kb.locks.seqLock = None
1058+
10561059
kb.nullConnection = None
10571060

10581061
# Back-end DBMS underlying operating system fingerprint via banner (-b)

lib/request/comparison.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None):
5858
else:
5959
page = re.sub('(?s)%s.+%s' % (prefix, postfix), '%s%s' % (prefix, postfix), page)
6060

61-
if kb.data.seqLock:
62-
kb.data.seqLock.acquire()
61+
if kb.locks.seqLock:
62+
kb.locks.seqLock.acquire()
6363

6464
if not conf.eRegexp and not conf.eString and kb.nullConnection:
6565
ratio = 1. * pageLength / len(conf.seqMatcher.a)
@@ -69,8 +69,8 @@ def comparison(page, headers=None, getSeqMatcher=False, pageLength=None):
6969
conf.seqMatcher.set_seq2(page if not conf.textOnly else getFilteredPageContent(page))
7070
ratio = round(conf.seqMatcher.ratio(), 3)
7171

72-
if kb.data.seqLock:
73-
kb.data.seqLock.release()
72+
if kb.locks.seqLock:
73+
kb.locks.seqLock.release()
7474

7575
# If the url is stable and we did not set yet the match ratio and the
7676
# current injected value changes the url page content

lib/techniques/blind/inference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def etaProgressUpdate(charTime, index):
251251
idxlock = threading.Lock()
252252
iolock = threading.Lock()
253253
valuelock = threading.Lock()
254-
kb.data.seqLock = threading.Lock()
254+
kb.locks.seqLock = threading.Lock()
255255
conf.threadContinue = True
256256

257257
def downloadThread():
@@ -415,7 +415,7 @@ def downloadThread():
415415
if conf.verbose >= 1 and not showEta and infoMsg:
416416
dataToStdout(infoMsg)
417417

418-
kb.data.seqLock = None
418+
kb.locks.seqLock = None
419419

420420
# No multi-threading (--threads = 1)
421421
else:

0 commit comments

Comments
 (0)