From 17bd96f29743dce89d1fd09a155dca4ab8f5ba59 Mon Sep 17 00:00:00 2001 From: derv82 Date: Fri, 24 Aug 2018 19:37:55 -0700 Subject: [PATCH] Python improvements, messaging improvements. Small code changed as proposed in #128. This should close #128. Slowly moving towards Camel-case in script output. --- wifite/attack/all.py | 10 +++++----- wifite/attack/pmkid.py | 4 ++-- wifite/attack/wpa.py | 2 +- wifite/attack/wps.py | 10 +++------- wifite/config.py | 3 ++- wifite/tools/hashcat.py | 4 ++-- wifite/tools/reaver.py | 2 +- wifite/util/scanner.py | 2 +- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/wifite/attack/all.py b/wifite/attack/all.py index 8fbd88e8c..6fab55a03 100755 --- a/wifite/attack/all.py +++ b/wifite/attack/all.py @@ -22,7 +22,7 @@ def attack_multiple(cls, targets): essid = target.essid if target.essid_known else '{O}ESSID unknown{W}' Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (index, len(targets)) + - ' starting attacks against {C}%s{W} ({C}%s{W})' % (bssid, essid)) + ' Starting attacks against {C}%s{W} ({C}%s{W})' % (bssid, essid)) should_continue = cls.attack_single(target, targets_remaining) if not should_continue: @@ -67,7 +67,7 @@ def attack_single(cls, target, targets_remaining): attacks.append(AttackWPA(target)) if len(attacks) == 0: - Color.pl('{!} {R}Error: {O}unable to attack: encryption not WEP or WPA') + Color.pl('{!} {R}Error: {O}Unable to attack: encryption not WEP or WPA') return while len(attacks) > 0: @@ -80,7 +80,7 @@ def attack_single(cls, target, targets_remaining): Color.pexception(e) continue except KeyboardInterrupt: - Color.pl('\n{!} {O}interrupted{W}\n') + Color.pl('\n{!} {O}Interrupted{W}\n') if not cls.user_wants_to_continue(targets_remaining, len(attacks)): return False # Stop attacking other targets @@ -106,9 +106,9 @@ def user_wants_to_continue(cls, targets_remaining, attacks_remaining=0): if targets_remaining > 0: prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining)) prompt = ' and '.join(prompt_list) - Color.pl('{+} %s remain, do you want to continue?' % prompt) + Color.pl('{+} %s remain, Do you want to continue?' % prompt) - prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' + + prompt = Color.s('{+} Type {G}c{W} to {G}continue{W}' + ' or {R}s{W} to {R}stop{W}: ') from ..util.input import raw_input diff --git a/wifite/attack/pmkid.py b/wifite/attack/pmkid.py index e55623c6d..1cc75c138 100755 --- a/wifite/attack/pmkid.py +++ b/wifite/attack/pmkid.py @@ -192,7 +192,7 @@ def dumptool_thread(self): dumptool = HcxDumpTool(self.target, self.pcapng_file) # Let the dump tool run until we have the hash. - while self.keep_capturing and dumptool.poll() == None: + while self.keep_capturing and dumptool.poll() is None: time.sleep(0.5) dumptool.interrupt() @@ -202,7 +202,7 @@ def save_pmkid(self, pmkid_hash): '''Saves a copy of the pmkid (handshake) to hs/ directory.''' # Create handshake dir if not os.path.exists(Configuration.wpa_handshake_dir): - os.mkdir(Configuration.wpa_handshake_dir) + os.makedirs(Configuration.wpa_handshake_dir) # Generate filesystem-safe filename from bssid, essid and date essid_safe = re.sub('[^a-zA-Z0-9]', '', self.target.essid) diff --git a/wifite/attack/wpa.py b/wifite/attack/wpa.py index 6e8c04db2..199965bbd 100755 --- a/wifite/attack/wpa.py +++ b/wifite/attack/wpa.py @@ -205,7 +205,7 @@ def save_handshake(self, handshake): ''' # Create handshake dir if not os.path.exists(Configuration.wpa_handshake_dir): - os.mkdir(Configuration.wpa_handshake_dir) + os.makedirs(Configuration.wpa_handshake_dir) # Generate filesystem-safe filename from bssid, essid and date if handshake.essid and type(handshake.essid) is str: diff --git a/wifite/attack/wps.py b/wifite/attack/wps.py index c5168cf0a..151f81ca6 100755 --- a/wifite/attack/wps.py +++ b/wifite/attack/wps.py @@ -17,26 +17,22 @@ def run(self): # Drop out if user specified to not use Reaver/Bully if Configuration.use_pmkid_only: - Color.pl('\r{!} {O}--pmkid{R} set, ignoring WPS attack on ' + - '{O}%s{W}' % self.target.essid) self.success = False return False if Configuration.no_wps: - Color.pl('\r{!} {O}--no-wps{R} set, ignoring WPS attack on ' + - '{O}%s{W}' % self.target.essid) self.success = False return False if not Configuration.wps_pixie and self.pixie_dust: - Color.pl('\r{!} {O}--no-pixie{R} set, ignoring WPS attack on ' + + Color.pl('\r{!} {O}--no-pixie{R} was given, ignoring WPS PIN Attack on ' + '{O}%s{W}' % self.target.essid) self.success = False return False if not Configuration.wps_pin and not self.pixie_dust: - Color.pl('\r{!} {O}--no-pin{R} set, ignoring WPS attack on ' + - '{O}%s{W}' % self.target.essid) + Color.pl('\r{!} {O}--no-pin{R} was given, ignoring WPS Pixie-Dust Attack ' + + 'on {O}%s{W}' % self.target.essid) self.success = False return False diff --git a/wifite/config.py b/wifite/config.py index 96f45f7af..463e36142 100755 --- a/wifite/config.py +++ b/wifite/config.py @@ -316,7 +316,8 @@ def parse_wps_args(cls, args): if args.wps_only: cls.wps_only = True - Color.pl('{+} {C}option:{W} will *only* attack non-WEP networks with ' + + cls.wps_filter = True # Also only show WPS networks + Color.pl('{+} {C}option:{W} will *only* attack WPS networks with ' + '{G}WPS attacks{W} (avoids handshake and PMKID)') if args.no_wps: diff --git a/wifite/tools/hashcat.py b/wifite/tools/hashcat.py index cb58c3ee0..89aa01731 100755 --- a/wifite/tools/hashcat.py +++ b/wifite/tools/hashcat.py @@ -28,7 +28,7 @@ def crack_handshake(handshake, show_command=False): key = None # Crack hccapx - for additional_arg in [ [], ['--show']]: + for additional_arg in ([], ['--show']): command = [ 'hashcat', '--quiet', @@ -65,7 +65,7 @@ def crack_pmkid(pmkid_file, verbose=False): # 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']]: + for additional_arg in ([], ['--show']): command = [ 'hashcat', '--quiet', # Only output the password if found. diff --git a/wifite/tools/reaver.py b/wifite/tools/reaver.py index b3c5af43d..2c418faeb 100755 --- a/wifite/tools/reaver.py +++ b/wifite/tools/reaver.py @@ -443,7 +443,7 @@ def get_output(self): (pin, psk, ssid) = Reaver.get_pin_psk_ssid(new_stdout) assert pin == '11867722', 'pin was "%s", should have been "11867722"' % pin - assert psk == None, 'psk was "%s", should have been "None"' % psk + assert psk is None, 'psk was "%s", should have been "None"' % psk assert ssid == 'belkin.00e', 'ssid was "%s", should have been "belkin.00e"' % repr(ssid) result = CrackResultWPS('AA:BB:CC:DD:EE:FF', ssid, pin, psk) result.dump() diff --git a/wifite/util/scanner.py b/wifite/util/scanner.py index fd6d72c20..bdaf3b582 100755 --- a/wifite/util/scanner.py +++ b/wifite/util/scanner.py @@ -54,7 +54,7 @@ def __init__(self): self.print_targets() target_count = len(self.targets) - client_count = sum([len(t.clients) for t in self.targets]) + client_count = sum(len(t.clients) for t in self.targets) outline = '\r{+} Scanning' if airodump.decloaking: