diff --git a/wifite/attack/pmkid.py b/wifite/attack/pmkid.py index a2fbba8..8c394a4 100644 --- a/wifite/attack/pmkid.py +++ b/wifite/attack/pmkid.py @@ -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 diff --git a/wifite/tools/hashcat.py b/wifite/tools/hashcat.py index c78f0ae..a44356e 100644 --- a/wifite/tools/hashcat.py +++ b/wifite/tools/hashcat.py @@ -22,34 +22,38 @@ class Hashcat(Dependency): Key (str) if found; `None` if not found. ''' - command = [ - 'hashcat', - '--force', - '--quiet', - '-m', '16800', - '-a', '0', # TODO: Configure - '-w', '2', # TODO: Configure - pmkid_file, - Configuration.wordlist - ] + # 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', # 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 + # TODO: Check status of hashcat (%); it's impossible with --quiet - try: - hashcat_proc = Process(command) - hashcat_proc.wait() - stdout = hashcat_proc.stdout() - except KeyboardInterrupt: # In case user gets impatient - Color.pl('\n{!} {O}Interrupted hashcat cracking{W}') - stdout = '' + try: + hashcat_proc = Process(command) + hashcat_proc.wait() + stdout = hashcat_proc.stdout() + except KeyboardInterrupt: # In case user gets impatient + Color.pl('\n{!} {O}Interrupted hashcat cracking{W}') + stdout = '' - if ':' not in stdout: - # Failed - return None - else: - # Cracked - key = stdout.strip().split(':', 1)[1] - return key + if ':' not in stdout: + # Failed + continue + else: + # Cracked + key = stdout.strip().split(':', 1)[1] + return key class HcxDumpTool(Dependency): diff --git a/wifite/util/process.py b/wifite/util/process.py index 8cd0345..9a9a824 100755 --- a/wifite/util/process.py +++ b/wifite/util/process.py @@ -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. diff --git a/wifite/wifite.py b/wifite/wifite.py index 17582af..d117354 100755 --- a/wifite/wifite.py +++ b/wifite/wifite.py @@ -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