Skip to content

Commit 0645d4d

Browse files
author
WhiteOnBlackCode
committed
Merged WPS commit
2 parents 64d3ac0 + e190794 commit 0645d4d

File tree

9 files changed

+45
-28
lines changed

9 files changed

+45
-28
lines changed

wifite/config.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,15 @@ def parse_wpa_args(cls, args):
289289
cls.wpa_filter = args.wpa_filter
290290

291291
if args.wordlist:
292-
if os.path.exists(args.wordlist):
292+
if not os.path.exists(args.wordlist):
293+
cls.wordlist = None
294+
Color.pl('{+} {C}option:{O} wordlist {R}%s{O} was not found, wifite will NOT attempt to crack handshakes' % args.wordlist)
295+
elif os.path.isfile(args.wordlist):
293296
cls.wordlist = args.wordlist
294297
Color.pl('{+} {C}option:{W} using wordlist {G}%s{W} to crack WPA handshakes' % args.wordlist)
295-
else:
298+
elif os.path.isdir(args.wordlist):
296299
cls.wordlist = None
297-
Color.pl('{+} {C}option:{O} wordlist {R}%s{O} was not found, wifite will NOT attempt to crack handshakes' % args.wordlist)
300+
Color.pl('{+} {C}option:{O} wordlist {R}%s{O} is a directory, not a file. Wifite will NOT attempt to crack handshakes' % args.wordlist)
298301

299302
if args.wpa_deauth_timeout:
300303
cls.wpa_deauth_timeout = args.wpa_deauth_timeout

wifite/model/target.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
import re
77

8+
9+
class WPSState:
10+
NONE, UNLOCKED, LOCKED, UNKNOWN = range(0, 4)
11+
12+
813
class Target(object):
914
'''
1015
Holds details for a 'Target' aka Access Point (e.g. router).
@@ -60,8 +65,7 @@ def __init__(self, fields):
6065
self.essid = None # '(%s)' % self.bssid
6166
self.essid_known = False
6267

63-
# False=No WPS, None=Locked WPS, True=Unlocked WPS
64-
self.wps = False
68+
self.wps = WPSState.UNKNOWN
6569

6670
self.decloaked = False # If ESSID was hidden but we decloaked it.
6771

@@ -133,13 +137,14 @@ def to_str(self, show_bssid=False):
133137
color = 'R'
134138
power = Color.s('{%s}%s' % (color, power))
135139

136-
wps = Color.s('{O} n/a')
137-
if self.wps:
140+
if self.wps == WPSState.UNLOCKED:
138141
wps = Color.s('{G} yes')
139-
elif not self.wps:
142+
elif self.wps == WPSState.NONE:
140143
wps = Color.s('{O} no')
141-
elif self.wps is None:
144+
elif self.wps == WPSState.LOCKED:
142145
wps = Color.s('{R}lock')
146+
elif self.wps == WPSState.UNKNOWN:
147+
wps = Color.s('{O} n/a')
143148

144149
clients = ' '
145150
if len(self.clients) > 0:

wifite/tools/airodump.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .wash import Wash
77
from ..util.process import Process
88
from ..config import Configuration
9-
from ..model.target import Target
9+
from ..model.target import Target, WPSState
1010
from ..model.client import Client
1111

1212
import os, time
@@ -17,8 +17,9 @@ class Airodump(Dependency):
1717
dependency_name = 'airodump-ng'
1818
dependency_url = 'https://www.aircrack-ng.org/install.html'
1919

20-
def __init__(self, interface=None, channel=None, encryption=None,
21-
wps=False, target_bssid=None, output_file_prefix='airodump',
20+
def __init__(self, interface=None, channel=None, encryption=None,\
21+
wps=WPSState.UNKNOWN, target_bssid=None,
22+
output_file_prefix='airodump',\
2223
ivs_only=False, skip_wps=False, delete_existing_files=True):
2324
'''Sets up airodump arguments, doesn't start process yet.'''
2425

@@ -260,7 +261,7 @@ def filter_targets(targets, skip_wps=False):
260261
result.append(target)
261262
elif 'WPA' in Configuration.encryption_filter and 'WPA' in target.encryption:
262263
result.append(target)
263-
elif 'WPS' in Configuration.encryption_filter and target.wps != False:
264+
elif 'WPS' in Configuration.encryption_filter and target.wps in [WPSState.UNLOCKED, WPSState.LOCKED]:
264265
result.append(target)
265266
elif skip_wps:
266267
result.append(target)

wifite/tools/bully.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def _run(self, airodump):
134134
return
135135
else:
136136
if self.locked and not Configuration.wps_ignore_lock:
137-
self.pattack('{R}Failed: {O}AP became {R}Locked{O}', newline=True)
137+
self.pattack('{R}Failed: {O}Access point is {R}Locked{O}',
138+
newline=True)
138139
self.stop()
139140
return
140141

wifite/tools/reaver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def _run(self):
117117

118118
# Check if locked
119119
if self.locked and not Configuration.wps_ignore_lock:
120-
raise Exception('{O}Because access point is {R}Locked{W}')
120+
raise Exception('{O}Access point is {R}Locked{W}')
121121

122122
time.sleep(0.5)
123123

wifite/tools/tshark.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
from .dependency import Dependency
5+
from ..model.target import WPSState
56
from ..util.process import Process
67
import re
78

@@ -188,7 +189,6 @@ def check_for_wps_and_update_targets(capfile, targets):
188189
if ',' not in line:
189190
continue
190191
bssid, locked = line.split(',')
191-
# Ignore if WPS is locked?
192192
if '1' not in locked:
193193
wps_bssids.add(bssid.upper())
194194
else:
@@ -197,11 +197,11 @@ def check_for_wps_and_update_targets(capfile, targets):
197197
for t in targets:
198198
target_bssid = t.bssid.upper()
199199
if target_bssid in wps_bssids:
200-
t.wps = True
200+
t.wps = WPSState.UNLOCKED
201201
elif target_bssid in locked_bssids:
202-
t.wps = None
202+
t.wps = WPSState.LOCKED
203203
else:
204-
t.wps = False
204+
t.wps = WPSState.NONE
205205

206206

207207
if __name__ == '__main__':
@@ -224,7 +224,8 @@ def check_for_wps_and_update_targets(capfile, targets):
224224
# Should update 'wps' field of a target
225225
Tshark.check_for_wps_and_update_targets(test_file, targets)
226226

227-
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
228-
assert targets[0].wps == True
227+
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
228+
targets[0].bssid, targets[0].wps))
229+
assert targets[0].wps == WPSState.UNLOCKED
229230

230231
print(Tshark.bssids_with_handshakes(test_file, bssid=target_bssid))

wifite/tools/wash.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
from .dependency import Dependency
5+
from ..model.target import WPSState
56
from ..util.process import Process
67
import json
78

@@ -53,11 +54,11 @@ def check_for_wps_and_update_targets(capfile, targets):
5354
for t in targets:
5455
target_bssid = t.bssid.upper()
5556
if target_bssid in wps_bssids:
56-
t.wps = True
57+
t.wps = WPSState.UNLOCKED
5758
elif target_bssid in locked_bssids:
58-
t.wps = None
59+
t.wps = WPSState.LOCKED
5960
else:
60-
t.wps = False
61+
t.wps = WPSState.NONE
6162

6263

6364
if __name__ == '__main__':
@@ -80,7 +81,8 @@ def check_for_wps_and_update_targets(capfile, targets):
8081
# Should update 'wps' field of a target
8182
Wash.check_for_wps_and_update_targets(test_file, targets)
8283

83-
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
84+
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
85+
targets[0].bssid, targets[0].wps))
8486

85-
assert targets[0].wps == True
87+
assert targets[0].wps == WPSState.UNLOCKED
8688

wifite/util/color.py

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def pexception(exception):
9797
'''Prints an exception. Includes stack trace if necessary.'''
9898
Color.pl('\n{!} {R}Error: {O}%s' % str(exception))
9999

100+
# Don't dump trace for the "no targets found" case.
101+
if 'No targets found' in str(exception):
102+
return
103+
100104
from ..config import Configuration
101105
if Configuration.verbose > 0 or Configuration.print_stack_traces:
102106
Color.pl('\n{!} {O}Full stack trace below')

wifite/util/scanner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ..util.color import Color
55
from ..tools.airodump import Airodump
66
from ..util.input import raw_input, xrange
7-
from ..model.target import Target
7+
from ..model.target import Target, WPSState
88
from ..config import Configuration
99

1010
from time import sleep, time
@@ -88,7 +88,7 @@ def found_target(self):
8888
return False # No specific target from user.
8989

9090
for target in self.targets:
91-
if Configuration.wps_only and target.wps == False:
91+
if Configuration.wps_only and target.wps not in [WPSState.UNLOCKED, WPSState.LOCKED]:
9292
continue
9393
if bssid and target.bssid and bssid.lower() == target.bssid.lower():
9494
self.target = target

0 commit comments

Comments
 (0)