Use enums to describe target WPS state.
To avoid confusion about wps = True/False/None. Came about because of #130
This commit is contained in:
@@ -6,7 +6,7 @@ from .tshark import Tshark
|
||||
from .wash import Wash
|
||||
from ..util.process import Process
|
||||
from ..config import Configuration
|
||||
from ..model.target import Target
|
||||
from ..model.target import Target, WPSState
|
||||
from ..model.client import Client
|
||||
|
||||
import os, time
|
||||
@@ -18,7 +18,8 @@ class Airodump(Dependency):
|
||||
dependency_url = 'https://www.aircrack-ng.org/install.html'
|
||||
|
||||
def __init__(self, interface=None, channel=None, encryption=None,\
|
||||
wps=False, target_bssid=None, output_file_prefix='airodump',\
|
||||
wps=WPSState.UNKNOWN, target_bssid=None,
|
||||
output_file_prefix='airodump',\
|
||||
ivs_only=False, skip_wps=False, delete_existing_files=True):
|
||||
'''Sets up airodump arguments, doesn't start process yet.'''
|
||||
|
||||
@@ -260,7 +261,7 @@ class Airodump(Dependency):
|
||||
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 in [WPSState.UNLOCKED, WPSState.LOCKED]:
|
||||
result.append(target)
|
||||
elif skip_wps:
|
||||
result.append(target)
|
||||
|
||||
@@ -134,7 +134,8 @@ class Bully(Attack, Dependency):
|
||||
return
|
||||
else:
|
||||
if self.locked and not Configuration.wps_ignore_lock:
|
||||
self.pattack('{R}Failed: {O}AP became {R}Locked{O}', newline=True)
|
||||
self.pattack('{R}Failed: {O}Access point is {R}Locked{O}',
|
||||
newline=True)
|
||||
self.stop()
|
||||
return
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class Reaver(Attack, Dependency):
|
||||
|
||||
# Check if locked
|
||||
if self.locked and not Configuration.wps_ignore_lock:
|
||||
raise Exception('{O}Because access point is {R}Locked{W}')
|
||||
raise Exception('{O}Access point is {R}Locked{W}')
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .dependency import Dependency
|
||||
from ..model.target import WPSState
|
||||
from ..util.process import Process
|
||||
import re
|
||||
|
||||
@@ -188,7 +189,6 @@ class Tshark(Dependency):
|
||||
if ',' not in line:
|
||||
continue
|
||||
bssid, locked = line.split(',')
|
||||
# Ignore if WPS is locked?
|
||||
if '1' not in locked:
|
||||
wps_bssids.add(bssid.upper())
|
||||
else:
|
||||
@@ -197,11 +197,11 @@ class Tshark(Dependency):
|
||||
for t in targets:
|
||||
target_bssid = t.bssid.upper()
|
||||
if target_bssid in wps_bssids:
|
||||
t.wps = True
|
||||
t.wps = WPSState.UNLOCKED
|
||||
elif target_bssid in locked_bssids:
|
||||
t.wps = None
|
||||
t.wps = WPSState.LOCKED
|
||||
else:
|
||||
t.wps = False
|
||||
t.wps = WPSState.NONE
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -224,7 +224,8 @@ if __name__ == '__main__':
|
||||
# Should update 'wps' field of a target
|
||||
Tshark.check_for_wps_and_update_targets(test_file, targets)
|
||||
|
||||
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
|
||||
assert targets[0].wps == True
|
||||
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
|
||||
targets[0].bssid, targets[0].wps))
|
||||
assert targets[0].wps == WPSState.UNLOCKED
|
||||
|
||||
print(Tshark.bssids_with_handshakes(test_file, bssid=target_bssid))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .dependency import Dependency
|
||||
from ..model.target import WPSState
|
||||
from ..util.process import Process
|
||||
import json
|
||||
|
||||
@@ -53,11 +54,11 @@ class Wash(Dependency):
|
||||
for t in targets:
|
||||
target_bssid = t.bssid.upper()
|
||||
if target_bssid in wps_bssids:
|
||||
t.wps = True
|
||||
t.wps = WPSState.UNLOCKED
|
||||
elif target_bssid in locked_bssids:
|
||||
t.wps = None
|
||||
t.wps = WPSState.LOCKED
|
||||
else:
|
||||
t.wps = False
|
||||
t.wps = WPSState.NONE
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -80,7 +81,8 @@ if __name__ == '__main__':
|
||||
# Should update 'wps' field of a target
|
||||
Wash.check_for_wps_and_update_targets(test_file, targets)
|
||||
|
||||
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
|
||||
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
|
||||
targets[0].bssid, targets[0].wps))
|
||||
|
||||
assert targets[0].wps == True
|
||||
assert targets[0].wps == WPSState.UNLOCKED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user