From 3c31ccd16e7766d18a23c9cdcad257218d4510cd Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 26 Oct 2011 22:37:04 +0000 Subject: [PATCH] minor update --- lib/core/common.py | 13 +++++++++++-- lib/utils/hash.py | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index ff29d62d5..88893cdc7 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -153,6 +153,7 @@ class Wordlist: self.cursize = 0 self.custom = [] self.adjust() + self.lock = None def __iter__(self): return self @@ -162,14 +163,17 @@ class Wordlist: if self.index > len(self.filenames): raise StopIteration elif self.index == len(self.filenames): - self.iter = iter(self.custom) + if self.custom: + self.iter = iter(self.custom) + else: + raise StopIteration else: current = self.filenames[self.index] infoMsg = "loading dictionary from '%s'" % current singleTimeLogMessage(infoMsg) self.fp = open(current, "r") self.cursize = os.path.getsize(current) - self.iter = self.fp.xreadlines() + self.iter = iter(self.fp) self.index += 1 @@ -183,11 +187,16 @@ class Wordlist: def next(self): retVal = None + if self.lock: + self.lock.acquire() try: retVal = self.iter.next().rstrip() except StopIteration: self.adjust() retVal = self.iter.next().rstrip() + finally: + if self.lock: + self.lock.release() return retVal def percentage(self): diff --git a/lib/utils/hash.py b/lib/utils/hash.py index f46c6a009..2ec779676 100644 --- a/lib/utils/hash.py +++ b/lib/utils/hash.py @@ -541,6 +541,9 @@ def dictionaryAttack(attack_dict): kb.wordlist = Wordlist(dictPaths) + if _multiprocessing: + kb.wordlist.lock = _multiprocessing.Lock() + except sqlmapFilePathException, msg: warnMsg = "there was a problem while loading dictionaries" warnMsg += " ('%s')" % msg