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

@@ -93,8 +93,11 @@ class Process(object):
Ran when object is GC'd.
If process is still running at this point, it should die.
'''
if self.pid and self.pid.poll() is None:
self.interrupt()
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.