From ea125d820d984de6580a968c1a0bca27984c314a Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 2 Nov 2011 09:57:42 +0000 Subject: [PATCH] some more speed ups for hash cracking --- lib/utils/hash.py | 24 ++++++++++++++++-------- lib/utils/hashdb.py | 6 ++++++ 2 files changed, 22 insertions(+), 8 deletions(-) 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')