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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user