File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments