Skip to content

Commit 17bd96f

Browse files
committed
Python improvements, messaging improvements.
Small code changed as proposed in #128. This should close #128. Slowly moving towards Camel-case in script output.
1 parent 7f0197e commit 17bd96f

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

wifite/attack/all.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def attack_multiple(cls, targets):
2222
essid = target.essid if target.essid_known else '{O}ESSID unknown{W}'
2323

2424
Color.pl('\n{+} ({G}%d{W}/{G}%d{W})' % (index, len(targets)) +
25-
' starting attacks against {C}%s{W} ({C}%s{W})' % (bssid, essid))
25+
' Starting attacks against {C}%s{W} ({C}%s{W})' % (bssid, essid))
2626

2727
should_continue = cls.attack_single(target, targets_remaining)
2828
if not should_continue:
@@ -67,7 +67,7 @@ def attack_single(cls, target, targets_remaining):
6767
attacks.append(AttackWPA(target))
6868

6969
if len(attacks) == 0:
70-
Color.pl('{!} {R}Error: {O}unable to attack: encryption not WEP or WPA')
70+
Color.pl('{!} {R}Error: {O}Unable to attack: encryption not WEP or WPA')
7171
return
7272

7373
while len(attacks) > 0:
@@ -80,7 +80,7 @@ def attack_single(cls, target, targets_remaining):
8080
Color.pexception(e)
8181
continue
8282
except KeyboardInterrupt:
83-
Color.pl('\n{!} {O}interrupted{W}\n')
83+
Color.pl('\n{!} {O}Interrupted{W}\n')
8484
if not cls.user_wants_to_continue(targets_remaining, len(attacks)):
8585
return False # Stop attacking other targets
8686

@@ -106,9 +106,9 @@ def user_wants_to_continue(cls, targets_remaining, attacks_remaining=0):
106106
if targets_remaining > 0:
107107
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
108108
prompt = ' and '.join(prompt_list)
109-
Color.pl('{+} %s remain, do you want to continue?' % prompt)
109+
Color.pl('{+} %s remain, Do you want to continue?' % prompt)
110110

111-
prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' +
111+
prompt = Color.s('{+} Type {G}c{W} to {G}continue{W}' +
112112
' or {R}s{W} to {R}stop{W}: ')
113113

114114
from ..util.input import raw_input

wifite/attack/pmkid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def dumptool_thread(self):
192192
dumptool = HcxDumpTool(self.target, self.pcapng_file)
193193

194194
# Let the dump tool run until we have the hash.
195-
while self.keep_capturing and dumptool.poll() == None:
195+
while self.keep_capturing and dumptool.poll() is None:
196196
time.sleep(0.5)
197197

198198
dumptool.interrupt()
@@ -202,7 +202,7 @@ def save_pmkid(self, pmkid_hash):
202202
'''Saves a copy of the pmkid (handshake) to hs/ directory.'''
203203
# Create handshake dir
204204
if not os.path.exists(Configuration.wpa_handshake_dir):
205-
os.mkdir(Configuration.wpa_handshake_dir)
205+
os.makedirs(Configuration.wpa_handshake_dir)
206206

207207
# Generate filesystem-safe filename from bssid, essid and date
208208
essid_safe = re.sub('[^a-zA-Z0-9]', '', self.target.essid)

wifite/attack/wpa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def save_handshake(self, handshake):
205205
'''
206206
# Create handshake dir
207207
if not os.path.exists(Configuration.wpa_handshake_dir):
208-
os.mkdir(Configuration.wpa_handshake_dir)
208+
os.makedirs(Configuration.wpa_handshake_dir)
209209

210210
# Generate filesystem-safe filename from bssid, essid and date
211211
if handshake.essid and type(handshake.essid) is str:

wifite/attack/wps.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,22 @@ def run(self):
1717

1818
# Drop out if user specified to not use Reaver/Bully
1919
if Configuration.use_pmkid_only:
20-
Color.pl('\r{!} {O}--pmkid{R} set, ignoring WPS attack on ' +
21-
'{O}%s{W}' % self.target.essid)
2220
self.success = False
2321
return False
2422

2523
if Configuration.no_wps:
26-
Color.pl('\r{!} {O}--no-wps{R} set, ignoring WPS attack on ' +
27-
'{O}%s{W}' % self.target.essid)
2824
self.success = False
2925
return False
3026

3127
if not Configuration.wps_pixie and self.pixie_dust:
32-
Color.pl('\r{!} {O}--no-pixie{R} set, ignoring WPS attack on ' +
28+
Color.pl('\r{!} {O}--no-pixie{R} was given, ignoring WPS PIN Attack on ' +
3329
'{O}%s{W}' % self.target.essid)
3430
self.success = False
3531
return False
3632

3733
if not Configuration.wps_pin and not self.pixie_dust:
38-
Color.pl('\r{!} {O}--no-pin{R} set, ignoring WPS attack on ' +
39-
'{O}%s{W}' % self.target.essid)
34+
Color.pl('\r{!} {O}--no-pin{R} was given, ignoring WPS Pixie-Dust Attack ' +
35+
'on {O}%s{W}' % self.target.essid)
4036
self.success = False
4137
return False
4238

wifite/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ def parse_wps_args(cls, args):
316316

317317
if args.wps_only:
318318
cls.wps_only = True
319-
Color.pl('{+} {C}option:{W} will *only* attack non-WEP networks with ' +
319+
cls.wps_filter = True # Also only show WPS networks
320+
Color.pl('{+} {C}option:{W} will *only* attack WPS networks with ' +
320321
'{G}WPS attacks{W} (avoids handshake and PMKID)')
321322

322323
if args.no_wps:

wifite/tools/hashcat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def crack_handshake(handshake, show_command=False):
2828

2929
key = None
3030
# Crack hccapx
31-
for additional_arg in [ [], ['--show']]:
31+
for additional_arg in ([], ['--show']):
3232
command = [
3333
'hashcat',
3434
'--quiet',
@@ -65,7 +65,7 @@ def crack_pmkid(pmkid_file, verbose=False):
6565

6666
# Run hashcat once normally, then with --show if it failed
6767
# To catch cases where the password is already in the pot file.
68-
for additional_arg in [ [], ['--show']]:
68+
for additional_arg in ([], ['--show']):
6969
command = [
7070
'hashcat',
7171
'--quiet', # Only output the password if found.

wifite/tools/reaver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def get_output(self):
443443

444444
(pin, psk, ssid) = Reaver.get_pin_psk_ssid(new_stdout)
445445
assert pin == '11867722', 'pin was "%s", should have been "11867722"' % pin
446-
assert psk == None, 'psk was "%s", should have been "None"' % psk
446+
assert psk is None, 'psk was "%s", should have been "None"' % psk
447447
assert ssid == 'belkin.00e', 'ssid was "%s", should have been "belkin.00e"' % repr(ssid)
448448
result = CrackResultWPS('AA:BB:CC:DD:EE:FF', ssid, pin, psk)
449449
result.dump()

wifite/util/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self):
5454
self.print_targets()
5555

5656
target_count = len(self.targets)
57-
client_count = sum([len(t.clients) for t in self.targets])
57+
client_count = sum(len(t.clients) for t in self.targets)
5858

5959
outline = '\r{+} Scanning'
6060
if airodump.decloaking:

0 commit comments

Comments
 (0)