This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
forked from hashcat/hashcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_options.c
3076 lines (2550 loc) · 101 KB
/
user_options.c
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
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "logfile.h"
#include "interface.h"
#include "shared.h"
#include "usage.h"
#include "backend.h"
#include "user_options.h"
#include "outfile.h"
#ifdef WITH_BRAIN
#include "brain.h"
#endif
#ifdef WITH_BRAIN
static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OSz";
#else
static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OS";
#endif
static const struct option long_options[] =
{
{"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE},
{"attack-mode", required_argument, NULL, IDX_ATTACK_MODE},
{"backend-devices", required_argument, NULL, IDX_BACKEND_DEVICES},
{"backend-ignore-cuda", no_argument, NULL, IDX_BACKEND_IGNORE_CUDA},
{"backend-ignore-opencl", no_argument, NULL, IDX_BACKEND_IGNORE_OPENCL},
{"backend-info", no_argument, NULL, IDX_BACKEND_INFO},
{"backend-vector-width", required_argument, NULL, IDX_BACKEND_VECTOR_WIDTH},
{"benchmark-all", no_argument, NULL, IDX_BENCHMARK_ALL},
{"benchmark", no_argument, NULL, IDX_BENCHMARK},
{"bitmap-max", required_argument, NULL, IDX_BITMAP_MAX},
{"bitmap-min", required_argument, NULL, IDX_BITMAP_MIN},
{"cpu-affinity", required_argument, NULL, IDX_CPU_AFFINITY},
{"custom-charset1", required_argument, NULL, IDX_CUSTOM_CHARSET_1},
{"custom-charset2", required_argument, NULL, IDX_CUSTOM_CHARSET_2},
{"custom-charset3", required_argument, NULL, IDX_CUSTOM_CHARSET_3},
{"custom-charset4", required_argument, NULL, IDX_CUSTOM_CHARSET_4},
{"debug-file", required_argument, NULL, IDX_DEBUG_FILE},
{"debug-mode", required_argument, NULL, IDX_DEBUG_MODE},
{"encoding-from", required_argument, NULL, IDX_ENCODING_FROM},
{"encoding-to", required_argument, NULL, IDX_ENCODING_TO},
{"example-hashes", no_argument, NULL, IDX_HASH_INFO}, // alias of hash-info
{"force", no_argument, NULL, IDX_FORCE},
{"generate-rules-func-max", required_argument, NULL, IDX_RP_GEN_FUNC_MAX},
{"generate-rules-func-min", required_argument, NULL, IDX_RP_GEN_FUNC_MIN},
{"generate-rules", required_argument, NULL, IDX_RP_GEN},
{"generate-rules-seed", required_argument, NULL, IDX_RP_GEN_SEED},
{"hwmon-disable", no_argument, NULL, IDX_HWMON_DISABLE},
{"hwmon-temp-abort", required_argument, NULL, IDX_HWMON_TEMP_ABORT},
{"hash-info", no_argument, NULL, IDX_HASH_INFO},
{"hash-type", required_argument, NULL, IDX_HASH_MODE},
{"hccapx-message-pair", required_argument, NULL, IDX_HCCAPX_MESSAGE_PAIR},
{"help", no_argument, NULL, IDX_HELP},
{"hex-charset", no_argument, NULL, IDX_HEX_CHARSET},
{"hex-salt", no_argument, NULL, IDX_HEX_SALT},
{"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST},
{"hook-threads", required_argument, NULL, IDX_HOOK_THREADS},
{"increment-max", required_argument, NULL, IDX_INCREMENT_MAX},
{"increment-min", required_argument, NULL, IDX_INCREMENT_MIN},
{"increment", no_argument, NULL, IDX_INCREMENT},
{"induction-dir", required_argument, NULL, IDX_INDUCTION_DIR},
{"keep-guessing", no_argument, NULL, IDX_KEEP_GUESSING},
{"kernel-accel", required_argument, NULL, IDX_KERNEL_ACCEL},
{"kernel-loops", required_argument, NULL, IDX_KERNEL_LOOPS},
{"kernel-threads", required_argument, NULL, IDX_KERNEL_THREADS},
{"keyboard-layout-mapping", required_argument, NULL, IDX_KEYBOARD_LAYOUT_MAPPING},
{"keyspace", no_argument, NULL, IDX_KEYSPACE},
{"left", no_argument, NULL, IDX_LEFT},
{"limit", required_argument, NULL, IDX_LIMIT},
{"logfile-disable", no_argument, NULL, IDX_LOGFILE_DISABLE},
{"loopback", no_argument, NULL, IDX_LOOPBACK},
{"machine-readable", no_argument, NULL, IDX_MACHINE_READABLE},
{"markov-classic", no_argument, NULL, IDX_MARKOV_CLASSIC},
{"markov-disable", no_argument, NULL, IDX_MARKOV_DISABLE},
{"markov-hcstat2", required_argument, NULL, IDX_MARKOV_HCSTAT2},
{"markov-threshold", required_argument, NULL, IDX_MARKOV_THRESHOLD},
{"nonce-error-corrections", required_argument, NULL, IDX_NONCE_ERROR_CORRECTIONS},
{"opencl-device-types", required_argument, NULL, IDX_OPENCL_DEVICE_TYPES},
{"optimized-kernel-enable", no_argument, NULL, IDX_OPTIMIZED_KERNEL_ENABLE},
{"outfile-autohex-disable", no_argument, NULL, IDX_OUTFILE_AUTOHEX_DISABLE},
{"outfile-check-dir", required_argument, NULL, IDX_OUTFILE_CHECK_DIR},
{"outfile-check-timer", required_argument, NULL, IDX_OUTFILE_CHECK_TIMER},
{"outfile-format", required_argument, NULL, IDX_OUTFILE_FORMAT},
{"outfile", required_argument, NULL, IDX_OUTFILE},
{"potfile-disable", no_argument, NULL, IDX_POTFILE_DISABLE},
{"potfile-path", required_argument, NULL, IDX_POTFILE_PATH},
{"progress-only", no_argument, NULL, IDX_PROGRESS_ONLY},
{"quiet", no_argument, NULL, IDX_QUIET},
{"remove", no_argument, NULL, IDX_REMOVE},
{"remove-timer", required_argument, NULL, IDX_REMOVE_TIMER},
{"restore-disable", no_argument, NULL, IDX_RESTORE_DISABLE},
{"restore-file-path", required_argument, NULL, IDX_RESTORE_FILE_PATH},
{"restore", no_argument, NULL, IDX_RESTORE},
{"rule-left", required_argument, NULL, IDX_RULE_BUF_L},
{"rule-right", required_argument, NULL, IDX_RULE_BUF_R},
{"rules-file", required_argument, NULL, IDX_RP_FILE},
{"runtime", required_argument, NULL, IDX_RUNTIME},
{"scrypt-tmto", required_argument, NULL, IDX_SCRYPT_TMTO},
{"segment-size", required_argument, NULL, IDX_SEGMENT_SIZE},
{"self-test-disable", no_argument, NULL, IDX_SELF_TEST_DISABLE},
{"separator", required_argument, NULL, IDX_SEPARATOR},
{"seperator", required_argument, NULL, IDX_SEPARATOR},
{"session", required_argument, NULL, IDX_SESSION},
{"show", no_argument, NULL, IDX_SHOW},
{"skip", required_argument, NULL, IDX_SKIP},
{"slow-candidates", no_argument, NULL, IDX_SLOW_CANDIDATES},
{"speed-only", no_argument, NULL, IDX_SPEED_ONLY},
{"spin-damp", required_argument, NULL, IDX_SPIN_DAMP},
{"status", no_argument, NULL, IDX_STATUS},
{"status-json", no_argument, NULL, IDX_STATUS_JSON},
{"status-timer", required_argument, NULL, IDX_STATUS_TIMER},
{"stdout", no_argument, NULL, IDX_STDOUT_FLAG},
{"stdin-timeout-abort", required_argument, NULL, IDX_STDIN_TIMEOUT_ABORT},
{"truecrypt-keyfiles", required_argument, NULL, IDX_TRUECRYPT_KEYFILES},
{"username", no_argument, NULL, IDX_USERNAME},
{"veracrypt-keyfiles", required_argument, NULL, IDX_VERACRYPT_KEYFILES},
{"veracrypt-pim-start", required_argument, NULL, IDX_VERACRYPT_PIM_START},
{"veracrypt-pim-stop", required_argument, NULL, IDX_VERACRYPT_PIM_STOP},
{"version", no_argument, NULL, IDX_VERSION},
{"wordlist-autohex-disable", no_argument, NULL, IDX_WORDLIST_AUTOHEX_DISABLE},
{"workload-profile", required_argument, NULL, IDX_WORKLOAD_PROFILE},
#ifdef WITH_BRAIN
{"brain-client", no_argument, NULL, IDX_BRAIN_CLIENT},
{"brain-client-features", required_argument, NULL, IDX_BRAIN_CLIENT_FEATURES},
{"brain-server", no_argument, NULL, IDX_BRAIN_SERVER},
{"brain-server-timer", required_argument, NULL, IDX_BRAIN_SERVER_TIMER},
{"brain-host", required_argument, NULL, IDX_BRAIN_HOST},
{"brain-port", required_argument, NULL, IDX_BRAIN_PORT},
{"brain-password", required_argument, NULL, IDX_BRAIN_PASSWORD},
{"brain-session", required_argument, NULL, IDX_BRAIN_SESSION},
{"brain-session-whitelist", required_argument, NULL, IDX_BRAIN_SESSION_WHITELIST},
#endif
{NULL, 0, NULL, 0 }
};
static const char *ENCODING_FROM = "utf-8";
static const char *ENCODING_TO = "utf-8";
static const char *RULE_BUF_R = ":";
static const char *RULE_BUF_L = ":";
static const char *DEF_MASK_CS_1 = "?l?d?u";
static const char *DEF_MASK_CS_2 = "?l?d";
static const char *DEF_MASK_CS_3 = "?l?d*!$@_";
int user_options_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options->advice_disable = ADVICE_DISABLE;
user_options->attack_mode = ATTACK_MODE;
user_options->backend_devices = NULL;
user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA;
user_options->backend_ignore_opencl = BACKEND_IGNORE_OPENCL;
user_options->backend_info = BACKEND_INFO;
user_options->backend_vector_width = BACKEND_VECTOR_WIDTH;
user_options->benchmark_all = BENCHMARK_ALL;
user_options->benchmark = BENCHMARK;
user_options->bitmap_max = BITMAP_MAX;
user_options->bitmap_min = BITMAP_MIN;
#ifdef WITH_BRAIN
user_options->brain_client = BRAIN_CLIENT;
user_options->brain_client_features = BRAIN_CLIENT_FEATURES;
user_options->brain_host = NULL;
user_options->brain_port = BRAIN_PORT;
user_options->brain_server = BRAIN_SERVER;
user_options->brain_server_timer = BRAIN_SERVER_TIMER;
user_options->brain_session = BRAIN_SESSION;
user_options->brain_session_whitelist = NULL;
#endif
user_options->cpu_affinity = NULL;
user_options->custom_charset_1 = NULL;
user_options->custom_charset_2 = NULL;
user_options->custom_charset_3 = NULL;
user_options->custom_charset_4 = NULL;
user_options->debug_file = NULL;
user_options->debug_mode = DEBUG_MODE;
user_options->encoding_from = ENCODING_FROM;
user_options->encoding_to = ENCODING_TO;
user_options->force = FORCE;
user_options->hwmon_disable = HWMON_DISABLE;
user_options->hwmon_temp_abort = HWMON_TEMP_ABORT;
user_options->hash_info = HASH_INFO;
user_options->hash_mode = HASH_MODE;
user_options->hccapx_message_pair = HCCAPX_MESSAGE_PAIR;
user_options->hex_charset = HEX_CHARSET;
user_options->hex_salt = HEX_SALT;
user_options->hex_wordlist = HEX_WORDLIST;
user_options->hook_threads = HOOK_THREADS;
user_options->increment = INCREMENT;
user_options->increment_max = INCREMENT_MAX;
user_options->increment_min = INCREMENT_MIN;
user_options->induction_dir = NULL;
user_options->keep_guessing = KEEP_GUESSING;
user_options->kernel_accel = KERNEL_ACCEL;
user_options->kernel_loops = KERNEL_LOOPS;
user_options->kernel_threads = KERNEL_THREADS;
user_options->keyboard_layout_mapping = NULL;
user_options->keyspace = KEYSPACE;
user_options->left = LEFT;
user_options->limit = LIMIT;
user_options->logfile_disable = LOGFILE_DISABLE;
user_options->loopback = LOOPBACK;
user_options->machine_readable = MACHINE_READABLE;
user_options->markov_classic = MARKOV_CLASSIC;
user_options->markov_disable = MARKOV_DISABLE;
user_options->markov_hcstat2 = NULL;
user_options->markov_threshold = MARKOV_THRESHOLD;
user_options->nonce_error_corrections = NONCE_ERROR_CORRECTIONS;
user_options->opencl_device_types = NULL;
user_options->optimized_kernel_enable = OPTIMIZED_KERNEL_ENABLE;
user_options->outfile_autohex = OUTFILE_AUTOHEX;
user_options->outfile_check_dir = NULL;
user_options->outfile_check_timer = OUTFILE_CHECK_TIMER;
user_options->outfile_format = OUTFILE_FORMAT;
user_options->outfile = NULL;
user_options->potfile_disable = POTFILE_DISABLE;
user_options->potfile_path = NULL;
user_options->progress_only = PROGRESS_ONLY;
user_options->quiet = QUIET;
user_options->remove = REMOVE;
user_options->remove_timer = REMOVE_TIMER;
user_options->restore_disable = RESTORE_DISABLE;
user_options->restore_file_path = NULL;
user_options->restore = RESTORE;
user_options->restore_timer = RESTORE_TIMER;
user_options->rp_gen_func_max = RP_GEN_FUNC_MAX;
user_options->rp_gen_func_min = RP_GEN_FUNC_MIN;
user_options->rp_gen = RP_GEN;
user_options->rp_gen_seed = RP_GEN_SEED;
user_options->rule_buf_l = RULE_BUF_L;
user_options->rule_buf_r = RULE_BUF_R;
user_options->runtime = RUNTIME;
user_options->scrypt_tmto = SCRYPT_TMTO;
user_options->segment_size = SEGMENT_SIZE;
user_options->self_test_disable = SELF_TEST_DISABLE;
user_options->separator = SEPARATOR;
user_options->session = PROGNAME;
user_options->show = SHOW;
user_options->skip = SKIP;
user_options->slow_candidates = SLOW_CANDIDATES;
user_options->speed_only = SPEED_ONLY;
user_options->spin_damp = SPIN_DAMP;
user_options->status = STATUS;
user_options->status_json = STATUS_JSON;
user_options->status_timer = STATUS_TIMER;
user_options->stdin_timeout_abort = STDIN_TIMEOUT_ABORT;
user_options->stdout_flag = STDOUT_FLAG;
user_options->truecrypt_keyfiles = NULL;
user_options->usage = USAGE;
user_options->username = USERNAME;
user_options->veracrypt_keyfiles = NULL;
user_options->veracrypt_pim_start = VERACRYPT_PIM_START;
user_options->veracrypt_pim_stop = VERACRYPT_PIM_STOP;
user_options->version = VERSION;
user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE;
user_options->workload_profile = WORKLOAD_PROFILE;
user_options->rp_files_cnt = 0;
user_options->rp_files = (char **) hccalloc (256, sizeof (char *));
user_options->hc_bin = PROGNAME;
user_options->hc_argc = 0;
user_options->hc_argv = NULL;
return 0;
}
void user_options_destroy (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
hcfree (user_options->rp_files);
//do not reset this, it might be used from main.c
//memset (user_options, 0, sizeof (user_options_t));
}
int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
{
user_options_t *user_options = hashcat_ctx->user_options;
int c = -1;
int option_index;
optind = 1;
optopt = 0;
option_index = 0;
while ((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1)
{
switch (c)
{
case IDX_REMOVE_TIMER:
case IDX_DEBUG_MODE:
case IDX_SKIP:
case IDX_LIMIT:
case IDX_STATUS_TIMER:
case IDX_HASH_MODE:
case IDX_RUNTIME:
case IDX_ATTACK_MODE:
case IDX_RP_GEN:
case IDX_RP_GEN_FUNC_MIN:
case IDX_RP_GEN_FUNC_MAX:
case IDX_RP_GEN_SEED:
case IDX_MARKOV_THRESHOLD:
case IDX_OUTFILE_CHECK_TIMER:
case IDX_BACKEND_VECTOR_WIDTH:
case IDX_WORKLOAD_PROFILE:
case IDX_KERNEL_ACCEL:
case IDX_KERNEL_LOOPS:
case IDX_KERNEL_THREADS:
case IDX_SPIN_DAMP:
case IDX_HWMON_TEMP_ABORT:
case IDX_HCCAPX_MESSAGE_PAIR:
case IDX_NONCE_ERROR_CORRECTIONS:
case IDX_VERACRYPT_PIM_START:
case IDX_VERACRYPT_PIM_STOP:
case IDX_SEGMENT_SIZE:
case IDX_SCRYPT_TMTO:
case IDX_BITMAP_MIN:
case IDX_BITMAP_MAX:
case IDX_INCREMENT_MIN:
case IDX_INCREMENT_MAX:
case IDX_HOOK_THREADS:
#ifdef WITH_BRAIN
case IDX_BRAIN_PORT:
#endif
if (hc_string_is_digit (optarg) == false)
{
event_log_error (hashcat_ctx, "The specified parameter cannot use '%s' as a value - must be a number.", optarg);
return -1;
}
break;
case '?':
{
event_log_error (hashcat_ctx, "Invalid argument specified.");
return -1;
}
}
}
optind = 1;
optopt = 0;
option_index = 0;
while ((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1)
{
switch (c)
{
case IDX_HELP: user_options->usage = true; break;
case IDX_VERSION: user_options->version = true; break;
case IDX_RESTORE: user_options->restore = true; break;
case IDX_QUIET: user_options->quiet = true; break;
case IDX_SHOW: user_options->show = true; break;
case IDX_LEFT: user_options->left = true; break;
case IDX_ADVICE_DISABLE: user_options->advice_disable = true; break;
case IDX_USERNAME: user_options->username = true; break;
case IDX_REMOVE: user_options->remove = true; break;
case IDX_REMOVE_TIMER: user_options->remove_timer = hc_strtoul (optarg, NULL, 10);
user_options->remove_timer_chgd = true; break;
case IDX_POTFILE_DISABLE: user_options->potfile_disable = true; break;
case IDX_POTFILE_PATH: user_options->potfile_path = optarg; break;
case IDX_DEBUG_MODE: user_options->debug_mode = hc_strtoul (optarg, NULL, 10); break;
case IDX_DEBUG_FILE: user_options->debug_file = optarg; break;
case IDX_ENCODING_FROM: user_options->encoding_from = optarg; break;
case IDX_ENCODING_TO: user_options->encoding_to = optarg; break;
case IDX_INDUCTION_DIR: user_options->induction_dir = optarg; break;
case IDX_OUTFILE_CHECK_DIR: user_options->outfile_check_dir = optarg; break;
case IDX_HASH_INFO: user_options->hash_info = true; break;
case IDX_FORCE: user_options->force = true; break;
case IDX_SELF_TEST_DISABLE: user_options->self_test_disable = true; break;
case IDX_SKIP: user_options->skip = hc_strtoull (optarg, NULL, 10);
user_options->skip_chgd = true; break;
case IDX_LIMIT: user_options->limit = hc_strtoull (optarg, NULL, 10);
user_options->limit_chgd = true; break;
case IDX_KEEP_GUESSING: user_options->keep_guessing = true; break;
case IDX_KEYSPACE: user_options->keyspace = true; break;
case IDX_BENCHMARK: user_options->benchmark = true; break;
case IDX_BENCHMARK_ALL: user_options->benchmark_all = true; break;
case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break;
case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10);
user_options->stdin_timeout_abort_chgd = true; break;
case IDX_SPEED_ONLY: user_options->speed_only = true; break;
case IDX_PROGRESS_ONLY: user_options->progress_only = true; break;
case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break;
case IDX_RESTORE_FILE_PATH: user_options->restore_file_path = optarg; break;
case IDX_STATUS: user_options->status = true; break;
case IDX_STATUS_JSON: user_options->status_json = true; break;
case IDX_STATUS_TIMER: user_options->status_timer = hc_strtoul (optarg, NULL, 10); break;
case IDX_MACHINE_READABLE: user_options->machine_readable = true; break;
case IDX_LOOPBACK: user_options->loopback = true; break;
case IDX_SESSION: user_options->session = optarg; break;
case IDX_HASH_MODE: user_options->hash_mode = hc_strtoul (optarg, NULL, 10);
user_options->hash_mode_chgd = true; break;
case IDX_RUNTIME: user_options->runtime = hc_strtoul (optarg, NULL, 10);
user_options->runtime_chgd = true; break;
case IDX_ATTACK_MODE: user_options->attack_mode = hc_strtoul (optarg, NULL, 10);
user_options->attack_mode_chgd = true; break;
case IDX_RP_FILE: user_options->rp_files[user_options->rp_files_cnt++] = optarg; break;
case IDX_RP_GEN: user_options->rp_gen = hc_strtoul (optarg, NULL, 10); break;
case IDX_RP_GEN_FUNC_MIN: user_options->rp_gen_func_min = hc_strtoul (optarg, NULL, 10); break;
case IDX_RP_GEN_FUNC_MAX: user_options->rp_gen_func_max = hc_strtoul (optarg, NULL, 10); break;
case IDX_RP_GEN_SEED: user_options->rp_gen_seed = hc_strtoul (optarg, NULL, 10);
user_options->rp_gen_seed_chgd = true; break;
case IDX_RULE_BUF_L: user_options->rule_buf_l = optarg; break;
case IDX_RULE_BUF_R: user_options->rule_buf_r = optarg; break;
case IDX_MARKOV_DISABLE: user_options->markov_disable = true; break;
case IDX_MARKOV_CLASSIC: user_options->markov_classic = true; break;
case IDX_MARKOV_THRESHOLD: user_options->markov_threshold = hc_strtoul (optarg, NULL, 10); break;
case IDX_MARKOV_HCSTAT2: user_options->markov_hcstat2 = optarg; break;
case IDX_OUTFILE: user_options->outfile = optarg; break;
case IDX_OUTFILE_FORMAT: user_options->outfile_format = outfile_format_parse (optarg);
user_options->outfile_format_chgd = true; break;
case IDX_OUTFILE_AUTOHEX_DISABLE: user_options->outfile_autohex = false; break;
case IDX_OUTFILE_CHECK_TIMER: user_options->outfile_check_timer = hc_strtoul (optarg, NULL, 10); break;
case IDX_WORDLIST_AUTOHEX_DISABLE: user_options->wordlist_autohex_disable = true; break;
case IDX_HEX_CHARSET: user_options->hex_charset = true; break;
case IDX_HEX_SALT: user_options->hex_salt = true; break;
case IDX_HEX_WORDLIST: user_options->hex_wordlist = true; break;
case IDX_CPU_AFFINITY: user_options->cpu_affinity = optarg; break;
case IDX_BACKEND_IGNORE_CUDA: user_options->backend_ignore_cuda = true; break;
case IDX_BACKEND_IGNORE_OPENCL: user_options->backend_ignore_opencl = true; break;
case IDX_BACKEND_INFO: user_options->backend_info = true; break;
case IDX_BACKEND_DEVICES: user_options->backend_devices = optarg; break;
case IDX_BACKEND_VECTOR_WIDTH: user_options->backend_vector_width = hc_strtoul (optarg, NULL, 10);
user_options->backend_vector_width_chgd = true; break;
case IDX_OPENCL_DEVICE_TYPES: user_options->opencl_device_types = optarg; break;
case IDX_OPTIMIZED_KERNEL_ENABLE: user_options->optimized_kernel_enable = true; break;
case IDX_WORKLOAD_PROFILE: user_options->workload_profile = hc_strtoul (optarg, NULL, 10);
user_options->workload_profile_chgd = true; break;
case IDX_KERNEL_ACCEL: user_options->kernel_accel = hc_strtoul (optarg, NULL, 10);
user_options->kernel_accel_chgd = true; break;
case IDX_KERNEL_LOOPS: user_options->kernel_loops = hc_strtoul (optarg, NULL, 10);
user_options->kernel_loops_chgd = true; break;
case IDX_KERNEL_THREADS: user_options->kernel_threads = hc_strtoul (optarg, NULL, 10);
user_options->kernel_threads_chgd = true; break;
case IDX_SPIN_DAMP: user_options->spin_damp = hc_strtoul (optarg, NULL, 10);
user_options->spin_damp_chgd = true; break;
case IDX_HWMON_DISABLE: user_options->hwmon_disable = true; break;
case IDX_HWMON_TEMP_ABORT: user_options->hwmon_temp_abort = hc_strtoul (optarg, NULL, 10); break;
case IDX_LOGFILE_DISABLE: user_options->logfile_disable = true; break;
case IDX_HCCAPX_MESSAGE_PAIR: user_options->hccapx_message_pair = hc_strtoul (optarg, NULL, 10);
user_options->hccapx_message_pair_chgd = true; break;
case IDX_NONCE_ERROR_CORRECTIONS: user_options->nonce_error_corrections = hc_strtoul (optarg, NULL, 10);
user_options->nonce_error_corrections_chgd = true; break;
case IDX_KEYBOARD_LAYOUT_MAPPING: user_options->keyboard_layout_mapping = optarg; break;
case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break;
case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break;
case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10);
user_options->veracrypt_pim_start_chgd = true; break;
case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10);
user_options->veracrypt_pim_stop_chgd = true; break;
case IDX_SEGMENT_SIZE: user_options->segment_size = hc_strtoul (optarg, NULL, 10);
user_options->segment_size_chgd = true; break;
case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10);
user_options->scrypt_tmto_chgd = true; break;
case IDX_SEPARATOR: user_options->separator = optarg[0]; break;
case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break;
case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break;
case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break;
case IDX_INCREMENT: user_options->increment = true; break;
case IDX_INCREMENT_MIN: user_options->increment_min = hc_strtoul (optarg, NULL, 10);
user_options->increment_min_chgd = true; break;
case IDX_INCREMENT_MAX: user_options->increment_max = hc_strtoul (optarg, NULL, 10);
user_options->increment_max_chgd = true; break;
case IDX_CUSTOM_CHARSET_1: user_options->custom_charset_1 = optarg; break;
case IDX_CUSTOM_CHARSET_2: user_options->custom_charset_2 = optarg; break;
case IDX_CUSTOM_CHARSET_3: user_options->custom_charset_3 = optarg; break;
case IDX_CUSTOM_CHARSET_4: user_options->custom_charset_4 = optarg; break;
case IDX_SLOW_CANDIDATES: user_options->slow_candidates = true; break;
#ifdef WITH_BRAIN
case IDX_BRAIN_CLIENT: user_options->brain_client = true; break;
case IDX_BRAIN_CLIENT_FEATURES: user_options->brain_client_features = hc_strtoul (optarg, NULL, 10); break;
case IDX_BRAIN_SERVER: user_options->brain_server = true; break;
case IDX_BRAIN_SERVER_TIMER: user_options->brain_server_timer = hc_strtoul (optarg, NULL, 10);
user_options->brain_server_timer_chgd = true; break;
case IDX_BRAIN_PASSWORD: user_options->brain_password = optarg;
user_options->brain_password_chgd = true; break;
case IDX_BRAIN_HOST: user_options->brain_host = optarg;
user_options->brain_host_chgd = true; break;
case IDX_BRAIN_PORT: user_options->brain_port = hc_strtoul (optarg, NULL, 10);
user_options->brain_port_chgd = true; break;
case IDX_BRAIN_SESSION: user_options->brain_session = hc_strtoul (optarg, NULL, 16); break;
case IDX_BRAIN_SESSION_WHITELIST: user_options->brain_session_whitelist = optarg; break;
#endif
}
}
user_options->hc_bin = argv[0];
user_options->hc_argc = argc - optind;
user_options->hc_argv = argv + optind;
return 0;
}
int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->hc_argc < 0)
{
event_log_error (hashcat_ctx, "hc_argc %d is invalid.", user_options->hc_argc);
return -1;
}
if (user_options->hc_argv == NULL)
{
event_log_error (hashcat_ctx, "hc_argv is NULL.");
return -1;
}
#ifdef WITH_BRAIN
if ((user_options->brain_client == true) && (user_options->brain_server == true))
{
event_log_error (hashcat_ctx, "Can not have --brain-client and --brain-server at the same time");
return -1;
}
if ((user_options->brain_client_features < 1) || (user_options->brain_client_features > 3))
{
event_log_error (hashcat_ctx, "Invalid --brain-client-feature argument");
return -1;
}
if ((user_options->brain_client == true) && (user_options->brain_password_chgd == false))
{
event_log_error (hashcat_ctx, "Brain clients need to set --brain-password");
return -1;
}
if (user_options->brain_server_timer_chgd)
{
if (user_options->brain_server == false)
{
event_log_error (hashcat_ctx, "The --brain-server-timer flag requires --brain-server.");
return -1;
}
if (user_options->brain_server_timer != 0) // special case (no intermediate dumps)
{
if (user_options->brain_server_timer < 60)
{
event_log_error (hashcat_ctx, "Brain server backup timer must be at least 60 seconds.");
return -1;
}
}
}
#endif
if (user_options->slow_candidates == true)
{
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
&& (user_options->attack_mode != ATTACK_MODE_BF))
{
event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified in slow-candidates mode.");
return -1;
}
}
#ifdef WITH_BRAIN
else if (user_options->brain_client == true)
{
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
&& (user_options->attack_mode != ATTACK_MODE_BF))
{
event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified in brain-client mode.");
return -1;
}
}
#endif
else
{
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
&& (user_options->attack_mode != ATTACK_MODE_BF)
&& (user_options->attack_mode != ATTACK_MODE_HYBRID1)
&& (user_options->attack_mode != ATTACK_MODE_HYBRID2)
&& (user_options->attack_mode != ATTACK_MODE_ASSOCIATION)
&& (user_options->attack_mode != ATTACK_MODE_NONE))
{
event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified.");
return -1;
}
}
if (user_options->hccapx_message_pair_chgd == true)
{
if (user_options->remove == true)
{
event_log_error (hashcat_ctx, "Combining --remove with --hccapx-message-pair is not allowed.");
return -1;
}
if (user_options->hccapx_message_pair >= 6)
{
event_log_error (hashcat_ctx, "Invalid --hccapx-message-pair value specified.");
return -1;
}
}
/*
if (user_options->skip_chgd == true && user_options->skip == 0)
{
event_log_error (hashcat_ctx, "Invalid --skip value specified.");
return -1;
}
*/
if (user_options->limit_chgd == true && user_options->limit == 0)
{
event_log_error (hashcat_ctx, "Invalid --limit value specified.");
return -1;
}
if (user_options->runtime_chgd == true && user_options->runtime == 0)
{
event_log_error (hashcat_ctx, "Invalid --runtime value specified.");
return -1;
}
if (user_options->runtime_chgd == true && user_options->loopback == true)
{
event_log_error (hashcat_ctx, "Combining --limit with --loopback is not allowed.");
return -1;
}
if (user_options->hash_mode >= MODULE_HASH_MODES_MAXIMUM)
{
event_log_error (hashcat_ctx, "Invalid -m (hash type) value specified.");
return -1;
}
if (user_options->outfile_format == 0)
{
event_log_error (hashcat_ctx, "Invalid --outfile-format value specified.");
return -1;
}
if (user_options->left == true)
{
if (user_options->outfile_format_chgd == true)
{
if (user_options->outfile_format > 1)
{
event_log_error (hashcat_ctx, "Combining --outfile-format > 1 with --left is not allowed.");
return -1;
}
}
}
if (user_options->show == true)
{
if (user_options->outfile_format_chgd == true)
{
if (user_options->outfile_format & OUTFILE_FMT_CRACKPOS)
{
event_log_error (hashcat_ctx, "Using crack_pos in --outfile-format for --show is not allowed.");
return -1;
}
if (user_options->outfile_format & OUTFILE_FMT_TIME_ABS)
{
event_log_error (hashcat_ctx, "Using the absolute timestamp in --outfile-format for --show is not allowed.");
return -1;
}
if (user_options->outfile_format & OUTFILE_FMT_TIME_REL)
{
event_log_error (hashcat_ctx, "Using the relative timestamp in --outfile-format for --show is not allowed.");
return -1;
}
}
}
if (user_options->increment_min < INCREMENT_MIN)
{
event_log_error (hashcat_ctx, "Invalid --increment-min value specified.");
return -1;
}
if (user_options->increment_max > INCREMENT_MAX)
{
event_log_error (hashcat_ctx, "Invalid --increment-max value specified.");
return -1;
}
if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == false))
{
event_log_error (hashcat_ctx, "If --veracrypt-pim-start is specified then --veracrypt-pim-stop needs to be specified, too.");
return -1;
}
if ((user_options->veracrypt_pim_start_chgd == false) && (user_options->veracrypt_pim_stop_chgd == true))
{
event_log_error (hashcat_ctx, "If --veracrypt-pim-stop is specified then --veracrypt-pim-start needs to be specified, too.");
return -1;
}
if (user_options->veracrypt_pim_start > user_options->veracrypt_pim_stop)
{
event_log_error (hashcat_ctx, "Invalid --veracrypt-pim-start value specified.");
return -1;
}
if (user_options->increment_min > user_options->increment_max)
{
event_log_error (hashcat_ctx, "Invalid --increment-min value specified - must be >= --increment-max.");
return -1;
}
if ((user_options->increment == true) && (user_options->progress_only == true))
{
event_log_error (hashcat_ctx, "Increment is not allowed in combination with --progress-only.");
return -1;
}
if ((user_options->increment == true) && (user_options->speed_only == true))
{
event_log_error (hashcat_ctx, "Increment is not allowed in combination with --speed-only.");
return -1;
}
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
{
event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 0 (straight).");
return -1;
}
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 9 (association).");
return -1;
}
if ((user_options->remove == true) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
event_log_error (hashcat_ctx, "Remove is not allowed in attack mode 9 (association).");
return -1;
}
if ((user_options->increment == false) && (user_options->increment_min_chgd == true))
{
event_log_error (hashcat_ctx, "Increment-min is only supported when combined with -i/--increment.");
return -1;
}
if ((user_options->increment == false) && (user_options->increment_max_chgd == true))
{
event_log_error (hashcat_ctx, "Increment-max is only supported combined with -i/--increment.");
return -1;
}
if ((user_options->rp_files_cnt > 0) && (user_options->rp_gen > 0))
{
event_log_error (hashcat_ctx, "Combining -r/--rules-file and -g/--rules-generate is not supported.");
return -1;
}
if ((user_options->rp_files_cnt > 0) || (user_options->rp_gen > 0))
{
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION))
{
event_log_error (hashcat_ctx, "Use of -r/--rules-file and -g/--rules-generate only allowed in attack mode 0 or 9.");
return -1;
}
}
if (user_options->bitmap_min > user_options->bitmap_max)
{
event_log_error (hashcat_ctx, "Invalid --bitmap-min value specified.");
return -1;
}
if (user_options->rp_gen_func_min > user_options->rp_gen_func_max)
{
event_log_error (hashcat_ctx, "Invalid --rp-gen-func-min value specified.");
return -1;
}
if (user_options->kernel_accel_chgd == true)
{
if (user_options->force == false)
{
event_log_error (hashcat_ctx, "The manual use of the -n option (or --kernel-accel) is outdated.");
event_log_warning (hashcat_ctx, "Please consider using the -w option instead.");
event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
event_log_warning (hashcat_ctx, NULL);
return -1;
}
if (user_options->kernel_accel < 1)
{
event_log_error (hashcat_ctx, "Invalid --kernel-accel value specified - must be greater than 0.");
return -1;
}
if (user_options->kernel_accel > 1024)
{
event_log_error (hashcat_ctx, "Invalid --kernel-accel value specified - must be <= 1024.");
return -1;
}
}
if (user_options->kernel_loops_chgd == true)
{
if (user_options->force == false)
{
event_log_error (hashcat_ctx, "The manual use of the -u option (or --kernel-loops) is outdated.");
event_log_warning (hashcat_ctx, "Please consider using the -w option instead.");
event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
event_log_warning (hashcat_ctx, NULL);
return -1;
}
if (user_options->kernel_loops < 1)
{
event_log_error (hashcat_ctx, "Invalid kernel-loops specified.");
return -1;
}
if (user_options->kernel_loops > 1024)
{
event_log_error (hashcat_ctx, "Invalid kernel-loops specified.");
return -1;
}
}
if (user_options->kernel_threads_chgd == true)
{
if (user_options->force == false)
{
event_log_error (hashcat_ctx, "The manual use of the -T option (or --kernel-threads) is outdated.");
event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
event_log_warning (hashcat_ctx, NULL);
return -1;
}
if (user_options->kernel_threads < 1)
{
event_log_error (hashcat_ctx, "Invalid kernel-threads specified.");
return -1;
}
if (user_options->kernel_threads > 1024)
{
event_log_error (hashcat_ctx, "Invalid kernel-threads specified.");
return -1;
}
}
if ((user_options->workload_profile < 1) || (user_options->workload_profile > 4))
{
event_log_error (hashcat_ctx, "workload-profile %u is not available.", user_options->workload_profile);
return -1;
}
if (user_options->backend_vector_width_chgd == true)
{
if (is_power_of_2 (user_options->backend_vector_width) == false || user_options->backend_vector_width > 16)
{
event_log_error (hashcat_ctx, "backend-vector-width %u is not allowed.", user_options->backend_vector_width);
return -1;
}
}
if (user_options->show == true || user_options->left == true)
{
if (user_options->remove == true)
{
event_log_error (hashcat_ctx, "Mixing --remove not allowed with --show or --left.");
return -1;
}
if (user_options->potfile_disable == true)
{
event_log_error (hashcat_ctx, "Mixing --potfile-disable is not allowed with --show or --left.");
return -1;
}
}
if (user_options->show == true)
{
if (user_options->outfile_autohex == false)
{
event_log_error (hashcat_ctx, "Mixing --outfile-autohex-disable is not allowed with --show.");
return -1;
}
}
if (user_options->keyspace == true)
{
if (user_options->show == true)
{
event_log_error (hashcat_ctx, "Combining --show with --keyspace is not allowed.");
return -1;
}
if (user_options->left == true)
{
event_log_error (hashcat_ctx, "Combining --left with --keyspace is not allowed.");
return -1;
}
}
if (user_options->machine_readable == true)
{
if (user_options->status_json == true)
{
event_log_error (hashcat_ctx, "The --status-json flag can not be used with --machine-readable.");
return -1;
}
}
if (user_options->remove_timer_chgd == true)
{
if (user_options->remove == false)
{
event_log_error (hashcat_ctx, "The --remove-timer flag requires --remove.");
return -1;
}
if (user_options->remove_timer < 1)
{