Avoid AttributeErrors, support re-cracking PMKIDs

Process.__del__() swallows AttributeErrors now (for #120).

And hashcat won't output the key if it's already been cracked (it's in the pot file).
So we run hashcat again, with the --show parameter. This does not try to crack again.
This commit is contained in:
derv82
2018-08-16 00:10:13 -07:00
parent fd3c955c48
commit e48f3bb035
4 changed files with 49 additions and 36 deletions

View File

@@ -106,7 +106,7 @@ class AttackPMKID(Attack):
return None # No hash found.
Color.clear_entire_line()
Color.pattack('PMKID', self.target, 'CAPTURE', '{G}Captured PMKID{W}\n')
Color.pattack('PMKID', self.target, 'CAPTURE', '{G}Captured PMKID{W}')
pmkid_file = self.save_pmkid(pmkid_hash)
return pmkid_file
@@ -118,8 +118,6 @@ class AttackPMKID(Attack):
Returns:
True if cracked, False otherwise.
'''
with open(pmkid_file, 'r') as pmkid_handle:
Color.pl("\nPMKID_FILE:%s HASH:'%s'" % (pmkid_file, pmkid_handle.read()))
# Check that wordlist exists before cracking.
if Configuration.wordlist is None:
Color.pl('\n{!} {O}Not cracking because {R}wordlist{O} is not found.')
@@ -140,9 +138,10 @@ class AttackPMKID(Attack):
else:
# Successfully cracked.
Color.clear_entire_line()
Color.pattack('PMKID', self.target, 'CRACKED', '{C}Key: {G}%s{W}\n' % key)
Color.pattack('PMKID', self.target, 'CRACKED', '{C}Key: {G}%s{W}' % key)
self.crack_result = CrackResultPMKID(self.target.bssid, self.target.essid,
pmkid_file, key)
Color.pl('\n')
self.crack_result.dump()
return True

View File

@@ -22,16 +22,20 @@ class Hashcat(Dependency):
Key (str) if found; `None` if not found.
'''
# Run hashcat once normally, then with --show if it failed
# To catch cases where the password is already in the pot file.
for additional_arg in [ [], ['--show']]:
command = [
'hashcat',
'--force',
'--quiet',
'-m', '16800',
'--quiet', # Only output the password if found.
'-m', '16800', # WPA-PMKID-PBKDF2
'-a', '0', # TODO: Configure
'-w', '2', # TODO: Configure
pmkid_file,
Configuration.wordlist
]
command.extend(additional_arg)
# TODO: Check status of hashcat (%); it's impossible with --quiet
@@ -45,7 +49,7 @@ class Hashcat(Dependency):
if ':' not in stdout:
# Failed
return None
continue
else:
# Cracked
key = stdout.strip().split(':', 1)[1]

View File

@@ -93,8 +93,11 @@ class Process(object):
Ran when object is GC'd.
If process is still running at this point, it should die.
'''
try:
if self.pid and self.pid.poll() is None:
self.interrupt()
except AttributeError:
pass
def stdout(self):
''' Waits for process to finish, returns stdout output '''
@@ -177,23 +180,30 @@ class Process(object):
if __name__ == '__main__':
Configuration.initialize(False)
p = Process('ls')
print(p.stdout(), p.stderr())
print(p.stdout())
print(p.stderr())
p.interrupt()
# Calling as list of arguments
(out, err) = Process.call(['ls', '-lah'])
print(out, err)
print(out)
print(err)
print('\n---------------------\n')
# Calling as string
(out, err) = Process.call('ls -l | head -2')
print(out, err)
print(out)
print(err)
print('"reaver" exists:', Process.exists('reaver'))
print('"reaver" exists: %s' % Process.exists('reaver'))
# Test on never-ending process
p = Process('yes')
print("Running yes...")
time.sleep(1)
print("yes should stop now")
# After program loses reference to instance in 'p', process dies.

View File

@@ -64,7 +64,7 @@ class Wifite(object):
def print_banner(self):
""" Displays ASCII art of the highest caliber. """
Color.pl('''\
Color.pl(r'''
{G} . {GR}{D} {W}{G} . {W}
{G}.´ · .{GR}{D} {W}{G}. · `. {G}wifite {D}%s{W}
{G}: : : {GR}{D} (¯) {W}{G} : : : {W}{D}automated wireless auditor