Skip to content

Another "Generator Expressions" improvements - #130

Open
deix wants to merge 2 commits into
derv82:masterfrom
deix:master
Open

Another "Generator Expressions" improvements#130
deix wants to merge 2 commits into
derv82:masterfrom
deix:master

Conversation

@deix

@deix deix commented Aug 25, 2018

Copy link
Copy Markdown
Contributor

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

deix added 2 commits August 25, 2018 19:47
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

deix commented Aug 25, 2018

Copy link
Copy Markdown
Contributor Author

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

@derv82 derv82 left a comment

Copy link
Copy Markdown
Owner

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.

Comment thread wifite/model/target.py
elif self.wps == False:
elif not self.wps:
wps = Color.s('{O} no')
elif self.wps is None:

Copy link
Copy Markdown
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
Copy Markdown
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)

Comment thread wifite/attack/all.py

# WPS
if target.wps != False:
if target.wps:

Copy link
Copy Markdown
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.

Comment thread wifite/config.py
Color.pl('{+} {C}option:{W} including {G}5Ghz networks{W} in scans')

if args.show_bssids == True:
if args.show_bssidS:

Copy link
Copy Markdown
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

derv82 commented Sep 9, 2018

Copy link
Copy Markdown
Owner

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

deix commented Sep 10, 2018

Copy link
Copy Markdown
Contributor Author

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

bencmd88 pushed a commit to bencmd88/wifite2 that referenced this pull request Mar 8, 2026
To avoid confusion about wps = True/False/None.
Came about because of derv82#130
maaffeedmaaf-art pushed a commit to maaffeedmaaf-art/wifite2 that referenced this pull request Mar 9, 2026
To avoid confusion about wps = True/False/None.
Came about because of derv82#130
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