From dbc0d995e316eec9a9834a5287d7254b32fdd670 Mon Sep 17 00:00:00 2001 From: deix Date: Mon, 28 Aug 2017 18:14:09 +0200 Subject: [PATCH] The start parameter for enumerate() Since python version 2.6 the start parameter was added and can be used --- Wifite.py | 8 ++++---- py/Airmon.py | 4 ++-- py/Airodump.py | 5 ++--- py/CrackHandshake.py | 4 ++-- py/Scanner.py | 5 ++--- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Wifite.py b/Wifite.py index 49f6a83..ec14a83 100755 --- a/Wifite.py +++ b/Wifite.py @@ -47,8 +47,8 @@ class Wifite(object): return with open(name, 'r') as fid: json = loads(fid.read()) - for (index, item) in enumerate(json): - Color.pl('\n{+} Cracked target #%d:' % (index + 1)) + for idx, item in enumerate(json, start=1): + Color.pl('\n{+} Cracked target #%d:' % (idx)) cr = CrackResult.load(item) cr.dump() @@ -88,11 +88,11 @@ class Wifite(object): attacked_targets = 0 targets_remaining = len(targets) - for index, t in enumerate(targets): + for idx, t in enumerate(targets, start=1): attacked_targets += 1 targets_remaining -= 1 - Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (index + 1, len(targets)) + + Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (idx, len(targets)) + ' starting attacks against {C}%s{W} ({C}%s{W})' % (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown")) if 'WEP' in t.encryption: diff --git a/py/Airmon.py b/py/Airmon.py index 0e209f7..52595d2 100644 --- a/py/Airmon.py +++ b/py/Airmon.py @@ -24,8 +24,8 @@ class Airmon(object): def print_menu(self): ''' Prints menu ''' print Interface.menu_header() - for (index, iface) in enumerate(self.interfaces): - Color.pl(" {G}%d{W}. %s" % (index + 1, iface)) + for idx, iface in enumerate(self.interfaces, start=1): + Color.pl(" {G}%d{W}. %s" % (idx, iface)) def get(self, index): ''' Gets interface at index (starts at 1) ''' diff --git a/py/Airodump.py b/py/Airodump.py index c42eef4..0957774 100644 --- a/py/Airodump.py +++ b/py/Airodump.py @@ -298,9 +298,8 @@ if __name__ == '__main__': targets = airodump.get_targets() Target.print_header() - for (index, target) in enumerate(targets): - index += 1 - Color.pl(' {G}%s %s' % (str(index).rjust(3), target)) + for idx, target in enumerate(targets, start=1): + Color.pl(' {G}%s %s' % (str(idx).rjust(3), target)) Configuration.delete_temp() diff --git a/py/CrackHandshake.py b/py/CrackHandshake.py index 17a27d3..19dcae7 100644 --- a/py/CrackHandshake.py +++ b/py/CrackHandshake.py @@ -74,11 +74,11 @@ class CrackHandshake(object): Color.p(" " + ("-" * 17)) Color.p(" " + ("-" * 19) + "\n") # Print all handshakes - for index, hs in enumerate(handshakes): + for idx, hs in enumerate(handshakes, start=1): bssid = hs["bssid"] essid = hs["essid"] date = datetime.strftime(datetime.fromtimestamp(hs["date"]), "%Y-%m-%dT%H:%M:%S") - Color.p(" {G}%s{W}" % str(index + 1).rjust(3)) + Color.p(" {G}%s{W}" % str(idx).rjust(3)) Color.p(" {C}%s{W}" % essid.ljust(max_essid_len)) Color.p(" {C}%s{W}" % bssid) Color.p(" {C}%s{W}\n" % date) diff --git a/py/Scanner.py b/py/Scanner.py index 288c9a6..8ecd423 100644 --- a/py/Scanner.py +++ b/py/Scanner.py @@ -125,10 +125,9 @@ class Scanner(object): Color.p('\r') Target.print_header() - for (index, target) in enumerate(self.targets): - index += 1 + for idx, target in enumerate(self.targets, start=1): Color.clear_entire_line() - Color.pl(' {G}%s %s' % (str(index).rjust(3), target)) + Color.pl(' {G}%s %s' % (str(idx).rjust(3), target)) @staticmethod def get_terminal_height():