Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another "Generator Expressions" improvements #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wifite/attack/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def attack_single(cls, target, targets_remaining):
# WPA can have multiple attack vectors:

# WPS
if target.wps != False:
if target.wps:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awkward... I recently changed Target.wps from a bool (binary) to bool + None (ternary).

  • True: Target is WPS and unlocked
  • False: Target is not WPS.
  • None: Target is WPS but locked

See

if target_bssid in wps_bssids:
t.wps = True
elif target_bssid in locked_bssids:
t.wps = None
else:
t.wps = False

I wanted to allow people to see Locked WPS targets, and still attack them if desired.

I should have added another field to model.target (such as target.wps_locked), but I was lazy & overloaded what wps meant.

if Configuration.wps_pixie:
attacks.append(AttackWPS(target, pixie_dust=True))
if Configuration.wps_pin:
Expand Down
4 changes: 2 additions & 2 deletions wifite/attack/pmkid.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self):
True if handshake is captured. False otherwise.
'''
# Skip if user only wants to attack WPS targets
if Configuration.wps_only and self.target.wps == False:
if Configuration.wps_only and not self.target.wps:
Color.pl('\r{!} {O}Skipping PMKID attack on {R}%s{O} because {R}--wps-only{O} is set{W}' % self.target.essid)
self.success = False
return False
Expand All @@ -82,7 +82,7 @@ def run(self):

pmkid_file = None

if Configuration.ignore_old_handshakes == False:
if not Configuration.ignore_old_handshakes:
# Load exisitng PMKID hash from filesystem
pmkid_file = self.get_existing_pmkid_file(self.target.bssid)
if pmkid_file is not None:
Expand Down
4 changes: 2 additions & 2 deletions wifite/attack/wpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(self):
'''Initiates full WPA handshake capture attack.'''

# Skip if target is not WPS
if Configuration.wps_only and self.target.wps == False:
if Configuration.wps_only and not self.target.wps:
Color.pl('\r{!} {O}Skipping WPA-Handshake attack on {R}%s{O} because {R}--wps-only{O} is set{W}' % self.target.essid)
self.success = False
return self.success
Expand Down Expand Up @@ -96,7 +96,7 @@ def capture_handshake(self):
self.clients = []

# Try to load existing handshake
if Configuration.ignore_old_handshakes == False:
if not Configuration.ignore_old_handshakes:
bssid = airodump_target.bssid
essid = airodump_target.essid if airodump_target.essid_known else None
handshake = self.load_handshake(bssid=bssid, essid=essid)
Expand Down
8 changes: 4 additions & 4 deletions wifite/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ def parse_settings_args(cls, args):
Color.pl('{+} {C}option:{W} targeting BSSID ' +
'{G}%s{W}' % args.target_bssid)

if args.five_ghz == True:
if args.five_ghz:
cls.five_ghz = True
Color.pl('{+} {C}option:{W} including {G}5Ghz networks{W} in scans')

if args.show_bssids == True:
if args.show_bssidS:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "if args.show_bssids:" with small "s" at the end - don't know why it come with capital letter from my code..

cls.show_bssids = True
Color.pl('{+} {C}option:{W} showing {G}bssids{W} of targets during scan')

if args.no_deauth == True:
if args.no_deauth:
cls.no_deauth = True
Color.pl('{+} {C}option:{W} will {R}not{W} {O}deauth{W} clients ' +
'during scans or captures')
Expand All @@ -207,7 +207,7 @@ def parse_settings_args(cls, args):
Color.pl('{+} {C}option:{W} {O}ignoring ESSIDs that include {R}%s{W}' % (
args.ignore_essid))

if args.clients_only == True:
if args.clients_only:
cls.clients_only = True
Color.pl('{+} {C}option:{W} {O}ignoring targets that do not have ' +
'associated clients')
Expand Down
2 changes: 1 addition & 1 deletion wifite/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def display(cls):
len(cracked_targets), name))

results = sorted([cls.load(item) for item in cracked_targets], key=lambda x: x.date, reverse=True)
longest_essid = max([len(result.essid or 'ESSID') for result in results])
longest_essid = max(len(result.essid or 'ESSID') for result in results)

# Header
Color.p('{D} ')
Expand Down
4 changes: 2 additions & 2 deletions wifite/model/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def to_str(self, show_bssid=False):
power = Color.s('{%s}%s' % (color, power))

wps = Color.s('{O} n/a')
if self.wps == True:
if self.wps:
wps = Color.s('{G} yes')
elif self.wps == False:
elif not self.wps:
wps = Color.s('{O} no')
elif self.wps is None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if-statement would never run, because not None evaluates to True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm, i have just made a quick test to resolve the situation and find possible solution - please try Yourself replacing the WPS value with "True/False/None":

WPS = None
if WPS:
print(True)
elif not WPS and WPS is not None:
print(False)
elif WPS is None:
print(None)

wps = Color.s('{R}lock')
Expand Down
6 changes: 2 additions & 4 deletions wifite/tools/airmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,8 @@ def terminate_conflicting_processes():

if not Configuration.kill_conflicting_processes:
# Don't kill processes, warn user
names_and_pids = ', '.join([
'{R}%s{O} (PID {R}%s{O})' % (pname, pid)
for pid, pname in pid_pnames
])
names_and_pids = ', '.join('{R}%s{O} (PID {R}%s{O})' % (pname, pid)
for pid, pname in pid_pnames)
Color.pl('{!} {O}Conflicting processes: %s' % names_and_pids)
Color.pl('{!} {O}If you have problems: {R}kill -9 PID{O} or re-run wifite with {R}--kill{O}){W}')
return
Expand Down
2 changes: 1 addition & 1 deletion wifite/tools/airodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def filter_targets(targets, skip_wps=False):
result.append(target)
elif 'WPA' in Configuration.encryption_filter and 'WPA' in target.encryption:
result.append(target)
elif 'WPS' in Configuration.encryption_filter and target.wps != False:
elif 'WPS' in Configuration.encryption_filter and target.wps:
result.append(target)
elif skip_wps:
result.append(target)
Expand Down
2 changes: 1 addition & 1 deletion wifite/tools/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_dependency_check(cls):
Macchanger
]

missing_required = any([app.fails_dependency_check() for app in apps])
missing_required = any(app.fails_dependency_check() for app in apps)

if missing_required:
Color.pl('{!} {O}At least 1 Required app is missing. Wifite needs Required apps to run{W}')
Expand Down
2 changes: 1 addition & 1 deletion wifite/tools/wash.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def check_for_wps_and_update_targets(capfile, targets):
obj = json.loads(line)
bssid = obj['bssid']
locked = obj['wps_locked']
if locked != True:
if not locked:
wps_bssids.add(bssid)
else:
locked_bssids.add(bssid)
Expand Down
4 changes: 2 additions & 2 deletions wifite/util/crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(cls):
return

hs_to_crack = cls.get_user_selection(handshakes)
any_pmkid = any([hs['type'] == 'PMKID' for hs in hs_to_crack])
any_pmkid = any(hs['type'] == 'PMKID' for hs in hs_to_crack)

# Tools for cracking & their dependencies.
available_tools = {
Expand All @@ -76,7 +76,7 @@ def run(cls):
if len(missing_tools) > 0:
Color.pl('\n{!} {O}Unavailable tools (install to enable):{W}')
for tool, deps in missing_tools:
dep_list = ', '.join([dep.dependency_name for dep in deps])
dep_list = ', '.join(dep.dependency_name for dep in deps)
Color.pl(' {R}* {R}%s {W}({O}%s{W})' % (tool, dep_list))

Color.p('\n{+} Enter the {C}cracking tool{W} to use ({C}%s{W}): {G}' % (
Expand Down
2 changes: 1 addition & 1 deletion wifite/util/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def found_target(self):
return False # No specific target from user.

for target in self.targets:
if Configuration.wps_only and target.wps == False:
if Configuration.wps_only and not target.wps:
continue
if bssid and target.bssid and bssid.lower() == target.bssid.lower():
self.target = target
Expand Down