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

Skip to content

Commit 3c31ccd

Browse files
committed
minor update
1 parent 9d31230 commit 3c31ccd

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/core/common.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def __init__(self, filenames):
153153
self.cursize = 0
154154
self.custom = []
155155
self.adjust()
156+
self.lock = None
156157

157158
def __iter__(self):
158159
return self
@@ -162,14 +163,17 @@ def adjust(self):
162163
if self.index > len(self.filenames):
163164
raise StopIteration
164165
elif self.index == len(self.filenames):
165-
self.iter = iter(self.custom)
166+
if self.custom:
167+
self.iter = iter(self.custom)
168+
else:
169+
raise StopIteration
166170
else:
167171
current = self.filenames[self.index]
168172
infoMsg = "loading dictionary from '%s'" % current
169173
singleTimeLogMessage(infoMsg)
170174
self.fp = open(current, "r")
171175
self.cursize = os.path.getsize(current)
172-
self.iter = self.fp.xreadlines()
176+
self.iter = iter(self.fp)
173177

174178
self.index += 1
175179

@@ -183,11 +187,16 @@ def closeFP(self):
183187

184188
def next(self):
185189
retVal = None
190+
if self.lock:
191+
self.lock.acquire()
186192
try:
187193
retVal = self.iter.next().rstrip()
188194
except StopIteration:
189195
self.adjust()
190196
retVal = self.iter.next().rstrip()
197+
finally:
198+
if self.lock:
199+
self.lock.release()
191200
return retVal
192201

193202
def percentage(self):

lib/utils/hash.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ def dictionaryAttack(attack_dict):
541541

542542
kb.wordlist = Wordlist(dictPaths)
543543

544+
if _multiprocessing:
545+
kb.wordlist.lock = _multiprocessing.Lock()
546+
544547
except sqlmapFilePathException, msg:
545548
warnMsg = "there was a problem while loading dictionaries"
546549
warnMsg += " ('%s')" % msg

0 commit comments

Comments
 (0)