forked from s0lst1c3/eaphammer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf_manager.py
159 lines (127 loc) · 4.2 KB
/
conf_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import os
import config
import cnf_templates
def hostapd_parse_essid_cloaking(cloaking):
return {
'none' : 0,
'full' : 1,
'zeroes' : 2
}[cloaking]
def responder_parse_on_off(s):
return 'On' if s else 'Off'
class hostapd_wpe_cnf(object):
path = config.hostapd_cnf
template = cnf_templates.hostapd_wpe_cnf
@classmethod
def configure(cls,
interface=None,
ca_pem=config.ca_pem,
eap_user_file=config.eap_user_file,
server_pem=config.server_pem,
private_key=config.private_key,
dh_file=config.dh_file,
logpath=config.hostapd_log,
ssid=None,
hw_mode=None,
channel=None,
wpa=None,
bssid=None,
karma=False,
cloaking=None,
use_autocrack=False,
eaphammer_fifo_path=None):
assert interface is not None
assert ca_pem is not None
assert server_pem is not None
assert private_key is not None
assert dh_file is not None
assert ssid is not None
assert hw_mode is not None
assert channel is not None
assert wpa is not None
assert bssid is not None
assert cloaking is not None
assert eaphammer_fifo_path is not None
cloaking = hostapd_parse_essid_cloaking(cloaking)
with open(cls.path, 'w') as fd:
fd.write(cls.template %\
(interface, eap_user_file, ca_pem,
server_pem, private_key, dh_file,
ssid, hw_mode, channel, logpath,
wpa, cloaking, bssid,
int(karma), int(use_autocrack),
eaphammer_fifo_path))
class hostapd_open_cnf(object):
path = config.hostapd_cnf
template = cnf_templates.hostapd_open_cnf
@classmethod
def configure(cls,
interface=None,
ssid=None,
hw_mode=None,
channel=None,
bssid=None,
cloaking=None,
karma=False):
assert interface is not None
assert ssid is not None
assert hw_mode is not None
assert channel is not None
assert bssid is not None
assert cloaking is not None
cloaking = hostapd_parse_essid_cloaking(cloaking)
with open(cls.path, 'w') as fd:
fd.write(cls.template %\
(interface, ssid, hw_mode, channel,
bssid, int(karma), cloaking))
class dnsmasq_dhcp_only_cnf(object):
path = config.dnsmasq_cnf
template = cnf_templates.dnsmasq_dhcp_only
@classmethod
def configure(cls,
interface=None,
log_file=None,
dhcp_script=None):
assert interface is not None
assert log_file is not None
assert dhcp_script is not None
with open(cls.path, 'w') as fd:
fd.write(cls.template %\
(interface, log_file, dhcp_script))
class dnsmasq_captive_portal_cnf(object):
path = config.dnsmasq_cnf
template = cnf_templates.dnsmasq_captive_portal
@classmethod
def configure(cls,
interface=None,
log_file=None,
dhcp_script=None):
assert interface is not None
assert log_file is not None
assert dhcp_script is not None
with open(cls.path, 'w') as fd:
fd.write(cls.template %\
(interface, log_file, dhcp_script))
class responder_cnf(object):
path = config.responder_cnf
template = cnf_templates.responder_cnf
@classmethod
def configure(cls,
sql=True,
smb=True,
kerberos=True,
ftp=True,
pop=True,
smtp=True,
imap=True,
http=False,
https=False,
dns=False,
ldap=True,
db_file=config.responder_db):
f = responder_parse_on_off
with open(cls.path, 'w') as fd:
fd.write(cls.template %\
(f(sql), f(smb), f(kerberos), f(ftp),
f(pop), f(smtp), f(imap), f(http),
f(https), f(dns), f(ldap), db_file))