Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/wifite/args.py
410 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from .util.color import Color
5
6
import argparse, sys
7
8
class Arguments(object):
9
''' Holds arguments used by the Wifite '''
10
11
def __init__(self, configuration):
12
# Hack: Check for -v before parsing args; so we know which commands to display.
13
self.verbose = '-v' in sys.argv or '-hv' in sys.argv or '-vh' in sys.argv
14
self.config = configuration
15
self.args = self.get_arguments()
16
17
def _verbose(self, msg):
18
if self.verbose:
19
return Color.s(msg)
20
else:
21
return argparse.SUPPRESS
22
23
def get_arguments(self):
24
''' Returns parser.args() containing all program arguments '''
25
26
parser = argparse.ArgumentParser(usage=argparse.SUPPRESS,
27
formatter_class=lambda prog: argparse.HelpFormatter(
28
prog, max_help_position=80, width=130))
29
30
self._add_global_args(parser.add_argument_group(Color.s('{C}SETTINGS{W}')))
31
self._add_wep_args(parser.add_argument_group(Color.s('{C}WEP{W}')))
32
self._add_wpa_args(parser.add_argument_group(Color.s('{C}WPA{W}')))
33
self._add_wps_args(parser.add_argument_group(Color.s('{C}WPS{W}')))
34
self._add_pmkid_args(parser.add_argument_group(Color.s('{C}PMKID{W}')))
35
self._add_eviltwin_args(parser.add_argument_group(Color.s('{C}EVIL TWIN{W}')))
36
self._add_command_args(parser.add_argument_group(Color.s('{C}COMMANDS{W}')))
37
38
return parser.parse_args()
39
40
41
def _add_global_args(self, glob):
42
glob.add_argument('-v',
43
'--verbose',
44
action='count',
45
default=0,
46
dest='verbose',
47
help=Color.s('Shows more options ({C}-h -v{W}). Prints commands and ' +
48
'outputs. (default: {G}quiet{W})'))
49
50
glob.add_argument('-i',
51
action='store',
52
dest='interface',
53
metavar='[interface]',
54
type=str,
55
help=Color.s('Wireless interface to use, e.g. {C}wlan0mon{W} ' +
56
'(default: {G}ask{W})'))
57
58
glob.add_argument('-c',
59
action='store',
60
dest='channel',
61
metavar='[channel]',
62
type=int,
63
help=Color.s('Wireless channel to scan (default: {G}all 2Ghz channels{W})'))
64
glob.add_argument('--channel', help=argparse.SUPPRESS, action='store',
65
dest='channel', type=int)
66
67
glob.add_argument('-5',
68
'--5ghz',
69
action='store_true',
70
dest='five_ghz',
71
help=self._verbose('Include 5Ghz channels (default: {G}off{W})'))
72
73
74
glob.add_argument('-mac',
75
'--random-mac',
76
action='store_true',
77
dest='random_mac',
78
help=Color.s('Randomize wireless card MAC address (default: {G}off{W})'))
79
80
glob.add_argument('-p',
81
action='store',
82
dest='scan_time',
83
nargs='?',
84
const=10,
85
metavar='scan_time',
86
type=int,
87
help=Color.s('{G}Pillage{W}: Attack all targets after ' +
88
'{C}scan_time{W} (seconds)'))
89
glob.add_argument('--pillage', help=argparse.SUPPRESS, action='store',
90
dest='scan_time', nargs='?', const=10, type=int)
91
92
glob.add_argument('--kill',
93
action='store_true',
94
dest='kill_conflicting_processes',
95
help=Color.s('Kill processes that conflict with Airmon/Airodump ' +
96
'(default: {G}off{W})'))
97
98
glob.add_argument('-b',
99
action='store',
100
dest='target_bssid',
101
metavar='[bssid]',
102
type=str,
103
help=self._verbose('BSSID (e.g. {GR}AA:BB:CC:DD:EE:FF{W}) of access ' +
104
'point to attack'))
105
glob.add_argument('--bssid', help=argparse.SUPPRESS, action='store',
106
dest='target_bssid', type=str)
107
108
glob.add_argument('-e',
109
action='store',
110
dest='target_essid',
111
metavar='[essid]',
112
type=str,
113
help=self._verbose('ESSID (e.g. {GR}NETGEAR07{W}) of access point to attack'))
114
glob.add_argument('--essid', help=argparse.SUPPRESS, action='store',
115
dest='target_essid', type=str)
116
117
glob.add_argument('-E',
118
action='store',
119
dest='ignore_essid',
120
metavar='[text]',
121
type=str,
122
default=None,
123
help=self._verbose('Hides targets with ESSIDs that match the given text'))
124
glob.add_argument('--ignore-essid', help=argparse.SUPPRESS, action='store',
125
dest='ignore_essid', type=str)
126
127
glob.add_argument('--clients-only',
128
action='store_true',
129
dest='clients_only',
130
help=Color.s('Only show targets that have associated clients ' +
131
'(default: {G}off{W})'))
132
133
glob.add_argument('--showb',
134
action='store_true',
135
dest='show_bssids',
136
help=self._verbose('Show BSSIDs of targets while scanning'))
137
138
glob.add_argument('--nodeauths',
139
action='store_true',
140
dest='no_deauth',
141
help=Color.s('Passive mode: Never deauthenticates clients ' +
142
'(default: {G}deauth targets{W})'))
143
glob.add_argument('--no-deauths', action='store_true', dest='no_deauth',
144
help=argparse.SUPPRESS)
145
glob.add_argument('-nd', action='store_true', dest='no_deauth',
146
help=argparse.SUPPRESS)
147
148
glob.add_argument('--num-deauths',
149
action='store',
150
type=int,
151
dest='num_deauths',
152
metavar='[num]',
153
default=None,
154
help=self._verbose('Number of deauth packets to send (default: ' +
155
'{G}%d{W})' % self.config.num_deauths))
156
157
158
def _add_eviltwin_args(self, group):
159
pass
160
'''
161
group.add_argument('--eviltwin',
162
action='store_true',
163
dest='use_eviltwin',
164
help=Color.s('Use the "Evil Twin" attack against all targets ' +
165
'(default: {G}off{W})'))
166
# TODO: Args to specify deauth interface, server port, etc.
167
'''
168
169
170
def _add_wep_args(self, wep):
171
# WEP
172
wep.add_argument('--wep',
173
action='store_true',
174
dest='wep_filter',
175
help=Color.s('Show only {C}WEP-encrypted networks{W}'))
176
wep.add_argument('-wep', help=argparse.SUPPRESS, action='store_true',
177
dest='wep_filter')
178
179
wep.add_argument('--require-fakeauth',
180
action='store_true',
181
dest='require_fakeauth',
182
help=Color.s('Fails attacks if {C}fake-auth{W} fails (default: {G}off{W})'))
183
wep.add_argument('--nofakeauth', help=argparse.SUPPRESS, action='store_true',
184
dest='require_fakeauth')
185
wep.add_argument('-nofakeauth', help=argparse.SUPPRESS, action='store_true',
186
dest='require_fakeauth')
187
188
wep.add_argument('--keep-ivs',
189
action='store_true',
190
dest='wep_keep_ivs',
191
default=False,
192
help=Color.s('Retain .IVS files and reuse when cracking ' +
193
'(default: {G}off{W})'))
194
195
wep.add_argument('--pps',
196
action='store',
197
dest='wep_pps',
198
metavar='[pps]',
199
type=int,
200
help=self._verbose('Packets-per-second to replay (default: ' +
201
'{G}%d pps{W})' % self.config.wep_pps))
202
wep.add_argument('-pps', help=argparse.SUPPRESS, action='store',
203
dest='wep_pps', type=int)
204
205
wep.add_argument('--wept',
206
action='store',
207
dest='wep_timeout',
208
metavar='[seconds]',
209
type=int,
210
help=self._verbose('Seconds to wait before failing (default: ' +
211
'{G}%d sec{W})' % self.config.wep_timeout))
212
wep.add_argument('-wept', help=argparse.SUPPRESS, action='store',
213
dest='wep_timeout', type=int)
214
215
wep.add_argument('--wepca',
216
action='store',
217
dest='wep_crack_at_ivs',
218
metavar='[ivs]',
219
type=int,
220
help=self._verbose('Start cracking at this many IVs (default: ' +
221
'{G}%d ivs{W})' % self.config.wep_crack_at_ivs))
222
wep.add_argument('-wepca', help=argparse.SUPPRESS, action='store',
223
dest='wep_crack_at_ivs', type=int)
224
225
wep.add_argument('--weprs',
226
action='store',
227
dest='wep_restart_stale_ivs',
228
metavar='[seconds]',
229
type=int,
230
help=self._verbose('Restart aireplay if no new IVs appear (default: ' +
231
'{G}%d sec{W})' % self.config.wep_restart_stale_ivs))
232
wep.add_argument('-weprs', help=argparse.SUPPRESS, action='store',
233
dest='wep_restart_stale_ivs', type=int)
234
235
wep.add_argument('--weprc',
236
action='store',
237
dest='wep_restart_aircrack',
238
metavar='[seconds]',
239
type=int,
240
help=self._verbose('Restart aircrack after this delay (default: ' +
241
'{G}%d sec{W})' % self.config.wep_restart_aircrack))
242
wep.add_argument('-weprc', help=argparse.SUPPRESS, action='store',
243
dest='wep_restart_aircrack', type=int)
244
245
wep.add_argument('--arpreplay',
246
action='store_true',
247
dest='wep_attack_replay',
248
help=self._verbose('Use {C}ARP-replay{W} WEP attack (default: {G}on{W})'))
249
wep.add_argument('-arpreplay', help=argparse.SUPPRESS, action='store_true',
250
dest='wep_attack_replay')
251
252
wep.add_argument('--fragment',
253
action='store_true',
254
dest='wep_attack_fragment',
255
help=self._verbose('Use {C}fragmentation{W} WEP attack (default: {G}on{W})'))
256
wep.add_argument('-fragment', help=argparse.SUPPRESS, action='store_true',
257
dest='wep_attack_fragment')
258
259
wep.add_argument('--chopchop',
260
action='store_true',
261
dest='wep_attack_chopchop',
262
help=self._verbose('Use {C}chop-chop{W} WEP attack (default: {G}on{W})'))
263
wep.add_argument('-chopchop', help=argparse.SUPPRESS, action='store_true',
264
dest='wep_attack_chopchop')
265
266
wep.add_argument('--caffelatte',
267
action='store_true',
268
dest='wep_attack_caffe',
269
help=self._verbose('Use {C}caffe-latte{W} WEP attack (default: {G}on{W})'))
270
wep.add_argument('-caffelatte', help=argparse.SUPPRESS, action='store_true',
271
dest='wep_attack_caffelatte')
272
273
wep.add_argument('--p0841',
274
action='store_true',
275
dest='wep_attack_p0841',
276
help=self._verbose('Use {C}p0841{W} WEP attack (default: {G}on{W})'))
277
wep.add_argument('-p0841', help=argparse.SUPPRESS, action='store_true',
278
dest='wep_attack_p0841')
279
280
wep.add_argument('--hirte',
281
action='store_true',
282
dest='wep_attack_hirte',
283
help=self._verbose('Use {C}hirte{W} WEP attack (default: {G}on{W})'))
284
wep.add_argument('-hirte', help=argparse.SUPPRESS, action='store_true',
285
dest='wep_attack_hirte')
286
287
288
def _add_wpa_args(self, wpa):
289
wpa.add_argument('--wpa',
290
action='store_true',
291
dest='wpa_filter',
292
help=Color.s('Show only {C}WPA-encrypted networks{W} (includes {C}WPS{W})'))
293
wpa.add_argument('-wpa', help=argparse.SUPPRESS, action='store_true',
294
dest='wpa_filter')
295
296
wpa.add_argument('--hs-dir',
297
action='store',
298
dest='wpa_handshake_dir',
299
metavar='[dir]',
300
type=str,
301
help=self._verbose('Directory to store handshake files ' +
302
'(default: {G}%s{W})' % self.config.wpa_handshake_dir))
303
wpa.add_argument('-hs-dir', help=argparse.SUPPRESS, action='store',
304
dest='wpa_handshake_dir', type=str)
305
306
wpa.add_argument('--new-hs',
307
action='store_true',
308
dest='ignore_old_handshakes',
309
help=Color.s('Captures new handshakes, ignores existing handshakes ' +
310
'in {C}%s{W} (default: {G}off{W})' % self.config.wpa_handshake_dir))
311
312
wpa.add_argument('--dict',
313
action='store',
314
dest='wordlist',
315
metavar='[file]',
316
type=str,
317
help=Color.s('File containing passwords for cracking (default: {G}%s{W})')
318
% self.config.wordlist)
319
320
wpa.add_argument('--wpadt',
321
action='store',
322
dest='wpa_deauth_timeout',
323
metavar='[seconds]',
324
type=int,
325
help=self._verbose('Time to wait between sending Deauths ' +
326
'(default: {G}%d sec{W})' % self.config.wpa_deauth_timeout))
327
wpa.add_argument('-wpadt', help=argparse.SUPPRESS, action='store',
328
dest='wpa_deauth_timeout', type=int)
329
330
wpa.add_argument('--wpat',
331
action='store',
332
dest='wpa_attack_timeout',
333
metavar='[seconds]',
334
type=int,
335
help=self._verbose('Time to wait before failing WPA attack ' +
336
'(default: {G}%d sec{W})' % self.config.wpa_attack_timeout))
337
wpa.add_argument('-wpat', help=argparse.SUPPRESS, action='store',
338
dest='wpa_attack_timeout', type=int)
339
340
# TODO: Uncomment the --strip option once it works
341
'''
342
wpa.add_argument('--strip',
343
action='store_true',
344
dest='wpa_strip_handshake',
345
default=False,
346
help=Color.s('Strip unnecessary packets from handshake capture using tshark'))
347
'''
348
wpa.add_argument('-strip', help=argparse.SUPPRESS, action='store_true',
349
dest='wpa_strip_handshake')
350
351
352
def _add_wps_args(self, wps):
353
wps.add_argument('--wps',
354
action='store_true',
355
dest='wps_filter',
356
help=Color.s('Show only {C}WPS-enabled networks{W}'))
357
wps.add_argument('-wps', help=argparse.SUPPRESS, action='store_true',
358
dest='wps_filter')
359
360
wps.add_argument('--no-wps',
361
action='store_true',
362
dest='no_wps',
363
help=self._verbose('{O}Never{W} use {O}WPS PIN{W} & {O}Pixie-Dust{W}' +
364
'attacks on targets (default: {G}off{W})'))
365
366
wps.add_argument('--wps-only',
367
action='store_true',
368
dest='wps_only',
369
help=Color.s('{O}Only{W} use {C}WPS PIN{W} & {C}Pixie-Dust{W} ' +
370
'attacks (default: {G}off{W})'))
371
372
wps.add_argument('--pixie', action='store_true', dest='wps_pixie',
373
help=self._verbose('{O}Only{W} use {C}WPS Pixie-Dust{W} attack ' +
374
'(do not use {O}PIN attack{W})'))
375
376
wps.add_argument('--no-pixie', action='store_true', dest='wps_no_pixie',
377
help=self._verbose('{O}Never{W} use {O}WPS Pixie-Dust{W} attack ' +
378
'(use {G}PIN attack{W})'))
379
380
wps.add_argument('--bully',
381
action='store_true',
382
dest='use_bully',
383
help=Color.s('Use {G}bully{W} program for WPS PIN & Pixie-Dust attacks ' +
384
'(default: {G}reaver{W})'))
385
# Alias
386
wps.add_argument('-bully', help=argparse.SUPPRESS, action='store_true',
387
dest='use_bully')
388
389
# Ignore lock-outs
390
wps.add_argument('--ignore-locks', action='store_true', dest='wps_ignore_lock',
391
help=Color.s('Do {O}not{W} stop WPS PIN attack if AP becomes {O}locked{W} ' +
392
' (default: {G}stop{W})'))
393
394
# Time limit on entire attack.
395
wps.add_argument('--wps-time',
396
action='store',
397
dest='wps_pixie_timeout',
398
metavar='[sec]',
399
type=int,
400
help=self._verbose('Total time to wait before failing PixieDust attack ' +
401
'(default: {G}%d sec{W})' % self.config.wps_pixie_timeout))
402
# Alias
403
wps.add_argument('-wpst', help=argparse.SUPPRESS, action='store',
404
dest='wps_pixie_timeout', type=int)
405
406
# Maximum number of 'failures' (WPSFail)
407
wps.add_argument('--wps-fails',
408
action='store',
409
dest='wps_fail_threshold',
410
metavar='[num]',
411
type=int,
412
help=self._verbose('Maximum number of WPSFail/NoAssoc errors before ' +
413
'failing (default: {G}%d{W})' % self.config.wps_fail_threshold))
414
# Alias
415
wps.add_argument('-wpsf', help=argparse.SUPPRESS, action='store',
416
dest='wps_fail_threshold', type=int)
417
418
# Maximum number of 'timeouts'
419
wps.add_argument('--wps-timeouts',
420
action='store',
421
dest='wps_timeout_threshold',
422
metavar='[num]',
423
type=int,
424
help=self._verbose('Maximum number of Timeouts before failing ' +
425
'(default: {G}%d{W})' % self.config.wps_timeout_threshold))
426
# Alias
427
wps.add_argument('-wpsto', help=argparse.SUPPRESS, action='store',
428
dest='wps_timeout_threshold', type=int)
429
430
def _add_pmkid_args(self, pmkid):
431
pmkid.add_argument('--pmkid',
432
action='store_true',
433
dest='use_pmkid_only',
434
help=Color.s('{O}Only{W} use {C}PMKID capture{W}, avoids other WPS & ' +
435
'WPA attacks (default: {G}off{W})'))
436
# Alias
437
pmkid.add_argument('-pmkid', help=argparse.SUPPRESS, action='store_true', dest='use_pmkid_only')
438
439
pmkid.add_argument('--pmkid-timeout',
440
action='store',
441
dest='pmkid_timeout',
442
metavar='[sec]',
443
type=int,
444
help=Color.s('Time to wait for PMKID capture ' +
445
'(default: {G}%d{W} seconds)' % self.config.pmkid_timeout))
446
447
def _add_command_args(self, commands):
448
commands.add_argument('--cracked',
449
action='store_true',
450
dest='cracked',
451
help=Color.s('Print previously-cracked access points'))
452
commands.add_argument('-cracked', help=argparse.SUPPRESS, action='store_true',
453
dest='cracked')
454
455
commands.add_argument('--check',
456
action='store',
457
metavar='file',
458
nargs='?',
459
const='<all>',
460
dest='check_handshake',
461
help=Color.s('Check a {C}.cap file{W} (or all {C}hs/*.cap{W} files) ' +
462
'for WPA handshakes'))
463
commands.add_argument('-check', help=argparse.SUPPRESS, action='store',
464
nargs='?', const='<all>', dest='check_handshake')
465
466
commands.add_argument('--crack',
467
action='store_true',
468
dest='crack_handshake',
469
help=Color.s('Show commands to crack a captured handshake'))
470
471
if __name__ == '__main__':
472
from .util.color import Color
473
from .config import Configuration
474
Configuration.initialize(False)
475
a = Arguments(Configuration)
476
args = a.args
477
for (key,value) in sorted(args.__dict__.items()):
478
Color.pl('{C}%s: {G}%s{W}' % (key.ljust(21),value))
479
480
481