Skip to content

Commit

Permalink
Merge pull request #102 from tiagogalvao/v2.7-flake8
Browse files Browse the repository at this point in the history
v2.7 preparation: code cleanup based on flake8 suggestions
  • Loading branch information
kimocoder committed Aug 6, 2022
2 parents 1bae850 + 7b1a5ef commit fe14f89
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 170 deletions.
3 changes: 2 additions & 1 deletion wifite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class Wifite(object):

def __init__(self):
"""
Initializes Wifite. Checks that its running under *nix, with root permissions and ensures dependencies are installed.
Initializes Wifite.
Checks that its running under *nix, with root permissions and ensures dependencies are installed.
"""

self.print_banner()
Expand Down
66 changes: 39 additions & 27 deletions wifite/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,26 @@ def _add_wep_args(self, wep):
dest='wep_crack_at_ivs',
metavar='[ivs]',
type=int,
help=self._verbose(
'Start cracking at this many IVs (default: {G}%d ivs{W})' % self.config.wep_crack_at_ivs))
help=self._verbose('Start cracking at this many IVs (default: {G}%d ivs{W})'
% self.config.wep_crack_at_ivs))
wep.add_argument('-wepca', help=argparse.SUPPRESS, action='store', dest='wep_crack_at_ivs', type=int)

wep.add_argument('--weprs',
action='store',
dest='wep_restart_stale_ivs',
metavar='[seconds]',
type=int,
help=self._verbose('Restart aireplay if no new IVs appear (default: ' +
'{G}%d sec{W})' % self.config.wep_restart_stale_ivs))
help=self._verbose('Restart aireplay if no new IVs appear (default: {G}%d sec{W})'
% self.config.wep_restart_stale_ivs))
wep.add_argument('-weprs', help=argparse.SUPPRESS, action='store', dest='wep_restart_stale_ivs', type=int)

wep.add_argument('--weprc',
action='store',
dest='wep_restart_aircrack',
metavar='[seconds]',
type=int,
help=self._verbose('Restart aircrack after this delay (default: ' +
'{G}%d sec{W})' % self.config.wep_restart_aircrack))
help=self._verbose('Restart aircrack after this delay (default: {G}%d sec{W})'
% self.config.wep_restart_aircrack))
wep.add_argument('-weprc', help=argparse.SUPPRESS, action='store', dest='wep_restart_aircrack', type=int)

wep.add_argument('--arpreplay',
Expand Down Expand Up @@ -327,8 +327,8 @@ def _add_wpa_args(self, wpa):
wpa.add_argument('--new-hs',
action='store_true',
dest='ignore_old_handshakes',
help=Color.s('Captures new handshakes, ignores existing handshakes ' +
'in {C}%s{W} (default: {G}off{W})' % self.config.wpa_handshake_dir))
help=Color.s('Captures new handshakes, ignores existing handshakes in {C}%s{W} '
'(default: {G}off{W})' % self.config.wpa_handshake_dir))

wpa.add_argument('--dict',
action='store',
Expand All @@ -343,17 +343,17 @@ def _add_wpa_args(self, wpa):
dest='wpa_deauth_timeout',
metavar='[seconds]',
type=int,
help=self._verbose('Time to wait between sending Deauths ' +
'(default: {G}%d sec{W})' % self.config.wpa_deauth_timeout))
help=self._verbose('Time to wait between sending Deauths (default: {G}%d sec{W})'
% self.config.wpa_deauth_timeout))
wpa.add_argument('-wpadt', help=argparse.SUPPRESS, action='store', dest='wpa_deauth_timeout', type=int)

wpa.add_argument('--wpat',
action='store',
dest='wpa_attack_timeout',
metavar='[seconds]',
type=int,
help=self._verbose('Time to wait before failing WPA attack ' +
'(default: {G}%d sec{W})' % self.config.wpa_attack_timeout))
help=self._verbose('Time to wait before failing WPA attack (default: {G}%d sec{W})'
% self.config.wpa_attack_timeout))
wpa.add_argument('-wpat', help=argparse.SUPPRESS, action='store', dest='wpa_attack_timeout', type=int)

# TODO: Uncomment the --strip option once it works
Expand All @@ -376,7 +376,7 @@ def _add_wps_args(self, wps):
wps.add_argument('--no-wps',
action='store_true',
dest='no_wps',
help=self._verbose('{O}Never{W} use {O}WPS PIN{W} & {O}Pixie-Dust{W}' +
help=self._verbose('{O}Never{W} use {O}WPS PIN{W} & {O}Pixie-Dust{W} '
'attacks on targets (default: {G}off{W})'))

wps.add_argument('--wps-only',
Expand All @@ -396,30 +396,32 @@ def _add_wps_args(self, wps):
wps.add_argument('--bully',
action='store_true',
dest='use_bully',
help=Color.s('Use {G}bully{W} program for WPS PIN & Pixie-Dust attacks ' +
help=Color.s('Use {G}bully{W} program for WPS PIN & Pixie-Dust attacks '
'(default: {G}reaver{W})'))
# Alias
wps.add_argument('-bully', help=argparse.SUPPRESS, action='store_true', dest='use_bully')

wps.add_argument('--reaver',
action='store_true',
dest='use_reaver',
help=Color.s('Use {G}reaver{W} program for WPS PIN & Pixie-Dust attacks (default: {G}reaver{W})'))
help=Color.s('Use {G}reaver{W} program for WPS PIN & Pixie-Dust attacks'
' (default: {G}reaver{W})'))
# Alias
wps.add_argument('-reaver', help=argparse.SUPPRESS, action='store_true', dest='use_reaver')

# Ignore lock-outs
wps.add_argument('--ignore-locks', action='store_true', dest='wps_ignore_lock',
help=Color.s('Do {O}not{W} stop WPS PIN attack if AP becomes {O}locked{W} (default: {G}stop{W})'))
help=Color.s('Do {O}not{W} stop WPS PIN attack if AP becomes {O}locked{W} '
'(default: {G}stop{W})'))

# Time limit on entire attack.
wps.add_argument('--wps-time',
action='store',
dest='wps_pixie_timeout',
metavar='[sec]',
type=int,
help=self._verbose('Total time to wait before failing PixieDust attack ' +
'(default: {G}%d sec{W})' % self.config.wps_pixie_timeout))
help=self._verbose('Total time to wait before failing PixieDust attack (default: {G}%d sec{W})'
% self.config.wps_pixie_timeout))
# Alias
wps.add_argument('-wpst', help=argparse.SUPPRESS, action='store', dest='wps_pixie_timeout', type=int)

Expand All @@ -429,8 +431,8 @@ def _add_wps_args(self, wps):
dest='wps_fail_threshold',
metavar='[num]',
type=int,
help=self._verbose('Maximum number of WPSFail/NoAssoc errors before ' +
'failing (default: {G}%d{W})' % self.config.wps_fail_threshold))
help=self._verbose('Maximum number of WPSFail/NoAssoc errors before failing '
'(default: {G}%d{W})' % self.config.wps_fail_threshold))
# Alias
wps.add_argument('-wpsf', help=argparse.SUPPRESS, action='store', dest='wps_fail_threshold', type=int)

Expand All @@ -440,16 +442,16 @@ def _add_wps_args(self, wps):
dest='wps_timeout_threshold',
metavar='[num]',
type=int,
help=self._verbose('Maximum number of Timeouts before failing ' +
'(default: {G}%d{W})' % self.config.wps_timeout_threshold))
help=self._verbose('Maximum number of Timeouts before failing (default: {G}%d{W})'
% self.config.wps_timeout_threshold))
# Alias
wps.add_argument('-wpsto', help=argparse.SUPPRESS, action='store', dest='wps_timeout_threshold', type=int)

def _add_pmkid_args(self, pmkid):
pmkid.add_argument('--pmkid',
action='store_true',
dest='use_pmkid_only',
help=Color.s('{O}Only{W} use {C}PMKID capture{W}, avoids other WPS & ' +
help=Color.s('{O}Only{W} use {C}PMKID capture{W}, avoids other WPS & '
'WPA attacks (default: {G}off{W})'))
pmkid.add_argument('--no-pmkid',
action='store_true',
Expand All @@ -464,15 +466,19 @@ def _add_pmkid_args(self, pmkid):
dest='pmkid_timeout',
metavar='[sec]',
type=int,
help=Color.s('Time to wait for PMKID capture ' +
'(default: {G}%d{W} seconds)' % self.config.pmkid_timeout))
help=Color.s('Time to wait for PMKID capture (default: {G}%d{W} seconds)'
% self.config.pmkid_timeout))

def _add_command_args(self, commands):
commands.add_argument('--cracked',
action='store_true',
dest='cracked',
help=Color.s('Print previously-cracked access points'))
commands.add_argument('-cracked', help=argparse.SUPPRESS, action='store_true', dest='cracked')

commands.add_argument('-cracked',
help=argparse.SUPPRESS,
action='store_true',
dest='cracked')

commands.add_argument('--check',
action='store',
Expand All @@ -481,7 +487,13 @@ def _add_command_args(self, commands):
const='<all>',
dest='check_handshake',
help=Color.s('Check a {C}.cap file{W} (or all {C}hs/*.cap{W} files) for WPA handshakes'))
commands.add_argument('-check', help=argparse.SUPPRESS, action='store', nargs='?', const='<all>', dest='check_handshake')

commands.add_argument('-check',
help=argparse.SUPPRESS,
action='store',
nargs='?',
const='<all>',
dest='check_handshake')

commands.add_argument('--crack',
action='store_true',
Expand Down
4 changes: 2 additions & 2 deletions wifite/attack/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def attack_multiple(cls, targets):
bssid = target.bssid
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))
Color.pl('\n{+} ({G}%d{W}/{G}%d{W})'
% (index, len(targets)) + ' Starting attacks against {C}%s{W} ({C}%s{W})' % (bssid, essid))

should_continue = cls.attack_single(target, targets_remaining)
if not should_continue:
Expand Down
12 changes: 5 additions & 7 deletions wifite/attack/pmkid.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def run_aircrack(self):
# essid = airodump_target.essid if airodump_target.essid_known else None
# handshake = self.load_handshake(bssid=bssid, essid=essid)
# if handshake:
# Color.pattack('WPA', self.target, 'Handshake capture', 'found {G}existing handshake{W} for {C}%s{W}' % handshake.essid)
# Color.pattack('WPA', self.target, 'Handshake capture',
# 'found {G}existing handshake{W} for {C}%s{W}' % handshake.essid)
# Color.pl('\n{+} Using handshake from {C}%s{W}' % handshake.capfile)
# return handshake

Expand All @@ -167,17 +168,14 @@ def run_aircrack(self):
copy(cap_file, temp_file)

# Check cap file in temp for Handshake
bssid = airodump_target.bssid
essid = airodump_target.essid if airodump_target.essid_known else None
# bssid = airodump_target.bssid
# essid = airodump_target.essid if airodump_target.essid_known else None

# AttackPMKID.check_pmkid(temp_file, self.target.bssid)
if self.check_pmkid(temp_file):
# We got a handshake
Color.clear_entire_line()
Color.pattack('WPA',
airodump_target,
'PMKID capture',
'{G}Captured PMKID{W}')
Color.pattack('WPA', airodump_target, 'PMKID capture', '{G}Captured PMKID{W}')
Color.pl('')
capture = temp_file
break
Expand Down
Loading

0 comments on commit fe14f89

Please sign in to comment.