Small fixes for #133

* Avoid cracking the same PMKID twice when selecting multiple files &
specifying a tool that is not hashcat.

* Mention PMKID hashes can only be cracked using hashcat:
  1. If all files are PMKID, or
  2. If the file is PMKID but a tool other than hashcat was chosen.

* Fix header colors if a warning is printed before the handshake files.
This commit is contained in:
derv82
2018-09-03 10:59:38 -07:00
parent 6d492aca44
commit 79b2753929

View File

@@ -77,7 +77,7 @@ class CrackHelper:
Color.pl(' {R}* {R}%s {W}({O}%s{W})' % (tool, dep_list)) Color.pl(' {R}* {R}%s {W}({O}%s{W})' % (tool, dep_list))
if all_pmkid: if all_pmkid:
Color.pl('{!} {O}Note: PMKID hashes will be cracked using {C}hashcat{W}') Color.pl('{!} {O}Note: PMKID hashes can only be cracked using {C}hashcat{W}')
tool_name = 'hashcat' tool_name = 'hashcat'
else: else:
Color.p('\n{+} Enter the {C}cracking tool{W} to use ({C}%s{W}): {G}' % ( Color.p('\n{+} Enter the {C}cracking tool{W} to use ({C}%s{W}): {G}' % (
@@ -92,8 +92,6 @@ class CrackHelper:
if tool_name != 'hashcat' and hs['type'] == 'PMKID': if tool_name != 'hashcat' and hs['type'] == 'PMKID':
if 'hashcat' in missing_tools: if 'hashcat' in missing_tools:
Color.pl('{!} {O}Hashcat is missing, therefore we cannot crack PMKID hash{W}') Color.pl('{!} {O}Hashcat is missing, therefore we cannot crack PMKID hash{W}')
else:
cls.crack(hs, 'hashcat')
cls.crack(hs, tool_name) cls.crack(hs, tool_name)
except KeyboardInterrupt: except KeyboardInterrupt:
Color.pl('\n{!} {O}Interrupted{W}') Color.pl('\n{!} {O}Interrupted{W}')
@@ -171,9 +169,9 @@ class CrackHelper:
handshakes.append(handshake) handshakes.append(handshake)
if skipped_pmkid_files > 0: if skipped_pmkid_files > 0:
Color.pl('{!} {O}Skipping %d {R}*.16800{O} files because {R}hashcat{O} is missing.\n' % skipped_pmkid_files) Color.pl('{!} {O}Skipping %d {R}*.16800{O} files because {R}hashcat{O} is missing.{W}\n' % skipped_pmkid_files)
if skipped_cracked_files > 0: if skipped_cracked_files > 0:
Color.pl('{!} {O}Skipping %d already cracked files.\n' % skipped_cracked_files) Color.pl('{!} {O}Skipping %d already cracked files.{W}\n' % skipped_cracked_files)
# Sort by Date (Descending) # Sort by Date (Descending)
return sorted(handshakes, key=lambda x: x.get('date'), reverse=True) return sorted(handshakes, key=lambda x: x.get('date'), reverse=True)
@@ -183,7 +181,7 @@ class CrackHelper:
def print_handshakes(cls, handshakes): def print_handshakes(cls, handshakes):
# Header # Header
max_essid_len = max([len(hs['essid']) for hs in handshakes] + [len('ESSID (truncated)')]) max_essid_len = max([len(hs['essid']) for hs in handshakes] + [len('ESSID (truncated)')])
Color.p('{D} NUM') Color.p('{W}{D} NUM')
Color.p(' ' + 'ESSID (truncated)'.ljust(max_essid_len)) Color.p(' ' + 'ESSID (truncated)'.ljust(max_essid_len))
Color.p(' ' + 'BSSID'.ljust(17)) Color.p(' ' + 'BSSID'.ljust(17))
Color.p(' ' + 'TYPE'.ljust(5)) Color.p(' ' + 'TYPE'.ljust(5))
@@ -231,7 +229,7 @@ class CrackHelper:
cls.TYPES[hs['type']], hs['essid'], hs['bssid'])) cls.TYPES[hs['type']], hs['essid'], hs['bssid']))
if hs['type'] == 'PMKID': if hs['type'] == 'PMKID':
crack_result = cls.crack_pmkid(hs) crack_result = cls.crack_pmkid(hs, tool)
elif hs['type'] == '4-WAY': elif hs['type'] == '4-WAY':
crack_result = cls.crack_4way(hs, tool) crack_result = cls.crack_4way(hs, tool)
else: else:
@@ -276,7 +274,10 @@ class CrackHelper:
@classmethod @classmethod
def crack_pmkid(cls, hs): def crack_pmkid(cls, hs, tool):
if tool != 'hashcat':
Color.pl('{!} {O}Note: PMKID hashes can only be cracked using {C}hashcat{W}')
key = Hashcat.crack_pmkid(hs['filename'], verbose=True) key = Hashcat.crack_pmkid(hs['filename'], verbose=True)
if key is not None: if key is not None: