Skip to content

Commit

Permalink
util/crack: Fix python3 --crack crash
Browse files Browse the repository at this point in the history
Wifite would crash if run with python3 and the parameter --crack
if a dependency was missing, just after selecting a target.
This was caused by popping from a dictionary while iterating on
it, an operation forbidden in python3. Issue described in derv82#157

Signed-off-by: Radu Nicolau <[email protected]>
  • Loading branch information
RaduNico committed Oct 19, 2018
1 parent e190794 commit 084a658
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions wifite/util/crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class CrackHelper:
'PMKID': 'PMKID Hash'
}

# Tools for cracking & their dependencies.
possible_tools = [
('aircrack', [Aircrack]),
('hashcat', [Hashcat, HcxPcapTool]),
('john', [John, HcxPcapTool]),
('cowpatty', [Cowpatty])
]

@classmethod
def run(cls):
Configuration.initialize(False)
Expand All @@ -52,23 +60,18 @@ def run(cls):
hs_to_crack = cls.get_user_selection(handshakes)
all_pmkid = all([hs['type'] == 'PMKID' for hs in hs_to_crack])

# Tools for cracking & their dependencies.
available_tools = {
'aircrack': [Aircrack],
'hashcat': [Hashcat, HcxPcapTool],
'john': [John, HcxPcapTool],
'cowpatty': [Cowpatty]
}
# Identify missing tools
missing_tools = []
for tool, dependencies in available_tools.items():
available_tools = []
for tool, dependencies in cls.possible_tools:
missing = [
dep for dep in dependencies
if not Process.exists(dep.dependency_name)
]
if len(missing) > 0:
available_tools.pop(tool)
missing_tools.append( (tool, missing) )
missing_tools.append((tool, missing))
else:
available_tools.append(tool)

if len(missing_tools) > 0:
Color.pl('\n{!} {O}Unavailable tools (install to enable):{W}')
Expand All @@ -81,7 +84,7 @@ def run(cls):
tool_name = 'hashcat'
else:
Color.p('\n{+} Enter the {C}cracking tool{W} to use ({C}%s{W}): {G}' % (
'{W}, {C}'.join(available_tools.keys())))
'{W}, {C}'.join(available_tools)))
tool_name = raw_input()
if tool_name not in available_tools:
Color.pl('{!} {R}"%s"{O} tool not found, defaulting to {C}aircrack{W}' % tool_name)
Expand Down

0 comments on commit 084a658

Please sign in to comment.