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

Skip to content

Commit d735582

Browse files
committed
major speed improvement of hash cracking
1 parent b3a5739 commit d735582

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
DEFAULT_MSSQL_SCHEMA = 'dbo'
325325

326326
# Display hash attack info every mod number of items
327-
HASH_MOD_ITEM_DISPLAY = 1597
327+
HASH_MOD_ITEM_DISPLAY = 11
328328

329329
# Maximum integer value
330330
MAX_INT = sys.maxint

lib/utils/hash.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def hashRecognition(value):
344344
def __bruteProcessVariantA(attack_info, hash_regex, wordlist, suffix, retVal, proc_id, proc_count):
345345
count = 0
346346
rotator = 0
347+
hashes = set([item[0][1] for item in attack_info])
347348

348349
try:
349350
for word in wordlist:
@@ -359,33 +360,36 @@ def __bruteProcessVariantA(attack_info, hash_regex, wordlist, suffix, retVal, pr
359360
try:
360361
current = __functions__[hash_regex](password = word, uppercase = False)
361362

362-
for item in list(attack_info):
363-
((user, hash_), _) = item
363+
count += 1
364364

365-
count += 1
365+
if current in hashes:
366+
continue
366367

367-
if hash_ == current:
368-
retVal.put((user, hash_, word))
368+
for item in list(attack_info):
369+
((user, hash_), _) = item
369370

370-
clearConsoleLine()
371+
if hash_ == current:
372+
retVal.put((user, hash_, word))
371373

372-
infoMsg = "\r[%s] [INFO] cracked password '%s'" % (time.strftime("%X"), word)
374+
clearConsoleLine()
373375

374-
if user and not user.startswith(DUMMY_USER_PREFIX):
375-
infoMsg += " for user '%s'\n" % user
376-
else:
377-
infoMsg += " for hash '%s'\n" % hash_
376+
infoMsg = "\r[%s] [INFO] cracked password '%s'" % (time.strftime("%X"), word)
377+
378+
if user and not user.startswith(DUMMY_USER_PREFIX):
379+
infoMsg += " for user '%s'\n" % user
380+
else:
381+
infoMsg += " for hash '%s'\n" % hash_
378382

379-
dataToStdout(infoMsg, True)
383+
dataToStdout(infoMsg, True)
380384

381-
attack_info.remove(item)
385+
attack_info.remove(item)
382386

383-
elif proc_id == 0 and count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
384-
rotator += 1
385-
if rotator >= len(ROTATING_CHARS):
386-
rotator = 0
387-
status = 'current status: %s... %s' % (word.ljust(5)[:5], ROTATING_CHARS[rotator])
388-
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
387+
elif proc_id == 0 and count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex == HASH.ORACLE_OLD or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
388+
rotator += 1
389+
if rotator >= len(ROTATING_CHARS):
390+
rotator = 0
391+
status = 'current status: %s... %s' % (word.ljust(5)[:5], ROTATING_CHARS[rotator])
392+
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
389393

390394
except KeyboardInterrupt:
391395
raise
@@ -436,7 +440,7 @@ def __bruteProcessVariantB(user, hash_, kwargs, hash_regex, wordlist, suffix, re
436440
dataToStdout(infoMsg, True)
437441

438442
found.value = True
439-
elif proc_id == 0 and count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex in (HASH.ORACLE_OLD) or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
443+
elif proc_id == 0 and count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex == HASH.ORACLE_OLD or hash_regex == HASH.CRYPT_GENERIC and IS_WIN:
440444
rotator += 1
441445
if rotator >= len(ROTATING_CHARS):
442446
rotator = 0

0 commit comments

Comments
 (0)