Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/wifite/tools/wash.py
412 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from .dependency import Dependency
5
from ..model.target import WPSState
6
from ..util.process import Process
7
import json
8
9
class Wash(Dependency):
10
''' Wrapper for Wash program. '''
11
dependency_required = False
12
dependency_name = 'wash'
13
dependency_url = 'https://github.com/t6x/reaver-wps-fork-t6x'
14
15
def __init__(self):
16
pass
17
18
19
@staticmethod
20
def check_for_wps_and_update_targets(capfile, targets):
21
if not Wash.exists():
22
return
23
24
command = [
25
'wash',
26
'-f', capfile,
27
'-j' # json
28
]
29
30
p = Process(command)
31
try:
32
p.wait()
33
lines = p.stdout()
34
except:
35
# Failure is acceptable
36
return
37
38
# Find all BSSIDs
39
wps_bssids = set()
40
locked_bssids = set()
41
for line in lines.split('\n'):
42
try:
43
obj = json.loads(line)
44
bssid = obj['bssid']
45
locked = obj['wps_locked']
46
if locked != True:
47
wps_bssids.add(bssid)
48
else:
49
locked_bssids.add(bssid)
50
except:
51
pass
52
53
# Update targets
54
for t in targets:
55
target_bssid = t.bssid.upper()
56
if target_bssid in wps_bssids:
57
t.wps = WPSState.UNLOCKED
58
elif target_bssid in locked_bssids:
59
t.wps = WPSState.LOCKED
60
else:
61
t.wps = WPSState.NONE
62
63
64
if __name__ == '__main__':
65
test_file = './tests/files/contains_wps_network.cap'
66
67
target_bssid = 'A4:2B:8C:16:6B:3A'
68
from ..model.target import Target
69
fields = [
70
'A4:2B:8C:16:6B:3A', # BSSID
71
'2015-05-27 19:28:44', '2015-05-27 19:28:46', # Dates
72
'11', # Channel
73
'54', # throughput
74
'WPA2', 'CCMP TKIP', 'PSK', # AUTH
75
'-58', '2', '0', '0.0.0.0', '9', # ???
76
'Test Router Please Ignore', # SSID
77
]
78
t = Target(fields)
79
targets = [t]
80
81
# Should update 'wps' field of a target
82
Wash.check_for_wps_and_update_targets(test_file, targets)
83
84
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
85
targets[0].bssid, targets[0].wps))
86
87
assert targets[0].wps == WPSState.UNLOCKED
88
89
90