The start parameter for enumerate()

Since python version 2.6 the start parameter was added and can be used
This commit is contained in:
deix
2017-08-28 18:14:09 +02:00
parent 00e5246f96
commit dbc0d995e3
5 changed files with 12 additions and 14 deletions

View File

@@ -47,8 +47,8 @@ class Wifite(object):
return return
with open(name, 'r') as fid: with open(name, 'r') as fid:
json = loads(fid.read()) json = loads(fid.read())
for (index, item) in enumerate(json): for idx, item in enumerate(json, start=1):
Color.pl('\n{+} Cracked target #%d:' % (index + 1)) Color.pl('\n{+} Cracked target #%d:' % (idx))
cr = CrackResult.load(item) cr = CrackResult.load(item)
cr.dump() cr.dump()
@@ -88,11 +88,11 @@ class Wifite(object):
attacked_targets = 0 attacked_targets = 0
targets_remaining = len(targets) targets_remaining = len(targets)
for index, t in enumerate(targets): for idx, t in enumerate(targets, start=1):
attacked_targets += 1 attacked_targets += 1
targets_remaining -= 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})' ' starting attacks against {C}%s{W} ({C}%s{W})'
% (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown")) % (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown"))
if 'WEP' in t.encryption: if 'WEP' in t.encryption:

View File

@@ -24,8 +24,8 @@ class Airmon(object):
def print_menu(self): def print_menu(self):
''' Prints menu ''' ''' Prints menu '''
print Interface.menu_header() print Interface.menu_header()
for (index, iface) in enumerate(self.interfaces): for idx, iface in enumerate(self.interfaces, start=1):
Color.pl(" {G}%d{W}. %s" % (index + 1, iface)) Color.pl(" {G}%d{W}. %s" % (idx, iface))
def get(self, index): def get(self, index):
''' Gets interface at index (starts at 1) ''' ''' Gets interface at index (starts at 1) '''

View File

@@ -298,9 +298,8 @@ if __name__ == '__main__':
targets = airodump.get_targets() targets = airodump.get_targets()
Target.print_header() Target.print_header()
for (index, target) in enumerate(targets): for idx, target in enumerate(targets, start=1):
index += 1 Color.pl(' {G}%s %s' % (str(idx).rjust(3), target))
Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
Configuration.delete_temp() Configuration.delete_temp()

View File

@@ -74,11 +74,11 @@ class CrackHandshake(object):
Color.p(" " + ("-" * 17)) Color.p(" " + ("-" * 17))
Color.p(" " + ("-" * 19) + "\n") Color.p(" " + ("-" * 19) + "\n")
# Print all handshakes # Print all handshakes
for index, hs in enumerate(handshakes): for idx, hs in enumerate(handshakes, start=1):
bssid = hs["bssid"] bssid = hs["bssid"]
essid = hs["essid"] essid = hs["essid"]
date = datetime.strftime(datetime.fromtimestamp(hs["date"]), "%Y-%m-%dT%H:%M:%S") 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}" % essid.ljust(max_essid_len))
Color.p(" {C}%s{W}" % bssid) Color.p(" {C}%s{W}" % bssid)
Color.p(" {C}%s{W}\n" % date) Color.p(" {C}%s{W}\n" % date)

View File

@@ -125,10 +125,9 @@ class Scanner(object):
Color.p('\r') Color.p('\r')
Target.print_header() Target.print_header()
for (index, target) in enumerate(self.targets): for idx, target in enumerate(self.targets, start=1):
index += 1
Color.clear_entire_line() 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 @staticmethod
def get_terminal_height(): def get_terminal_height():