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

Skip to content

Commit f9bb762

Browse files
committed
minor improvement (resuming of already cracked values)
1 parent c0cd29f commit f9bb762

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/utils/hash.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from lib.core.convert import hexdecode
5151
from lib.core.convert import hexencode
5252
from lib.core.convert import utf8encode
53+
from lib.core.data import conf
5354
from lib.core.data import kb
5455
from lib.core.data import logger
5556
from lib.core.enums import DBMS
@@ -500,7 +501,15 @@ def dictionaryAttack(attack_dict):
500501

501502
key = hash(repr(item))
502503
if item and key not in keys:
503-
attack_info.append(item)
504+
resumed = conf.hashDB.retrieve(hash_)
505+
if not resumed:
506+
attack_info.append(item)
507+
else:
508+
infoMsg = "resuming found '%s' ('%s')" % (resumed, hash_)
509+
if user and not user.startswith(DUMMY_USER_PREFIX):
510+
infoMsg += " for user '%s'" % user
511+
logger.info(infoMsg)
512+
results.append((user, hash_, resumed))
504513
keys.add(key)
505514

506515
if not attack_info:
@@ -615,7 +624,9 @@ def dictionaryAttack(attack_dict):
615624
process.join()
616625

617626
while not retVal.empty():
618-
results.append(retVal.get(block=False))
627+
_, hash_, word = item = retVal.get(block=False)
628+
conf.hashDB.write(hash_, word)
629+
results.append(item)
619630

620631
clearConsoleLine()
621632

@@ -689,7 +700,9 @@ class Value():
689700
process.join()
690701

691702
while not retVal.empty():
692-
results.append(retVal.get(block=False))
703+
_, hash_, word = item = retVal.get(block=False)
704+
conf.hashDB.write(hash_, word)
705+
results.append(item)
693706

694707
clearConsoleLine()
695708

lib/utils/hashdb.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ def close(self):
4040
except:
4141
pass
4242

43-
def hashKey(self, key):
43+
@staticmethod
44+
def hashKey(key):
4445
key = key.encode(UNICODE_ENCODING) if isinstance(key, unicode) else repr(key)
4546
retVal = int(hashlib.md5(key).hexdigest()[:8], 16)
4647
return retVal
4748

4849
def retrieve(self, key):
4950
retVal = None
5051
if key:
51-
hash_ = self.hashKey(key)
52+
hash_ = HashDB.hashKey(key)
5253
while True:
5354
try:
5455
for row in self.cursor.execute("SELECT value FROM storage WHERE id=?", (hash_,)):
@@ -62,7 +63,7 @@ def retrieve(self, key):
6263

6364
def write(self, key, value):
6465
if key:
65-
hash_ = self.hashKey(key)
66+
hash_ = HashDB.hashKey(key)
6667
while True:
6768
try:
6869
try:

0 commit comments

Comments
 (0)