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

Another "Generator Expressions" improvements #130

wants to merge 2 commits into from

Conversation

deix
Copy link
Contributor

@deix deix commented Aug 25, 2018

The is no need to create the lists for the functions, iterator is still enough

The is no need to create the lists for the functions, iterator is still enough
According to: https://www.python.org/dev/peps/pep-0008/

Don't compare boolean values to True or False using ==.

Yes:   if greeting:
No:    if greeting == True:
Worse: if greeting is True:
@deix
Copy link
Contributor Author

deix commented Aug 25, 2018

I have another possible improvement to the code. Accordding to: "https://docs.python.org/3.6/library/stdtypes.html#truth-value-testing", testing if list is empty can be done taking advantage of the fact, that: "Here are most of the built-in objects considered false: ........empty sequences and collections: '', (), [], {}, set(), range(0)".
That is to say, that:

if len(some_list) > 0:
do sth

is equvalent with (without calling len() function:

if some_list:
do sth

This change would require some "find and replace" across the whole code, but might be worth doing...

Regards
deix

Copy link
Owner

@derv82 derv82 left a comment

Choose a reason for hiding this comment

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

The changes unrelated to wps seem fine to me, but see my comments on how wps == None is not the same as wps == False.

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)

@@ -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.

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..

@derv82
Copy link
Owner

derv82 commented Sep 9, 2018

I will fix the WPS True/False/None thing (change to an Enum) to avoid confusion in the future. Unfortunately, this will create conflicts with this PR.

derv82 added a commit that referenced this pull request Sep 9, 2018
To avoid confusion about wps = True/False/None.
Came about because of #130
@deix
Copy link
Contributor Author

deix commented Sep 10, 2018

Can You manually merge the small changes in the code, or should I create the fresh & new PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants