diff --git a/lib/utils/hash.py b/lib/utils/hash.py index 0f2e471a3..1444cc910 100644 --- a/lib/utils/hash.py +++ b/lib/utils/hash.py @@ -630,10 +630,14 @@ def dictionaryAttack(attack_dict): process.terminate() process.join() - while not retVal.empty(): - _, hash_, word = item = retVal.get(block=False) - conf.hashDB.write(hash_, word) - results.append(item) + finally: + if retVal: + conf.hashDB.beginTransaction() + while not retVal.empty(): + _, hash_, word = item = retVal.get(block=False) + conf.hashDB.write(hash_, word) + results.append(item) + conf.hashDB.endTransaction() clearConsoleLine() @@ -706,10 +710,14 @@ def dictionaryAttack(attack_dict): process.terminate() process.join() - while not retVal.empty(): - _, hash_, word = item = retVal.get(block=False) - conf.hashDB.write(hash_, word) - results.append(item) + finally: + if retVal: + conf.hashDB.beginTransaction() + while not retVal.empty(): + _, hash_, word = item = retVal.get(block=False) + conf.hashDB.write(hash_, word) + results.append(item) + conf.hashDB.endTransaction() clearConsoleLine() diff --git a/lib/utils/hashdb.py b/lib/utils/hashdb.py index 2f0198a18..0b8fad1ea 100644 --- a/lib/utils/hashdb.py +++ b/lib/utils/hashdb.py @@ -75,3 +75,9 @@ class HashDB(object): raise else: break + + def beginTransaction(self): + self.cursor.execute('BEGIN TRANSACTION') + + def endTransaction(self): + self.cursor.execute('END TRANSACTION')