"Fossies" - the Fresh Open Source Software Archive

Member "hashcat-6.2.6/src/user_options.c" (2 Sep 2022, 108355 Bytes) of package /linux/privat/hashcat-6.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "user_options.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.2.5_vs_6.2.6.

    1 /**
    2  * Author......: See docs/credits.txt
    3  * License.....: MIT
    4  */
    5 
    6 #include "common.h"
    7 #include "types.h"
    8 #include "memory.h"
    9 #include "event.h"
   10 #include "convert.h"
   11 #include "logfile.h"
   12 #include "interface.h"
   13 #include "shared.h"
   14 #include "usage.h"
   15 #include "backend.h"
   16 #include "user_options.h"
   17 #include "outfile.h"
   18 
   19 #ifdef WITH_BRAIN
   20 #include "brain.h"
   21 #endif
   22 
   23 #ifdef WITH_BRAIN
   24 static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSz";
   25 #else
   26 static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS";
   27 #endif
   28 
   29 static char *const SEPARATOR = ":";
   30 
   31 static const struct option long_options[] =
   32 {
   33   {"advice-disable",            no_argument,       NULL, IDX_ADVICE_DISABLE},
   34   {"attack-mode",               required_argument, NULL, IDX_ATTACK_MODE},
   35   {"backend-devices",           required_argument, NULL, IDX_BACKEND_DEVICES},
   36   {"backend-ignore-cuda",       no_argument,       NULL, IDX_BACKEND_IGNORE_CUDA},
   37   {"backend-ignore-hip",        no_argument,       NULL, IDX_BACKEND_IGNORE_HIP},
   38   #if defined (__APPLE__)
   39   {"backend-ignore-metal",      no_argument,       NULL, IDX_BACKEND_IGNORE_METAL},
   40   #endif
   41   {"backend-ignore-opencl",     no_argument,       NULL, IDX_BACKEND_IGNORE_OPENCL},
   42   {"backend-info",              no_argument,       NULL, IDX_BACKEND_INFO},
   43   {"backend-vector-width",      required_argument, NULL, IDX_BACKEND_VECTOR_WIDTH},
   44   {"benchmark-all",             no_argument,       NULL, IDX_BENCHMARK_ALL},
   45   {"benchmark",                 no_argument,       NULL, IDX_BENCHMARK},
   46   {"bitmap-max",                required_argument, NULL, IDX_BITMAP_MAX},
   47   {"bitmap-min",                required_argument, NULL, IDX_BITMAP_MIN},
   48   {"cpu-affinity",              required_argument, NULL, IDX_CPU_AFFINITY},
   49   {"custom-charset1",           required_argument, NULL, IDX_CUSTOM_CHARSET_1},
   50   {"custom-charset2",           required_argument, NULL, IDX_CUSTOM_CHARSET_2},
   51   {"custom-charset3",           required_argument, NULL, IDX_CUSTOM_CHARSET_3},
   52   {"custom-charset4",           required_argument, NULL, IDX_CUSTOM_CHARSET_4},
   53   {"debug-file",                required_argument, NULL, IDX_DEBUG_FILE},
   54   {"debug-mode",                required_argument, NULL, IDX_DEBUG_MODE},
   55   {"deprecated-check-disable",  no_argument,       NULL, IDX_DEPRECATED_CHECK_DISABLE},
   56   {"encoding-from",             required_argument, NULL, IDX_ENCODING_FROM},
   57   {"encoding-to",               required_argument, NULL, IDX_ENCODING_TO},
   58   {"example-hashes",            no_argument,       NULL, IDX_HASH_INFO}, // alias of hash-info
   59   {"force",                     no_argument,       NULL, IDX_FORCE},
   60   {"generate-rules-func-max",   required_argument, NULL, IDX_RP_GEN_FUNC_MAX},
   61   {"generate-rules-func-min",   required_argument, NULL, IDX_RP_GEN_FUNC_MIN},
   62   {"generate-rules-func-sel",   required_argument, NULL, IDX_RP_GEN_FUNC_SEL},
   63   {"generate-rules",            required_argument, NULL, IDX_RP_GEN},
   64   {"generate-rules-seed",       required_argument, NULL, IDX_RP_GEN_SEED},
   65   {"hwmon-disable",             no_argument,       NULL, IDX_HWMON_DISABLE},
   66   {"hwmon-temp-abort",          required_argument, NULL, IDX_HWMON_TEMP_ABORT},
   67   {"hash-info",                 no_argument,       NULL, IDX_HASH_INFO},
   68   {"hash-type",                 required_argument, NULL, IDX_HASH_MODE},
   69   {"hccapx-message-pair",       required_argument, NULL, IDX_HCCAPX_MESSAGE_PAIR},
   70   {"help",                      no_argument,       NULL, IDX_HELP},
   71   {"hex-charset",               no_argument,       NULL, IDX_HEX_CHARSET},
   72   {"hex-salt",                  no_argument,       NULL, IDX_HEX_SALT},
   73   {"hex-wordlist",              no_argument,       NULL, IDX_HEX_WORDLIST},
   74   {"hook-threads",              required_argument, NULL, IDX_HOOK_THREADS},
   75   {"identify",                  no_argument,       NULL, IDX_IDENTIFY},
   76   {"increment-max",             required_argument, NULL, IDX_INCREMENT_MAX},
   77   {"increment-min",             required_argument, NULL, IDX_INCREMENT_MIN},
   78   {"increment",                 no_argument,       NULL, IDX_INCREMENT},
   79   {"induction-dir",             required_argument, NULL, IDX_INDUCTION_DIR},
   80   {"keep-guessing",             no_argument,       NULL, IDX_KEEP_GUESSING},
   81   {"kernel-accel",              required_argument, NULL, IDX_KERNEL_ACCEL},
   82   {"kernel-loops",              required_argument, NULL, IDX_KERNEL_LOOPS},
   83   {"kernel-threads",            required_argument, NULL, IDX_KERNEL_THREADS},
   84   {"keyboard-layout-mapping",   required_argument, NULL, IDX_KEYBOARD_LAYOUT_MAPPING},
   85   {"keyspace",                  no_argument,       NULL, IDX_KEYSPACE},
   86   {"left",                      no_argument,       NULL, IDX_LEFT},
   87   {"limit",                     required_argument, NULL, IDX_LIMIT},
   88   {"logfile-disable",           no_argument,       NULL, IDX_LOGFILE_DISABLE},
   89   {"loopback",                  no_argument,       NULL, IDX_LOOPBACK},
   90   {"machine-readable",          no_argument,       NULL, IDX_MACHINE_READABLE},
   91   {"markov-classic",            no_argument,       NULL, IDX_MARKOV_CLASSIC},
   92   {"markov-disable",            no_argument,       NULL, IDX_MARKOV_DISABLE},
   93   {"markov-hcstat2",            required_argument, NULL, IDX_MARKOV_HCSTAT2},
   94   {"markov-inverse",            no_argument,       NULL, IDX_MARKOV_INVERSE},
   95   {"markov-threshold",          required_argument, NULL, IDX_MARKOV_THRESHOLD},
   96   {"nonce-error-corrections",   required_argument, NULL, IDX_NONCE_ERROR_CORRECTIONS},
   97   {"opencl-device-types",       required_argument, NULL, IDX_OPENCL_DEVICE_TYPES},
   98   {"optimized-kernel-enable",   no_argument,       NULL, IDX_OPTIMIZED_KERNEL_ENABLE},
   99   {"multiply-accel-disable",    no_argument,       NULL, IDX_MULTIPLY_ACCEL_DISABLE},
  100   {"outfile-autohex-disable",   no_argument,       NULL, IDX_OUTFILE_AUTOHEX_DISABLE},
  101   {"outfile-check-dir",         required_argument, NULL, IDX_OUTFILE_CHECK_DIR},
  102   {"outfile-check-timer",       required_argument, NULL, IDX_OUTFILE_CHECK_TIMER},
  103   {"outfile-format",            required_argument, NULL, IDX_OUTFILE_FORMAT},
  104   {"outfile",                   required_argument, NULL, IDX_OUTFILE},
  105   {"potfile-disable",           no_argument,       NULL, IDX_POTFILE_DISABLE},
  106   {"potfile-path",              required_argument, NULL, IDX_POTFILE_PATH},
  107   {"progress-only",             no_argument,       NULL, IDX_PROGRESS_ONLY},
  108   {"quiet",                     no_argument,       NULL, IDX_QUIET},
  109   {"remove",                    no_argument,       NULL, IDX_REMOVE},
  110   {"remove-timer",              required_argument, NULL, IDX_REMOVE_TIMER},
  111   {"restore-disable",           no_argument,       NULL, IDX_RESTORE_DISABLE},
  112   {"restore-file-path",         required_argument, NULL, IDX_RESTORE_FILE_PATH},
  113   {"restore",                   no_argument,       NULL, IDX_RESTORE},
  114   {"rule-left",                 required_argument, NULL, IDX_RULE_BUF_L},
  115   {"rule-right",                required_argument, NULL, IDX_RULE_BUF_R},
  116   {"rules-file",                required_argument, NULL, IDX_RP_FILE},
  117   {"runtime",                   required_argument, NULL, IDX_RUNTIME},
  118   {"scrypt-tmto",               required_argument, NULL, IDX_SCRYPT_TMTO},
  119   {"segment-size",              required_argument, NULL, IDX_SEGMENT_SIZE},
  120   {"self-test-disable",         no_argument,       NULL, IDX_SELF_TEST_DISABLE},
  121   {"separator",                 required_argument, NULL, IDX_SEPARATOR},
  122   {"seperator",                 required_argument, NULL, IDX_SEPARATOR},
  123   {"session",                   required_argument, NULL, IDX_SESSION},
  124   {"show",                      no_argument,       NULL, IDX_SHOW},
  125   {"skip",                      required_argument, NULL, IDX_SKIP},
  126   {"slow-candidates",           no_argument,       NULL, IDX_SLOW_CANDIDATES},
  127   {"speed-only",                no_argument,       NULL, IDX_SPEED_ONLY},
  128   {"spin-damp",                 required_argument, NULL, IDX_SPIN_DAMP},
  129   {"status",                    no_argument,       NULL, IDX_STATUS},
  130   {"status-json",               no_argument,       NULL, IDX_STATUS_JSON},
  131   {"status-timer",              required_argument, NULL, IDX_STATUS_TIMER},
  132   {"stdout",                    no_argument,       NULL, IDX_STDOUT_FLAG},
  133   {"stdin-timeout-abort",       required_argument, NULL, IDX_STDIN_TIMEOUT_ABORT},
  134   {"truecrypt-keyfiles",        required_argument, NULL, IDX_TRUECRYPT_KEYFILES},
  135   {"username",                  no_argument,       NULL, IDX_USERNAME},
  136   {"veracrypt-keyfiles",        required_argument, NULL, IDX_VERACRYPT_KEYFILES},
  137   {"veracrypt-pim-start",       required_argument, NULL, IDX_VERACRYPT_PIM_START},
  138   {"veracrypt-pim-stop",        required_argument, NULL, IDX_VERACRYPT_PIM_STOP},
  139   {"version",                   no_argument,       NULL, IDX_VERSION},
  140   {"wordlist-autohex-disable",  no_argument,       NULL, IDX_WORDLIST_AUTOHEX_DISABLE},
  141   {"workload-profile",          required_argument, NULL, IDX_WORKLOAD_PROFILE},
  142   #ifdef WITH_BRAIN
  143   {"brain-client",              no_argument,       NULL, IDX_BRAIN_CLIENT},
  144   {"brain-client-features",     required_argument, NULL, IDX_BRAIN_CLIENT_FEATURES},
  145   {"brain-server",              no_argument,       NULL, IDX_BRAIN_SERVER},
  146   {"brain-server-timer",        required_argument, NULL, IDX_BRAIN_SERVER_TIMER},
  147   {"brain-host",                required_argument, NULL, IDX_BRAIN_HOST},
  148   {"brain-port",                required_argument, NULL, IDX_BRAIN_PORT},
  149   {"brain-password",            required_argument, NULL, IDX_BRAIN_PASSWORD},
  150   {"brain-session",             required_argument, NULL, IDX_BRAIN_SESSION},
  151   {"brain-session-whitelist",   required_argument, NULL, IDX_BRAIN_SESSION_WHITELIST},
  152   #endif
  153   {NULL,                        0,                 NULL, 0 }
  154 };
  155 
  156 static const char *const ENCODING_FROM = "utf-8";
  157 static const char *const ENCODING_TO   = "utf-8";
  158 
  159 static const char *const RULE_BUF_R = ":";
  160 static const char *const RULE_BUF_L = ":";
  161 
  162 static const char *const DEF_MASK_CS_1 = "?l?d?u";
  163 static const char *const DEF_MASK_CS_2 = "?l?d";
  164 static const char *const DEF_MASK_CS_3 = "?l?d*!$@_";
  165 
  166 int user_options_init (hashcat_ctx_t *hashcat_ctx)
  167 {
  168   user_options_t *user_options = hashcat_ctx->user_options;
  169 
  170   user_options->advice_disable            = ADVICE_DISABLE;
  171   user_options->attack_mode               = ATTACK_MODE;
  172   user_options->autodetect                = AUTODETECT;
  173   user_options->backend_devices           = NULL;
  174   user_options->backend_ignore_cuda       = BACKEND_IGNORE_CUDA;
  175   user_options->backend_ignore_hip        = BACKEND_IGNORE_HIP;
  176   #if defined (__APPLE__)
  177   user_options->backend_ignore_metal      = BACKEND_IGNORE_METAL;
  178   #endif
  179   user_options->backend_ignore_opencl     = BACKEND_IGNORE_OPENCL;
  180   user_options->backend_info              = BACKEND_INFO;
  181   user_options->backend_vector_width      = BACKEND_VECTOR_WIDTH;
  182   user_options->benchmark_all             = BENCHMARK_ALL;
  183   user_options->benchmark                 = BENCHMARK;
  184   user_options->bitmap_max                = BITMAP_MAX;
  185   user_options->bitmap_min                = BITMAP_MIN;
  186   #ifdef WITH_BRAIN
  187   user_options->brain_client              = BRAIN_CLIENT;
  188   user_options->brain_client_features     = BRAIN_CLIENT_FEATURES;
  189   user_options->brain_host                = NULL;
  190   user_options->brain_port                = BRAIN_PORT;
  191   user_options->brain_server              = BRAIN_SERVER;
  192   user_options->brain_server_timer        = BRAIN_SERVER_TIMER;
  193   user_options->brain_session             = BRAIN_SESSION;
  194   user_options->brain_session_whitelist   = NULL;
  195   #endif
  196   user_options->cpu_affinity              = NULL;
  197   user_options->custom_charset_1          = NULL;
  198   user_options->custom_charset_2          = NULL;
  199   user_options->custom_charset_3          = NULL;
  200   user_options->custom_charset_4          = NULL;
  201   user_options->debug_file                = NULL;
  202   user_options->debug_mode                = DEBUG_MODE;
  203   user_options->deprecated_check_disable  = DEPRECATED_CHECK_DISABLE;
  204   user_options->encoding_from             = ENCODING_FROM;
  205   user_options->encoding_to               = ENCODING_TO;
  206   user_options->force                     = FORCE;
  207   user_options->hwmon_disable             = HWMON_DISABLE;
  208   user_options->hwmon_temp_abort          = HWMON_TEMP_ABORT;
  209   user_options->hash_info                 = HASH_INFO;
  210   user_options->hash_mode                 = HASH_MODE;
  211   user_options->hccapx_message_pair       = HCCAPX_MESSAGE_PAIR;
  212   user_options->hex_charset               = HEX_CHARSET;
  213   user_options->hex_salt                  = HEX_SALT;
  214   user_options->hex_wordlist              = HEX_WORDLIST;
  215   user_options->hook_threads              = HOOK_THREADS;
  216   user_options->identify                  = IDENTIFY;
  217   user_options->increment                 = INCREMENT;
  218   user_options->increment_max             = INCREMENT_MAX;
  219   user_options->increment_min             = INCREMENT_MIN;
  220   user_options->induction_dir             = NULL;
  221   user_options->keep_guessing             = KEEP_GUESSING;
  222   user_options->kernel_accel              = KERNEL_ACCEL;
  223   user_options->kernel_loops              = KERNEL_LOOPS;
  224   user_options->kernel_threads            = KERNEL_THREADS;
  225   user_options->keyboard_layout_mapping   = NULL;
  226   user_options->keyspace                  = KEYSPACE;
  227   user_options->left                      = LEFT;
  228   user_options->limit                     = LIMIT;
  229   user_options->logfile_disable           = LOGFILE_DISABLE;
  230   user_options->loopback                  = LOOPBACK;
  231   user_options->machine_readable          = MACHINE_READABLE;
  232   user_options->markov_classic            = MARKOV_CLASSIC;
  233   user_options->markov_disable            = MARKOV_DISABLE;
  234   user_options->markov_hcstat2            = NULL;
  235   user_options->markov_inverse            = MARKOV_INVERSE;
  236   user_options->markov_threshold          = MARKOV_THRESHOLD;
  237   user_options->nonce_error_corrections   = NONCE_ERROR_CORRECTIONS;
  238   user_options->opencl_device_types       = NULL;
  239   user_options->optimized_kernel_enable   = OPTIMIZED_KERNEL_ENABLE;
  240   user_options->multiply_accel_disable    = MULTIPLY_ACCEL_DISABLE;
  241   user_options->outfile_autohex           = OUTFILE_AUTOHEX;
  242   user_options->outfile_check_dir         = NULL;
  243   user_options->outfile_check_timer       = OUTFILE_CHECK_TIMER;
  244   user_options->outfile_format            = OUTFILE_FORMAT;
  245   user_options->outfile                   = NULL;
  246   user_options->potfile_disable           = POTFILE_DISABLE;
  247   user_options->potfile_path              = NULL;
  248   user_options->progress_only             = PROGRESS_ONLY;
  249   user_options->quiet                     = QUIET;
  250   user_options->remove                    = REMOVE;
  251   user_options->remove_timer              = REMOVE_TIMER;
  252   user_options->restore_disable           = RESTORE_DISABLE;
  253   user_options->restore_file_path         = NULL;
  254   user_options->restore                   = RESTORE;
  255   user_options->restore_timer             = RESTORE_TIMER;
  256   user_options->rp_gen_func_max           = RP_GEN_FUNC_MAX;
  257   user_options->rp_gen_func_min           = RP_GEN_FUNC_MIN;
  258   user_options->rp_gen_func_sel           = NULL;
  259   user_options->rp_gen                    = RP_GEN;
  260   user_options->rp_gen_seed               = RP_GEN_SEED;
  261   user_options->rule_buf_l                = RULE_BUF_L;
  262   user_options->rule_buf_r                = RULE_BUF_R;
  263   user_options->runtime                   = RUNTIME;
  264   user_options->scrypt_tmto               = SCRYPT_TMTO;
  265   user_options->segment_size              = SEGMENT_SIZE;
  266   user_options->self_test_disable         = SELF_TEST_DISABLE;
  267   user_options->separator                 = SEPARATOR;
  268   user_options->session                   = PROGNAME;
  269   user_options->show                      = SHOW;
  270   user_options->skip                      = SKIP;
  271   user_options->slow_candidates           = SLOW_CANDIDATES;
  272   user_options->speed_only                = SPEED_ONLY;
  273   user_options->spin_damp                 = SPIN_DAMP;
  274   user_options->status                    = STATUS;
  275   user_options->status_json               = STATUS_JSON;
  276   user_options->status_timer              = STATUS_TIMER;
  277   user_options->stdin_timeout_abort       = STDIN_TIMEOUT_ABORT;
  278   user_options->stdout_flag               = STDOUT_FLAG;
  279   user_options->truecrypt_keyfiles        = NULL;
  280   user_options->usage                     = USAGE;
  281   user_options->username                  = USERNAME;
  282   user_options->veracrypt_keyfiles        = NULL;
  283   user_options->veracrypt_pim_start       = VERACRYPT_PIM_START;
  284   user_options->veracrypt_pim_stop        = VERACRYPT_PIM_STOP;
  285   user_options->version                   = VERSION;
  286   user_options->wordlist_autohex_disable  = WORDLIST_AUTOHEX_DISABLE;
  287   user_options->workload_profile          = WORKLOAD_PROFILE;
  288   user_options->rp_files_cnt              = 0;
  289   user_options->rp_files                  = (char **) hccalloc (256, sizeof (char *));
  290   user_options->hc_bin                    = PROGNAME;
  291   user_options->hc_argc                   = 0;
  292   user_options->hc_argv                   = NULL;
  293 
  294   return 0;
  295 }
  296 
  297 void user_options_destroy (hashcat_ctx_t *hashcat_ctx)
  298 {
  299   user_options_t *user_options = hashcat_ctx->user_options;
  300 
  301   hcfree (user_options->rp_files);
  302 
  303   //do not reset this, it might be used from main.c
  304   //memset (user_options, 0, sizeof (user_options_t));
  305 }
  306 
  307 int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
  308 {
  309   user_options_t *user_options = hashcat_ctx->user_options;
  310 
  311   int c = -1;
  312 
  313   int option_index;
  314 
  315   optind = 1;
  316   optopt = 0;
  317 
  318   option_index = 0;
  319 
  320   while ((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1)
  321   {
  322     switch (c)
  323     {
  324       case IDX_REMOVE_TIMER:
  325       case IDX_DEBUG_MODE:
  326       case IDX_SKIP:
  327       case IDX_LIMIT:
  328       case IDX_STATUS_TIMER:
  329       case IDX_HASH_MODE:
  330       case IDX_RUNTIME:
  331       case IDX_ATTACK_MODE:
  332       case IDX_RP_GEN:
  333       case IDX_RP_GEN_FUNC_MIN:
  334       case IDX_RP_GEN_FUNC_MAX:
  335       case IDX_RP_GEN_SEED:
  336       case IDX_MARKOV_THRESHOLD:
  337       case IDX_OUTFILE_CHECK_TIMER:
  338       case IDX_BACKEND_VECTOR_WIDTH:
  339       case IDX_WORKLOAD_PROFILE:
  340       case IDX_KERNEL_ACCEL:
  341       case IDX_KERNEL_LOOPS:
  342       case IDX_KERNEL_THREADS:
  343       case IDX_SPIN_DAMP:
  344       case IDX_HWMON_TEMP_ABORT:
  345       case IDX_HCCAPX_MESSAGE_PAIR:
  346       case IDX_NONCE_ERROR_CORRECTIONS:
  347       case IDX_VERACRYPT_PIM_START:
  348       case IDX_VERACRYPT_PIM_STOP:
  349       case IDX_SEGMENT_SIZE:
  350       case IDX_SCRYPT_TMTO:
  351       case IDX_BITMAP_MIN:
  352       case IDX_BITMAP_MAX:
  353       case IDX_INCREMENT_MIN:
  354       case IDX_INCREMENT_MAX:
  355       case IDX_HOOK_THREADS:
  356       #ifdef WITH_BRAIN
  357       case IDX_BRAIN_PORT:
  358       #endif
  359 
  360       if (hc_string_is_digit (optarg) == false)
  361       {
  362         event_log_error (hashcat_ctx, "The specified parameter cannot use '%s' as a value - must be a number.", optarg);
  363 
  364         return -1;
  365       }
  366 
  367       break;
  368 
  369       case '?':
  370       {
  371         event_log_error (hashcat_ctx, "Invalid argument specified.");
  372 
  373         return -1;
  374       }
  375     }
  376   }
  377 
  378   optind = 1;
  379   optopt = 0;
  380 
  381   option_index = 0;
  382 
  383   while ((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1)
  384   {
  385     switch (c)
  386     {
  387       case IDX_HELP:                      user_options->usage                     = true;                            break;
  388       case IDX_VERSION:                   user_options->version                   = true;                            break;
  389       case IDX_RESTORE:                   user_options->restore                   = true;                            break;
  390       case IDX_QUIET:                     user_options->quiet                     = true;                            break;
  391       case IDX_SHOW:                      user_options->show                      = true;                            break;
  392       case IDX_DEPRECATED_CHECK_DISABLE:  user_options->deprecated_check_disable  = true;                            break;
  393       case IDX_LEFT:                      user_options->left                      = true;                            break;
  394       case IDX_ADVICE_DISABLE:            user_options->advice_disable            = true;                            break;
  395       case IDX_USERNAME:                  user_options->username                  = true;                            break;
  396       case IDX_REMOVE:                    user_options->remove                    = true;                            break;
  397       case IDX_REMOVE_TIMER:              user_options->remove_timer              = hc_strtoul (optarg, NULL, 10);
  398                                           user_options->remove_timer_chgd         = true;                            break;
  399       case IDX_POTFILE_DISABLE:           user_options->potfile_disable           = true;                            break;
  400       case IDX_POTFILE_PATH:              user_options->potfile_path              = optarg;                          break;
  401       case IDX_DEBUG_MODE:                user_options->debug_mode                = hc_strtoul (optarg, NULL, 10);   break;
  402       case IDX_DEBUG_FILE:                user_options->debug_file                = optarg;                          break;
  403       case IDX_ENCODING_FROM:             user_options->encoding_from             = optarg;                          break;
  404       case IDX_ENCODING_TO:               user_options->encoding_to               = optarg;                          break;
  405       case IDX_INDUCTION_DIR:             user_options->induction_dir             = optarg;                          break;
  406       case IDX_OUTFILE_CHECK_DIR:         user_options->outfile_check_dir         = optarg;                          break;
  407       case IDX_HASH_INFO:                 user_options->hash_info                 = true;                            break;
  408       case IDX_FORCE:                     user_options->force                     = true;                            break;
  409       case IDX_SELF_TEST_DISABLE:         user_options->self_test_disable         = true;                            break;
  410       case IDX_SKIP:                      user_options->skip                      = hc_strtoull (optarg, NULL, 10);
  411                                           user_options->skip_chgd                 = true;                            break;
  412       case IDX_LIMIT:                     user_options->limit                     = hc_strtoull (optarg, NULL, 10);
  413                                           user_options->limit_chgd                = true;                            break;
  414       case IDX_KEEP_GUESSING:             user_options->keep_guessing             = true;                            break;
  415       case IDX_KEYSPACE:                  user_options->keyspace                  = true;                            break;
  416       case IDX_BENCHMARK:                 user_options->benchmark                 = true;                            break;
  417       case IDX_BENCHMARK_ALL:             user_options->benchmark_all             = true;                            break;
  418       case IDX_STDOUT_FLAG:               user_options->stdout_flag               = true;                            break;
  419       case IDX_STDIN_TIMEOUT_ABORT:       user_options->stdin_timeout_abort       = hc_strtoul (optarg, NULL, 10);
  420                                           user_options->stdin_timeout_abort_chgd  = true;                            break;
  421       case IDX_IDENTIFY:                  user_options->identify                  = true;                            break;
  422       case IDX_SPEED_ONLY:                user_options->speed_only                = true;                            break;
  423       case IDX_PROGRESS_ONLY:             user_options->progress_only             = true;                            break;
  424       case IDX_RESTORE_DISABLE:           user_options->restore_disable           = true;                            break;
  425       case IDX_RESTORE_FILE_PATH:         user_options->restore_file_path         = optarg;                          break;
  426       case IDX_STATUS:                    user_options->status                    = true;                            break;
  427       case IDX_STATUS_JSON:               user_options->status_json               = true;                            break;
  428       case IDX_STATUS_TIMER:              user_options->status_timer              = hc_strtoul (optarg, NULL, 10);   break;
  429       case IDX_MACHINE_READABLE:          user_options->machine_readable          = true;                            break;
  430       case IDX_LOOPBACK:                  user_options->loopback                  = true;                            break;
  431       case IDX_SESSION:                   user_options->session                   = optarg;                          break;
  432       case IDX_HASH_MODE:                 user_options->hash_mode                 = hc_strtoul (optarg, NULL, 10);
  433                                           user_options->hash_mode_chgd            = true;                            break;
  434       case IDX_RUNTIME:                   user_options->runtime                   = hc_strtoul (optarg, NULL, 10);
  435                                           user_options->runtime_chgd              = true;                            break;
  436       case IDX_ATTACK_MODE:               user_options->attack_mode               = hc_strtoul (optarg, NULL, 10);
  437                                           user_options->attack_mode_chgd          = true;                            break;
  438       case IDX_RP_FILE:                   user_options->rp_files[user_options->rp_files_cnt++] = optarg;             break;
  439       case IDX_RP_GEN:                    user_options->rp_gen                    = hc_strtoul (optarg, NULL, 10);   break;
  440       case IDX_RP_GEN_FUNC_MIN:           user_options->rp_gen_func_min           = hc_strtoul (optarg, NULL, 10);   break;
  441       case IDX_RP_GEN_FUNC_MAX:           user_options->rp_gen_func_max           = hc_strtoul (optarg, NULL, 10);   break;
  442       case IDX_RP_GEN_FUNC_SEL:           user_options->rp_gen_func_sel           = optarg;                          break;
  443       case IDX_RP_GEN_SEED:               user_options->rp_gen_seed               = hc_strtoul (optarg, NULL, 10);
  444                                           user_options->rp_gen_seed_chgd          = true;                            break;
  445       case IDX_RULE_BUF_L:                user_options->rule_buf_l                = optarg;                          break;
  446       case IDX_RULE_BUF_R:                user_options->rule_buf_r                = optarg;                          break;
  447       case IDX_MARKOV_DISABLE:            user_options->markov_disable            = true;                            break;
  448       case IDX_MARKOV_CLASSIC:            user_options->markov_classic            = true;                            break;
  449       case IDX_MARKOV_INVERSE:            user_options->markov_inverse            = true;                            break;
  450       case IDX_MARKOV_THRESHOLD:          user_options->markov_threshold          = hc_strtoul (optarg, NULL, 10);   break;
  451       case IDX_MARKOV_HCSTAT2:            user_options->markov_hcstat2            = optarg;                          break;
  452       case IDX_OUTFILE:                   user_options->outfile                   = optarg;                          break;
  453       case IDX_OUTFILE_FORMAT:            user_options->outfile_format            = outfile_format_parse (optarg);
  454                                           user_options->outfile_format_chgd       = true;                            break;
  455       case IDX_OUTFILE_AUTOHEX_DISABLE:   user_options->outfile_autohex           = false;                           break;
  456       case IDX_OUTFILE_CHECK_TIMER:       user_options->outfile_check_timer       = hc_strtoul (optarg, NULL, 10);   break;
  457       case IDX_WORDLIST_AUTOHEX_DISABLE:  user_options->wordlist_autohex_disable  = true;                            break;
  458       case IDX_HEX_CHARSET:               user_options->hex_charset               = true;                            break;
  459       case IDX_HEX_SALT:                  user_options->hex_salt                  = true;                            break;
  460       case IDX_HEX_WORDLIST:              user_options->hex_wordlist              = true;                            break;
  461       case IDX_CPU_AFFINITY:              user_options->cpu_affinity              = optarg;                          break;
  462       case IDX_BACKEND_IGNORE_CUDA:       user_options->backend_ignore_cuda       = true;                            break;
  463       case IDX_BACKEND_IGNORE_HIP:        user_options->backend_ignore_hip        = true;                            break;
  464       #if defined (__APPLE__)
  465       case IDX_BACKEND_IGNORE_METAL:      user_options->backend_ignore_metal      = true;                            break;
  466       #endif
  467       case IDX_BACKEND_IGNORE_OPENCL:     user_options->backend_ignore_opencl     = true;                            break;
  468       case IDX_BACKEND_INFO:              user_options->backend_info++;                                              break;
  469       case IDX_BACKEND_DEVICES:           user_options->backend_devices           = optarg;                          break;
  470       case IDX_BACKEND_VECTOR_WIDTH:      user_options->backend_vector_width      = hc_strtoul (optarg, NULL, 10);
  471                                           user_options->backend_vector_width_chgd = true;                            break;
  472       case IDX_OPENCL_DEVICE_TYPES:       user_options->opencl_device_types       = optarg;                          break;
  473       case IDX_OPTIMIZED_KERNEL_ENABLE:   user_options->optimized_kernel_enable   = true;                            break;
  474       case IDX_MULTIPLY_ACCEL_DISABLE:    user_options->multiply_accel_disable    = true;                            break;
  475       case IDX_WORKLOAD_PROFILE:          user_options->workload_profile          = hc_strtoul (optarg, NULL, 10);
  476                                           user_options->workload_profile_chgd     = true;                            break;
  477       case IDX_KERNEL_ACCEL:              user_options->kernel_accel              = hc_strtoul (optarg, NULL, 10);
  478                                           user_options->kernel_accel_chgd         = true;                            break;
  479       case IDX_KERNEL_LOOPS:              user_options->kernel_loops              = hc_strtoul (optarg, NULL, 10);
  480                                           user_options->kernel_loops_chgd         = true;                            break;
  481       case IDX_KERNEL_THREADS:            user_options->kernel_threads            = hc_strtoul (optarg, NULL, 10);
  482                                           user_options->kernel_threads_chgd       = true;                            break;
  483       case IDX_SPIN_DAMP:                 user_options->spin_damp                 = hc_strtoul (optarg, NULL, 10);
  484                                           user_options->spin_damp_chgd            = true;                            break;
  485       case IDX_HWMON_DISABLE:             user_options->hwmon_disable             = true;                            break;
  486       case IDX_HWMON_TEMP_ABORT:          user_options->hwmon_temp_abort          = hc_strtoul (optarg, NULL, 10);   break;
  487       case IDX_LOGFILE_DISABLE:           user_options->logfile_disable           = true;                            break;
  488       case IDX_HCCAPX_MESSAGE_PAIR:       user_options->hccapx_message_pair       = hc_strtoul (optarg, NULL, 10);
  489                                           user_options->hccapx_message_pair_chgd  = true;                            break;
  490       case IDX_NONCE_ERROR_CORRECTIONS:   user_options->nonce_error_corrections   = hc_strtoul (optarg, NULL, 10);
  491                                           user_options->nonce_error_corrections_chgd = true;                         break;
  492       case IDX_KEYBOARD_LAYOUT_MAPPING:   user_options->keyboard_layout_mapping   = optarg;                          break;
  493       case IDX_TRUECRYPT_KEYFILES:        user_options->truecrypt_keyfiles        = optarg;                          break;
  494       case IDX_VERACRYPT_KEYFILES:        user_options->veracrypt_keyfiles        = optarg;                          break;
  495       case IDX_VERACRYPT_PIM_START:       user_options->veracrypt_pim_start       = hc_strtoul (optarg, NULL, 10);
  496                                           user_options->veracrypt_pim_start_chgd  = true;                            break;
  497       case IDX_VERACRYPT_PIM_STOP:        user_options->veracrypt_pim_stop        = hc_strtoul (optarg, NULL, 10);
  498                                           user_options->veracrypt_pim_stop_chgd   = true;                            break;
  499       case IDX_SEGMENT_SIZE:              user_options->segment_size              = hc_strtoul (optarg, NULL, 10);
  500                                           user_options->segment_size_chgd         = true;                            break;
  501       case IDX_SCRYPT_TMTO:               user_options->scrypt_tmto               = hc_strtoul (optarg, NULL, 10);
  502                                           user_options->scrypt_tmto_chgd          = true;                            break;
  503       case IDX_SEPARATOR:                 user_options->separator                 = optarg;
  504                                           user_options->separator_chgd            = true;                            break;
  505       case IDX_BITMAP_MIN:                user_options->bitmap_min                = hc_strtoul (optarg, NULL, 10);   break;
  506       case IDX_BITMAP_MAX:                user_options->bitmap_max                = hc_strtoul (optarg, NULL, 10);   break;
  507       case IDX_HOOK_THREADS:              user_options->hook_threads              = hc_strtoul (optarg, NULL, 10);   break;
  508       case IDX_INCREMENT:                 user_options->increment                 = true;                            break;
  509       case IDX_INCREMENT_MIN:             user_options->increment_min             = hc_strtoul (optarg, NULL, 10);
  510                                           user_options->increment_min_chgd        = true;                            break;
  511       case IDX_INCREMENT_MAX:             user_options->increment_max             = hc_strtoul (optarg, NULL, 10);
  512                                           user_options->increment_max_chgd        = true;                            break;
  513       case IDX_CUSTOM_CHARSET_1:          user_options->custom_charset_1          = optarg;                          break;
  514       case IDX_CUSTOM_CHARSET_2:          user_options->custom_charset_2          = optarg;                          break;
  515       case IDX_CUSTOM_CHARSET_3:          user_options->custom_charset_3          = optarg;                          break;
  516       case IDX_CUSTOM_CHARSET_4:          user_options->custom_charset_4          = optarg;                          break;
  517       case IDX_SLOW_CANDIDATES:           user_options->slow_candidates           = true;                            break;
  518       #ifdef WITH_BRAIN
  519       case IDX_BRAIN_CLIENT:              user_options->brain_client              = true;                            break;
  520       case IDX_BRAIN_CLIENT_FEATURES:     user_options->brain_client_features     = hc_strtoul (optarg, NULL, 10);   break;
  521       case IDX_BRAIN_SERVER:              user_options->brain_server              = true;                            break;
  522       case IDX_BRAIN_SERVER_TIMER:        user_options->brain_server_timer        = hc_strtoul (optarg, NULL, 10);
  523                                           user_options->brain_server_timer_chgd   = true;                            break;
  524       case IDX_BRAIN_PASSWORD:            user_options->brain_password            = optarg;
  525                                           user_options->brain_password_chgd       = true;                            break;
  526       case IDX_BRAIN_HOST:                user_options->brain_host                = optarg;
  527                                           user_options->brain_host_chgd           = true;                            break;
  528       case IDX_BRAIN_PORT:                user_options->brain_port                = hc_strtoul (optarg, NULL, 10);
  529                                           user_options->brain_port_chgd           = true;                            break;
  530       case IDX_BRAIN_SESSION:             user_options->brain_session             = hc_strtoul (optarg, NULL, 16);   break;
  531       case IDX_BRAIN_SESSION_WHITELIST:   user_options->brain_session_whitelist   = optarg;                          break;
  532       #endif
  533     }
  534   }
  535 
  536   user_options->hc_bin = argv[0];
  537 
  538   user_options->hc_argc = argc - optind;
  539   user_options->hc_argv = argv + optind;
  540 
  541   return 0;
  542 }
  543 
  544 int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
  545 {
  546   user_options_t *user_options = hashcat_ctx->user_options;
  547 
  548   if (user_options->hc_argc < 0)
  549   {
  550     event_log_error (hashcat_ctx, "hc_argc %d is invalid.", user_options->hc_argc);
  551 
  552     return -1;
  553   }
  554 
  555   if (user_options->hc_argv == NULL)
  556   {
  557     event_log_error (hashcat_ctx, "hc_argv is NULL.");
  558 
  559     return -1;
  560   }
  561 
  562   #ifdef WITH_BRAIN
  563   if ((user_options->brain_client == true) && (user_options->brain_server == true))
  564   {
  565     event_log_error (hashcat_ctx, "Can not have --brain-client and --brain-server at the same time");
  566 
  567     return -1;
  568   }
  569 
  570   if ((user_options->brain_client_features < 1) || (user_options->brain_client_features > 3))
  571   {
  572     event_log_error (hashcat_ctx, "Invalid --brain-client-feature argument");
  573 
  574     return -1;
  575   }
  576 
  577   if ((user_options->brain_client == true) && (user_options->brain_password_chgd == false))
  578   {
  579     event_log_error (hashcat_ctx, "Brain clients need to set --brain-password");
  580 
  581     return -1;
  582   }
  583 
  584   if (user_options->brain_server_timer_chgd)
  585   {
  586     if (user_options->brain_server == false)
  587     {
  588       event_log_error (hashcat_ctx, "The --brain-server-timer flag requires --brain-server.");
  589 
  590       return -1;
  591     }
  592 
  593     if (user_options->brain_server_timer != 0) // special case (no intermediate dumps)
  594     {
  595       if (user_options->brain_server_timer < 60)
  596       {
  597         event_log_error (hashcat_ctx, "Brain server backup timer must be at least 60 seconds.");
  598 
  599         return -1;
  600       }
  601     }
  602   }
  603   #endif
  604 
  605   if (user_options->separator_chgd == true)
  606   {
  607     bool error = false;
  608     if ((strlen (user_options->separator) != 1) && (strlen (user_options->separator) != 4))
  609     {
  610         error = true;
  611     }
  612     if (strlen (user_options->separator) == 4)
  613     {
  614       if ((user_options->separator[0] == '0') && (user_options->separator[1] == 'x'))
  615       {
  616         if (is_valid_hex_string ((u8 * ) (&(user_options->separator[2])), 2))
  617         {
  618           u8 sep = hex_to_u8 ((u8 * ) (&(user_options->separator[2])));
  619           user_options->separator[0] = sep;
  620           user_options->separator[1] = 0;
  621         }
  622         else
  623         {
  624           error = true;
  625         }
  626       }
  627       else{
  628         error = true;
  629       }
  630     }
  631 
  632     if (error)
  633     {
  634       event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte (single char or hex format e.g. 0x09 for TAB)");
  635 
  636       return -1;
  637     }
  638   }
  639 
  640   if (user_options->slow_candidates == true)
  641   {
  642     if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
  643      && (user_options->attack_mode != ATTACK_MODE_COMBI)
  644      && (user_options->attack_mode != ATTACK_MODE_BF))
  645     {
  646       event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified in slow-candidates mode.");
  647 
  648       return -1;
  649     }
  650   }
  651   #ifdef WITH_BRAIN
  652   else if (user_options->brain_client == true)
  653   {
  654     if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
  655      && (user_options->attack_mode != ATTACK_MODE_COMBI)
  656      && (user_options->attack_mode != ATTACK_MODE_BF))
  657     {
  658       event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified in brain-client mode.");
  659 
  660       return -1;
  661     }
  662   }
  663   #endif
  664   else
  665   {
  666     if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
  667      && (user_options->attack_mode != ATTACK_MODE_COMBI)
  668      && (user_options->attack_mode != ATTACK_MODE_BF)
  669      && (user_options->attack_mode != ATTACK_MODE_HYBRID1)
  670      && (user_options->attack_mode != ATTACK_MODE_HYBRID2)
  671      && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION)
  672      && (user_options->attack_mode != ATTACK_MODE_NONE))
  673     {
  674       event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified.");
  675 
  676       return -1;
  677     }
  678   }
  679 
  680   if (user_options->hccapx_message_pair_chgd == true)
  681   {
  682     if (user_options->remove == true)
  683     {
  684       event_log_error (hashcat_ctx, "Combining --remove with --hccapx-message-pair is not allowed.");
  685 
  686       return -1;
  687     }
  688 
  689     if (user_options->hccapx_message_pair >= 6)
  690     {
  691       event_log_error (hashcat_ctx, "Invalid --hccapx-message-pair value specified.");
  692 
  693       return -1;
  694     }
  695   }
  696 
  697   /*
  698   if (user_options->skip_chgd == true && user_options->skip == 0)
  699   {
  700     event_log_error (hashcat_ctx, "Invalid --skip value specified.");
  701 
  702     return -1;
  703   }
  704   */
  705 
  706   if (user_options->limit_chgd == true && user_options->limit == 0)
  707   {
  708     event_log_error (hashcat_ctx, "Invalid --limit value specified.");
  709 
  710     return -1;
  711   }
  712 
  713   if (user_options->runtime_chgd == true && user_options->runtime == 0)
  714   {
  715     event_log_error (hashcat_ctx, "Invalid --runtime value specified.");
  716 
  717     return -1;
  718   }
  719 
  720   if (user_options->limit_chgd == true && user_options->loopback == true)
  721   {
  722     event_log_error (hashcat_ctx, "Combining --limit with --loopback is not allowed.");
  723 
  724     return -1;
  725   }
  726 
  727   if (user_options->hash_mode >= MODULE_HASH_MODES_MAXIMUM)
  728   {
  729     event_log_error (hashcat_ctx, "Invalid -m (hash type) value specified.");
  730 
  731     return -1;
  732   }
  733 
  734   if (user_options->outfile_format == 0)
  735   {
  736     event_log_error (hashcat_ctx, "Invalid --outfile-format value specified.");
  737 
  738     return -1;
  739   }
  740 
  741   if (user_options->left == true)
  742   {
  743     if (user_options->outfile_format_chgd == true)
  744     {
  745       if (user_options->outfile_format > 1)
  746       {
  747         event_log_error (hashcat_ctx, "Combining --outfile-format > 1 with --left is not allowed.");
  748 
  749         return -1;
  750       }
  751     }
  752   }
  753 
  754   if (user_options->show == true)
  755   {
  756     if (user_options->outfile_format_chgd == true)
  757     {
  758       if (user_options->outfile_format & OUTFILE_FMT_CRACKPOS)
  759       {
  760         event_log_error (hashcat_ctx, "Using crack_pos in --outfile-format for --show is not allowed.");
  761 
  762         return -1;
  763       }
  764 
  765       if (user_options->outfile_format & OUTFILE_FMT_TIME_ABS)
  766       {
  767         event_log_error (hashcat_ctx, "Using the absolute timestamp in --outfile-format for --show is not allowed.");
  768 
  769         return -1;
  770       }
  771 
  772       if (user_options->outfile_format & OUTFILE_FMT_TIME_REL)
  773       {
  774         event_log_error (hashcat_ctx, "Using the relative timestamp in --outfile-format for --show is not allowed.");
  775 
  776         return -1;
  777       }
  778     }
  779   }
  780 
  781   if (user_options->increment_min < INCREMENT_MIN)
  782   {
  783     event_log_error (hashcat_ctx, "Invalid --increment-min value specified.");
  784 
  785     return -1;
  786   }
  787 
  788   if (user_options->increment_max > INCREMENT_MAX)
  789   {
  790     event_log_error (hashcat_ctx, "Invalid --increment-max value specified.");
  791 
  792     return -1;
  793   }
  794 
  795   if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == false))
  796   {
  797     event_log_error (hashcat_ctx, "The--veracrypt-pim-start option requires --veracrypt-pim-stop as well.");
  798 
  799     return -1;
  800   }
  801 
  802   if ((user_options->veracrypt_pim_start_chgd == false) && (user_options->veracrypt_pim_stop_chgd == true))
  803   {
  804     event_log_error (hashcat_ctx, "The --veracrypt-pim-stop option requires --veracrypt-pim-start as well.");
  805 
  806     return -1;
  807   }
  808 
  809   if (user_options->veracrypt_pim_start > user_options->veracrypt_pim_stop)
  810   {
  811     event_log_error (hashcat_ctx, "Invalid --veracrypt-pim-start value specified.");
  812 
  813     return -1;
  814   }
  815 
  816   if (user_options->increment_min > user_options->increment_max)
  817   {
  818     event_log_error (hashcat_ctx, "Invalid --increment-min value specified - must be >= --increment-max.");
  819 
  820     return -1;
  821   }
  822 
  823   if ((user_options->increment == true) && (user_options->progress_only == true))
  824   {
  825     event_log_error (hashcat_ctx, "Increment is not allowed in combination with --progress-only.");
  826 
  827     return -1;
  828   }
  829 
  830   if ((user_options->increment == true) && (user_options->speed_only == true))
  831   {
  832     event_log_error (hashcat_ctx, "Increment is not allowed in combination with --speed-only.");
  833 
  834     return -1;
  835   }
  836 
  837   if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
  838   {
  839     event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 0 (straight).");
  840 
  841     return -1;
  842   }
  843 
  844   if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
  845   {
  846     event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 9 (association).");
  847 
  848     return -1;
  849   }
  850 
  851   if ((user_options->remove == true) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
  852   {
  853     event_log_error (hashcat_ctx, "Remove is not allowed in attack mode 9 (association).");
  854 
  855     return -1;
  856   }
  857 
  858   if ((user_options->increment == false) && (user_options->increment_min_chgd == true))
  859   {
  860     event_log_error (hashcat_ctx, "Increment-min is only supported when combined with -i/--increment.");
  861 
  862     return -1;
  863   }
  864 
  865   if ((user_options->increment == false) && (user_options->increment_max_chgd == true))
  866   {
  867     event_log_error (hashcat_ctx, "Increment-max is only supported combined with -i/--increment.");
  868 
  869     return -1;
  870   }
  871 
  872   if ((user_options->rp_files_cnt > 0) && (user_options->rp_gen > 0))
  873   {
  874     event_log_error (hashcat_ctx, "Combining -r/--rules-file and -g/--rules-generate is not supported.");
  875 
  876     return -1;
  877   }
  878 
  879   if ((user_options->rp_files_cnt > 0) || (user_options->rp_gen > 0))
  880   {
  881     if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION))
  882     {
  883       event_log_error (hashcat_ctx, "Use of -r/--rules-file and -g/--rules-generate requires attack mode 0 or 9.");
  884 
  885       return -1;
  886     }
  887   }
  888 
  889   if (user_options->bitmap_min > user_options->bitmap_max)
  890   {
  891     event_log_error (hashcat_ctx, "Invalid --bitmap-min value specified.");
  892 
  893     return -1;
  894   }
  895 
  896   if (user_options->rp_gen_func_min > user_options->rp_gen_func_max)
  897   {
  898     event_log_error (hashcat_ctx, "Invalid --rp-gen-func-min value specified.");
  899 
  900     return -1;
  901   }
  902 
  903   if (user_options->kernel_accel_chgd == true)
  904   {
  905     if (user_options->force == false)
  906     {
  907       event_log_error (hashcat_ctx, "The manual use of the -n option (or --kernel-accel) is outdated.");
  908 
  909       event_log_warning (hashcat_ctx, "Please consider using the -w option instead.");
  910       event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
  911       event_log_warning (hashcat_ctx, NULL);
  912 
  913       return -1;
  914     }
  915 
  916     if (user_options->kernel_accel < 1)
  917     {
  918       event_log_error (hashcat_ctx, "Invalid --kernel-accel value specified - must be greater than 0.");
  919 
  920       return -1;
  921     }
  922 
  923     if (user_options->kernel_accel > 1024)
  924     {
  925       event_log_error (hashcat_ctx, "Invalid --kernel-accel value specified - must be <= 1024.");
  926 
  927       return -1;
  928     }
  929   }
  930 
  931   if (user_options->kernel_loops_chgd == true)
  932   {
  933     if (user_options->force == false)
  934     {
  935       event_log_error (hashcat_ctx, "The manual use of the -u option (or --kernel-loops) is outdated.");
  936 
  937       event_log_warning (hashcat_ctx, "Please consider using the -w option instead.");
  938       event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
  939       event_log_warning (hashcat_ctx, NULL);
  940 
  941       return -1;
  942     }
  943 
  944     if (user_options->kernel_loops < 1)
  945     {
  946       event_log_error (hashcat_ctx, "Invalid kernel-loops specified.");
  947 
  948       return -1;
  949     }
  950 
  951     if (user_options->kernel_loops > 1024)
  952     {
  953       event_log_error (hashcat_ctx, "Invalid kernel-loops specified.");
  954 
  955       return -1;
  956     }
  957   }
  958 
  959   if (user_options->kernel_threads_chgd == true)
  960   {
  961     if (user_options->force == false)
  962     {
  963       event_log_error (hashcat_ctx, "The manual use of the -T option (or --kernel-threads) is outdated.");
  964 
  965       event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors.");
  966       event_log_warning (hashcat_ctx, NULL);
  967 
  968       return -1;
  969     }
  970 
  971     if (user_options->kernel_threads < 1)
  972     {
  973       event_log_error (hashcat_ctx, "Invalid kernel-threads specified.");
  974 
  975       return -1;
  976     }
  977 
  978     if (user_options->kernel_threads > 1024)
  979     {
  980       event_log_error (hashcat_ctx, "Invalid kernel-threads specified.");
  981 
  982       return -1;
  983     }
  984   }
  985 
  986   if ((user_options->workload_profile < 1) || (user_options->workload_profile > 4))
  987   {
  988     event_log_error (hashcat_ctx, "workload-profile %u is not available.", user_options->workload_profile);
  989 
  990     return -1;
  991   }
  992 
  993   if (user_options->backend_vector_width_chgd == true)
  994   {
  995     if (is_power_of_2 (user_options->backend_vector_width) == false || user_options->backend_vector_width > 16)
  996     {
  997       event_log_error (hashcat_ctx, "backend-vector-width %u is not allowed.", user_options->backend_vector_width);
  998 
  999       return -1;
 1000     }
 1001   }
 1002 
 1003   if (user_options->show == true || user_options->left == true)
 1004   {
 1005     if (user_options->remove == true)
 1006     {
 1007       event_log_error (hashcat_ctx, "Mixing --remove not allowed with --show or --left.");
 1008 
 1009       return -1;
 1010     }
 1011 
 1012     if (user_options->potfile_disable == true)
 1013     {
 1014       event_log_error (hashcat_ctx, "Mixing --potfile-disable is not allowed with --show or --left.");
 1015 
 1016       return -1;
 1017     }
 1018   }
 1019 
 1020   if (user_options->show == true)
 1021   {
 1022     if (user_options->outfile_autohex == false)
 1023     {
 1024       event_log_error (hashcat_ctx, "Mixing --outfile-autohex-disable is not allowed with --show.");
 1025 
 1026       return -1;
 1027     }
 1028   }
 1029 
 1030   if (user_options->keyspace == true)
 1031   {
 1032     if (user_options->show == true)
 1033     {
 1034       event_log_error (hashcat_ctx, "Combining --show with --keyspace is not allowed.");
 1035 
 1036       return -1;
 1037     }
 1038 
 1039    if (user_options->left == true)
 1040     {
 1041       event_log_error (hashcat_ctx, "Combining --left with --keyspace is not allowed.");
 1042 
 1043       return -1;
 1044     }
 1045   }
 1046 
 1047   if (user_options->machine_readable == true)
 1048   {
 1049     if (user_options->status_json == true)
 1050     {
 1051       event_log_error (hashcat_ctx, "The --status-json flag can not be used with --machine-readable.");
 1052 
 1053       return -1;
 1054     }
 1055   }
 1056 
 1057   if (user_options->remove_timer_chgd == true)
 1058   {
 1059     if (user_options->remove == false)
 1060     {
 1061       event_log_error (hashcat_ctx, "The --remove-timer flag requires --remove.");
 1062 
 1063       return -1;
 1064     }
 1065 
 1066     if (user_options->remove_timer < 1)
 1067     {
 1068       event_log_error (hashcat_ctx, "The --remove-timer parameter must have a value greater than or equal to 1.");
 1069 
 1070       return -1;
 1071     }
 1072   }
 1073 
 1074   if (user_options->loopback == true)
 1075   {
 1076     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1077     {
 1078       if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
 1079       {
 1080         event_log_error (hashcat_ctx, "Parameter --loopback requires either -r/--rules-file or -g/--rules-generate.");
 1081 
 1082         return -1;
 1083       }
 1084     }
 1085     else
 1086     {
 1087       event_log_error (hashcat_ctx, "Parameter --loopback is only allowed in attack mode 0 (straight).");
 1088 
 1089       return -1;
 1090     }
 1091   }
 1092 
 1093   if (user_options->debug_mode > 0)
 1094   {
 1095     if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION))
 1096     {
 1097       event_log_error (hashcat_ctx, "Parameter --debug-mode option is only allowed in attack mode 0 (straight).");
 1098 
 1099       return -1;
 1100     }
 1101 
 1102     if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
 1103     {
 1104       event_log_error (hashcat_ctx, "Use of --debug-mode requires -r/--rules-file or -g/--rules-generate.");
 1105 
 1106       return -1;
 1107     }
 1108   }
 1109 
 1110   if (user_options->debug_mode > 5)
 1111   {
 1112     event_log_error (hashcat_ctx, "Invalid --debug-mode value specified.");
 1113 
 1114     return -1;
 1115   }
 1116 
 1117   if (user_options->induction_dir != NULL)
 1118   {
 1119     if (user_options->attack_mode == ATTACK_MODE_BF)
 1120     {
 1121       event_log_error (hashcat_ctx, "Use of --induction-dir is not allowed in attack mode 3 (brute-force).");
 1122 
 1123       return -1;
 1124     }
 1125 
 1126     if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1127     {
 1128       event_log_error (hashcat_ctx, "Use of --induction-dir is not allowed in attack mode 9 (association).");
 1129 
 1130       return -1;
 1131     }
 1132   }
 1133 
 1134   if (user_options->spin_damp > 100)
 1135   {
 1136     event_log_error (hashcat_ctx, "Values of --spin-damp must be between 0 and 100 (inclusive).");
 1137 
 1138     return -1;
 1139   }
 1140 
 1141   if (user_options->identify == true)
 1142   {
 1143     if (user_options->hash_mode_chgd == true)
 1144     {
 1145       event_log_error (hashcat_ctx, "Can't change --hash-type (-m) in identify mode.");
 1146 
 1147       return -1;
 1148     }
 1149   }
 1150 
 1151   if (user_options->benchmark == true)
 1152   {
 1153     // sanity checks based on automatically overwritten configuration variables by
 1154     // benchmark mode section in user_options_preprocess()
 1155 
 1156     #ifdef WITH_BRAIN
 1157     if (user_options->brain_client == true)
 1158     {
 1159       event_log_error (hashcat_ctx, "Brain client (-z) is not allowed in benchmark mode.");
 1160 
 1161       return -1;
 1162     }
 1163 
 1164     if (user_options->brain_server == true)
 1165     {
 1166       event_log_error (hashcat_ctx, "Brain server is not allowed in benchmark mode.");
 1167 
 1168       return -1;
 1169     }
 1170     #endif
 1171 
 1172     if (user_options->attack_mode_chgd == true)
 1173     {
 1174       event_log_error (hashcat_ctx, "Can't change --attack-mode (-a) in benchmark mode.");
 1175 
 1176       return -1;
 1177     }
 1178 
 1179     if (user_options->bitmap_min != BITMAP_MIN)
 1180     {
 1181       event_log_error (hashcat_ctx, "Can't change --bitmap-min in benchmark mode.");
 1182 
 1183       return -1;
 1184     }
 1185 
 1186     if (user_options->bitmap_max != BITMAP_MAX)
 1187     {
 1188       event_log_error (hashcat_ctx, "Can't change --bitmap-max in benchmark mode.");
 1189 
 1190       return -1;
 1191     }
 1192 
 1193     if (user_options->hwmon_temp_abort != HWMON_TEMP_ABORT)
 1194     {
 1195       event_log_error (hashcat_ctx, "Can't change --hwmon-temp-abort in benchmark mode.");
 1196 
 1197       return -1;
 1198     }
 1199 
 1200     if (user_options->left == true)
 1201     {
 1202       event_log_error (hashcat_ctx, "Can't change --left in benchmark mode.");
 1203 
 1204       return -1;
 1205     }
 1206 
 1207     if (user_options->show == true)
 1208     {
 1209       event_log_error (hashcat_ctx, "Can't change --show in benchmark mode.");
 1210 
 1211       return -1;
 1212     }
 1213 
 1214     if (user_options->speed_only == true)
 1215     {
 1216       event_log_error (hashcat_ctx, "Can't change --speed-only in benchmark mode.");
 1217 
 1218       return -1;
 1219     }
 1220 
 1221     if (user_options->progress_only == true)
 1222     {
 1223       event_log_error (hashcat_ctx, "Can't change --progress-only in benchmark mode.");
 1224 
 1225       return -1;
 1226     }
 1227 
 1228     if (user_options->hash_info == true)
 1229     {
 1230       event_log_error (hashcat_ctx, "Use of --hash-info is not allowed in benchmark mode.");
 1231 
 1232       return -1;
 1233     }
 1234 
 1235     if (user_options->increment == true)
 1236     {
 1237       event_log_error (hashcat_ctx, "Can't change --increment (-i) in benchmark mode.");
 1238 
 1239       return -1;
 1240     }
 1241 
 1242     if (user_options->restore == true)
 1243     {
 1244       event_log_error (hashcat_ctx, "Can't change --restore in benchmark mode.");
 1245 
 1246       return -1;
 1247     }
 1248 
 1249     if (user_options->status == true)
 1250     {
 1251       event_log_error (hashcat_ctx, "Can't change --status in benchmark mode.");
 1252 
 1253       return -1;
 1254     }
 1255 
 1256     if (user_options->spin_damp_chgd == true)
 1257     {
 1258       event_log_error (hashcat_ctx, "Can't change --spin-damp in benchmark mode.");
 1259 
 1260       return -1;
 1261     }
 1262 
 1263     if ((user_options->custom_charset_1 != NULL)
 1264      || (user_options->custom_charset_2 != NULL)
 1265      || (user_options->custom_charset_3 != NULL)
 1266      || (user_options->custom_charset_4 != NULL))
 1267     {
 1268       if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
 1269       {
 1270         event_log_error (hashcat_ctx, "Custom charsets are not supported in benchmark mode.");
 1271 
 1272         return -1;
 1273       }
 1274     }
 1275   }
 1276 
 1277   if (user_options->markov_hcstat2 != NULL)
 1278   {
 1279     if (strlen (user_options->markov_hcstat2) == 0)
 1280     {
 1281       event_log_error (hashcat_ctx, "Invalid --markov-hcstat2 value - must not be empty.");
 1282 
 1283       return -1;
 1284     }
 1285   }
 1286 
 1287   if (user_options->markov_threshold != 0) // is 0 by default
 1288   {
 1289     if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_COMBI) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
 1290     {
 1291       event_log_error (hashcat_ctx, "Option --markov-threshold is not allowed in combination with --attack mode %d", user_options->attack_mode);
 1292 
 1293       return -1;
 1294     }
 1295   }
 1296 
 1297   if (user_options->restore_file_path != NULL)
 1298   {
 1299     if (strlen (user_options->restore_file_path) == 0)
 1300     {
 1301       event_log_error (hashcat_ctx, "Invalid --restore-file-path value - must not be empty.");
 1302 
 1303       return -1;
 1304     }
 1305   }
 1306 
 1307   if (user_options->outfile != NULL)
 1308   {
 1309     if (strlen (user_options->outfile) == 0)
 1310     {
 1311       event_log_error (hashcat_ctx, "Invalid --outfile value - must not be empty.");
 1312 
 1313       return -1;
 1314     }
 1315   }
 1316 
 1317   if (user_options->debug_file != NULL)
 1318   {
 1319     if (strlen (user_options->debug_file) == 0)
 1320     {
 1321       event_log_error (hashcat_ctx, "Invalid --debug-file value - must not be empty.");
 1322 
 1323       return -1;
 1324     }
 1325   }
 1326 
 1327   if (user_options->session != NULL)
 1328   {
 1329     if (strlen (user_options->session) == 0)
 1330     {
 1331       event_log_error (hashcat_ctx, "Invalid --session value - must not be empty.");
 1332 
 1333       return -1;
 1334     }
 1335   }
 1336 
 1337   if (user_options->cpu_affinity != NULL)
 1338   {
 1339     if (strlen (user_options->cpu_affinity) == 0)
 1340     {
 1341       event_log_error (hashcat_ctx, "Invalid --cpu-affinity value - must not be empty.");
 1342 
 1343       return -1;
 1344     }
 1345   }
 1346 
 1347   if (user_options->backend_devices != NULL)
 1348   {
 1349     if (strlen (user_options->backend_devices) == 0)
 1350     {
 1351       event_log_error (hashcat_ctx, "Invalid --backend-devices value - must not be empty.");
 1352 
 1353       return -1;
 1354     }
 1355   }
 1356 
 1357   if (user_options->opencl_device_types != NULL)
 1358   {
 1359     if (strlen (user_options->opencl_device_types) == 0)
 1360     {
 1361       event_log_error (hashcat_ctx, "Invalid --opencl-device-types value - must not be empty.");
 1362 
 1363       return -1;
 1364     }
 1365   }
 1366 
 1367   if (user_options->stdin_timeout_abort_chgd == true)
 1368   {
 1369     if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
 1370     {
 1371       event_log_error (hashcat_ctx, "Use of --stdin-timeout-abort is only allowed in attack mode 0 (straight).");
 1372 
 1373       return -1;
 1374     }
 1375 
 1376     // --stdin-timeout-abort can only be used in stdin mode
 1377 
 1378     int hc_argc_expected = 1; // our hash file (note: hc_argc only counts hash files and dicts)
 1379 
 1380     if (user_options->stdout_flag == true) hc_argc_expected = 0; // special case: no hash file
 1381 
 1382     if (user_options->hc_argc != hc_argc_expected)
 1383     {
 1384       event_log_error (hashcat_ctx, "Use of --stdin-timeout-abort is only allowed in stdin mode (pipe).");
 1385 
 1386       return -1;
 1387     }
 1388   }
 1389 
 1390   if (user_options->backend_info > 2)
 1391   {
 1392     event_log_error (hashcat_ctx, "Invalid --backend-info/-I value, must have a value greater or equal to 0 and lower than 3.");
 1393 
 1394     return -1;
 1395   }
 1396 
 1397   #ifdef WITH_BRAIN
 1398   if ((user_options->brain_client == true) && (user_options->remove == true))
 1399   {
 1400     event_log_error (hashcat_ctx, "Using --remove is not allowed if --brain-client is used.");
 1401 
 1402     return -1;
 1403   }
 1404 
 1405   if ((user_options->brain_client == true) && (user_options->potfile_disable == true))
 1406   {
 1407     event_log_error (hashcat_ctx, "Using --potfile-disable is not allowed if --brain-client is used.");
 1408 
 1409     return -1;
 1410   }
 1411   #endif
 1412 
 1413   // custom charset checks
 1414 
 1415   if ((user_options->custom_charset_1 != NULL)
 1416    || (user_options->custom_charset_2 != NULL)
 1417    || (user_options->custom_charset_3 != NULL)
 1418    || (user_options->custom_charset_4 != NULL))
 1419   {
 1420     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1421     {
 1422       event_log_error (hashcat_ctx, "Custom charsets are not supported in attack mode 0 (straight).");
 1423 
 1424       return -1;
 1425     }
 1426 
 1427     if (user_options->attack_mode == ATTACK_MODE_COMBI)
 1428     {
 1429       event_log_error (hashcat_ctx, "Custom charsets are not supported in attack mode 1 (combination).");
 1430 
 1431       return -1;
 1432     }
 1433 
 1434     if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1435     {
 1436       event_log_error (hashcat_ctx, "Custom charsets are not supported in attack mode 9 (association).");
 1437 
 1438       return -1;
 1439     }
 1440 
 1441     // detect if mask was specified:
 1442 
 1443     bool mask_is_missing = true;
 1444 
 1445     if (user_options->keyspace == true) // special case if --keyspace was used: we need the mask but no hash file
 1446     {
 1447       if (user_options->hc_argc > 0) mask_is_missing = false;
 1448     }
 1449     else if (user_options->stdout_flag == true) // special case if --stdout was used: we need the mask but no hash file
 1450     {
 1451       if (user_options->hc_argc > 0) mask_is_missing = false;
 1452     }
 1453     else
 1454     {
 1455       if (user_options->hc_argc > 1) mask_is_missing = false;
 1456     }
 1457 
 1458     if (mask_is_missing == true)
 1459     {
 1460       event_log_error (hashcat_ctx, "If you specify a custom charset, you must also specify a mask.");
 1461 
 1462       return -1;
 1463     }
 1464   }
 1465 
 1466   // argc / argv checks
 1467 
 1468   bool show_error = true;
 1469 
 1470   if (user_options->version == true)
 1471   {
 1472     show_error = false;
 1473   }
 1474   else if (user_options->usage == true)
 1475   {
 1476     show_error = false;
 1477   }
 1478   #ifdef WITH_BRAIN
 1479   else if (user_options->brain_server == true)
 1480   {
 1481     show_error = false;
 1482   }
 1483   #endif
 1484   else if (user_options->benchmark == true)
 1485   {
 1486     if (user_options->hc_argc == 0)
 1487     {
 1488       show_error = false;
 1489     }
 1490   }
 1491   else if (user_options->hash_info == true)
 1492   {
 1493     if (user_options->hc_argc == 0)
 1494     {
 1495       show_error = false;
 1496     }
 1497   }
 1498   else if (user_options->backend_info > 0)
 1499   {
 1500     if (user_options->hc_argc == 0)
 1501     {
 1502       show_error = false;
 1503     }
 1504   }
 1505   else if (user_options->restore == true)
 1506   {
 1507     if (user_options->hc_argc == 0)
 1508     {
 1509       show_error = false;
 1510     }
 1511   }
 1512   else if (user_options->keyspace == true)
 1513   {
 1514     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1515     {
 1516       if (user_options->hc_argc == 1)
 1517       {
 1518         show_error = false;
 1519       }
 1520     }
 1521     else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 1522     {
 1523       if (user_options->hc_argc == 2)
 1524       {
 1525         show_error = false;
 1526       }
 1527     }
 1528     else if (user_options->attack_mode == ATTACK_MODE_BF)
 1529     {
 1530       if (user_options->hc_argc == 1)
 1531       {
 1532         show_error = false;
 1533       }
 1534     }
 1535     else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 1536     {
 1537       if (user_options->hc_argc == 2)
 1538       {
 1539         show_error = false;
 1540       }
 1541     }
 1542     else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 1543     {
 1544       if (user_options->hc_argc == 2)
 1545       {
 1546         show_error = false;
 1547       }
 1548     }
 1549     else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1550     {
 1551       if (user_options->hc_argc == 1)
 1552       {
 1553         show_error = false;
 1554       }
 1555     }
 1556   }
 1557   else if (user_options->stdout_flag == true)
 1558   {
 1559     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1560     {
 1561       // all argc possible because of stdin mode
 1562 
 1563       show_error = false;
 1564     }
 1565     else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 1566     {
 1567       if (user_options->hc_argc == 2)
 1568       {
 1569         show_error = false;
 1570       }
 1571     }
 1572     else if (user_options->attack_mode == ATTACK_MODE_BF)
 1573     {
 1574       if (user_options->hc_argc >= 1)
 1575       {
 1576         show_error = false;
 1577       }
 1578     }
 1579     else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 1580     {
 1581       if (user_options->hc_argc >= 1)
 1582       {
 1583         show_error = false;
 1584       }
 1585     }
 1586     else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 1587     {
 1588       if (user_options->hc_argc >= 1)
 1589       {
 1590         show_error = false;
 1591       }
 1592     }
 1593     else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1594     {
 1595       if (user_options->hc_argc >= 1)
 1596       {
 1597         show_error = false;
 1598       }
 1599     }
 1600   }
 1601   else
 1602   {
 1603     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1604     {
 1605       if (user_options->hc_argc >= 1)
 1606       {
 1607         show_error = false;
 1608       }
 1609 
 1610       if (user_options->hc_argc == 1)
 1611       {
 1612         // stdin mode
 1613 
 1614         #ifdef WITH_BRAIN
 1615         if (user_options->brain_client == true)
 1616         {
 1617           event_log_error (hashcat_ctx, "Use of --brain-client is not possible in stdin mode.");
 1618 
 1619           return -1;
 1620         }
 1621         #endif
 1622 
 1623         if (user_options->slow_candidates == true)
 1624         {
 1625           event_log_error (hashcat_ctx, "Use of --slow-candidates is not possible in stdin mode.");
 1626 
 1627           return -1;
 1628         }
 1629       }
 1630     }
 1631     else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 1632     {
 1633       if (user_options->hc_argc == 3)
 1634       {
 1635         show_error = false;
 1636       }
 1637     }
 1638     else if (user_options->attack_mode == ATTACK_MODE_BF)
 1639     {
 1640       if (user_options->hc_argc >= 1)
 1641       {
 1642         show_error = false;
 1643       }
 1644     }
 1645     else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 1646     {
 1647       if (user_options->hc_argc >= 2)
 1648       {
 1649         show_error = false;
 1650       }
 1651     }
 1652     else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 1653     {
 1654       if (user_options->hc_argc >= 2)
 1655       {
 1656         show_error = false;
 1657       }
 1658     }
 1659     else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1660     {
 1661       if (user_options->hc_argc >= 2)
 1662       {
 1663         show_error = false;
 1664       }
 1665     }
 1666   }
 1667 
 1668   if (show_error == true)
 1669   {
 1670     usage_mini_print (user_options->hc_bin);
 1671 
 1672     return -1;
 1673   }
 1674 
 1675   return 0;
 1676 }
 1677 
 1678 void user_options_session_auto (hashcat_ctx_t *hashcat_ctx)
 1679 {
 1680   user_options_t *user_options = hashcat_ctx->user_options;
 1681 
 1682   if (strcmp (user_options->session, PROGNAME) == 0)
 1683   {
 1684     if (user_options->benchmark == true)
 1685     {
 1686       user_options->session = "benchmark";
 1687     }
 1688 
 1689     if (user_options->hash_info == true)
 1690     {
 1691       user_options->session = "hash_info";
 1692     }
 1693 
 1694     if (user_options->usage == true)
 1695     {
 1696       user_options->session = "usage";
 1697     }
 1698 
 1699     if (user_options->speed_only == true)
 1700     {
 1701       user_options->session = "speed_only";
 1702     }
 1703 
 1704     if (user_options->progress_only == true)
 1705     {
 1706       user_options->session = "progress_only";
 1707     }
 1708 
 1709     if (user_options->keyspace == true)
 1710     {
 1711       user_options->session = "keyspace";
 1712     }
 1713 
 1714     if (user_options->stdout_flag == true)
 1715     {
 1716       user_options->session = "stdout";
 1717     }
 1718 
 1719     if (user_options->backend_info > 0)
 1720     {
 1721       user_options->session = "backend_info";
 1722     }
 1723 
 1724     if (user_options->show == true)
 1725     {
 1726       user_options->session = "show";
 1727     }
 1728 
 1729     if (user_options->left == true)
 1730     {
 1731       user_options->session = "left";
 1732     }
 1733 
 1734     if (user_options->identify == true)
 1735     {
 1736       user_options->session = "identify";
 1737     }
 1738   }
 1739 }
 1740 
 1741 void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
 1742 {
 1743   user_options_t *user_options = hashcat_ctx->user_options;
 1744 
 1745   // some options can influence or overwrite other options
 1746 
 1747   #ifdef WITH_BRAIN
 1748   if (user_options->brain_client == true)
 1749   {
 1750     user_options->slow_candidates = true;
 1751   }
 1752   #endif
 1753 
 1754   if (user_options->stdout_flag)
 1755   {
 1756     user_options->hwmon_disable       = true;
 1757     user_options->left                = false;
 1758     user_options->logfile_disable     = true;
 1759     user_options->spin_damp           = 0;
 1760     user_options->outfile_check_timer = 0;
 1761     user_options->potfile_disable     = true;
 1762     user_options->restore_disable     = true;
 1763     user_options->restore             = false;
 1764     user_options->restore_timer       = 0;
 1765     user_options->show                = false;
 1766     user_options->status              = false;
 1767     user_options->status_timer        = 0;
 1768     user_options->bitmap_min          = 1;
 1769     user_options->bitmap_max          = 1;
 1770   }
 1771 
 1772   if (user_options->hash_info        == true
 1773    || user_options->keyspace         == true
 1774    || user_options->speed_only       == true
 1775    || user_options->progress_only    == true
 1776    || user_options->identify         == true
 1777    || user_options->usage            == true
 1778    || user_options->backend_info      > 0)
 1779   {
 1780     user_options->hwmon_disable       = true;
 1781     user_options->left                = false;
 1782     user_options->logfile_disable     = true;
 1783     user_options->spin_damp           = 0;
 1784     user_options->outfile_check_timer = 0;
 1785     user_options->potfile_disable     = true;
 1786     user_options->restore_disable     = true;
 1787     user_options->restore             = false;
 1788     user_options->restore_timer       = 0;
 1789     user_options->show                = false;
 1790     user_options->status              = false;
 1791     user_options->status_timer        = 0;
 1792     user_options->bitmap_min          = 1;
 1793     user_options->bitmap_max          = 1;
 1794     #ifdef WITH_BRAIN
 1795     user_options->brain_client        = false;
 1796     #endif
 1797   }
 1798 
 1799   if (user_options->benchmark == true)
 1800   {
 1801     user_options->attack_mode         = ATTACK_MODE_BF;
 1802     user_options->hwmon_temp_abort    = 0;
 1803     user_options->increment           = false;
 1804     user_options->left                = false;
 1805     user_options->logfile_disable     = true;
 1806     user_options->spin_damp           = 0;
 1807     user_options->potfile_disable     = true;
 1808     user_options->progress_only       = false;
 1809     user_options->restore_disable     = true;
 1810     user_options->restore             = false;
 1811     user_options->restore_timer       = 0;
 1812     user_options->show                = false;
 1813     user_options->speed_only          = true;
 1814     user_options->status              = false;
 1815     user_options->status_timer        = 0;
 1816     user_options->bitmap_min          = 1;
 1817     user_options->bitmap_max          = 1;
 1818     #ifdef WITH_BRAIN
 1819     user_options->brain_client        = false;
 1820     #endif
 1821 
 1822     if (user_options->workload_profile_chgd == false)
 1823     {
 1824       user_options->optimized_kernel_enable = true;
 1825       user_options->workload_profile        = 3;
 1826     }
 1827   }
 1828 
 1829   if (user_options->hash_info == true)
 1830   {
 1831     user_options->quiet = true;
 1832   }
 1833 
 1834   if (user_options->usage == true)
 1835   {
 1836     user_options->quiet = true;
 1837   }
 1838 
 1839   if (user_options->progress_only == true)
 1840   {
 1841     user_options->speed_only = true;
 1842   }
 1843 
 1844   if (user_options->keyspace == true)
 1845   {
 1846     user_options->quiet = true;
 1847   }
 1848 
 1849   if (user_options->slow_candidates == true)
 1850   {
 1851     user_options->backend_vector_width = 1;
 1852   }
 1853 
 1854   if (user_options->stdout_flag == true)
 1855   {
 1856     user_options->force                 = true;
 1857     user_options->hash_mode             = 2000;
 1858     user_options->kernel_accel          = 1024;
 1859     user_options->backend_vector_width  = 1;
 1860     user_options->outfile_format        = OUTFILE_FMT_PLAIN;
 1861     user_options->quiet                 = true;
 1862 
 1863     if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 1864     {
 1865       user_options->kernel_loops = KERNEL_RULES;
 1866     }
 1867     else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 1868     {
 1869       user_options->kernel_loops = KERNEL_COMBS;
 1870     }
 1871     else if (user_options->attack_mode == ATTACK_MODE_BF)
 1872     {
 1873       user_options->kernel_loops = KERNEL_BFS;
 1874     }
 1875     else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 1876     {
 1877       user_options->kernel_loops = KERNEL_COMBS;
 1878     }
 1879     else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 1880     {
 1881       user_options->kernel_loops = KERNEL_COMBS;
 1882     }
 1883     else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1884     {
 1885       user_options->kernel_loops = KERNEL_RULES;
 1886     }
 1887   }
 1888 
 1889   if (user_options->backend_info > 0)
 1890   {
 1891     user_options->backend_devices     = NULL;
 1892     user_options->opencl_device_types = hcstrdup ("1,2,3");
 1893     user_options->quiet               = true;
 1894   }
 1895 
 1896   if (user_options->left == true)
 1897   {
 1898     user_options->outfile_format = OUTFILE_FMT_HASH;
 1899   }
 1900 
 1901   if (user_options->show == true || user_options->left == true)
 1902   {
 1903     user_options->attack_mode = ATTACK_MODE_NONE;
 1904     user_options->quiet       = true;
 1905   }
 1906 
 1907   // this allows the user to use --show and --left while cracking (i.e. while another instance of hashcat is running)
 1908   if (user_options->show == true || user_options->left == true)
 1909   {
 1910     user_options->restore_disable = true;
 1911 
 1912     user_options->restore = false;
 1913   }
 1914 
 1915   if (user_options->skip != 0 && user_options->limit != 0)
 1916   {
 1917     user_options->limit += user_options->skip;
 1918   }
 1919 
 1920   if (user_options->markov_threshold == 0)
 1921   {
 1922     user_options->markov_threshold = 0x100;
 1923   }
 1924 
 1925   if (user_options->segment_size_chgd == true)
 1926   {
 1927     user_options->segment_size *= (1024 * 1024);
 1928   }
 1929 
 1930   #if !defined (WITH_HWMON)
 1931   user_options->hwmon_disable = true;
 1932   #endif // WITH_HWMON
 1933 
 1934   if (user_options->hwmon_disable == true)
 1935   {
 1936     user_options->hwmon_temp_abort = 0;
 1937   }
 1938 
 1939   // default mask
 1940 
 1941   if (user_options->attack_mode == ATTACK_MODE_BF)
 1942   {
 1943     if (user_options->hash_info == true)
 1944     {
 1945 
 1946     }
 1947     else if (user_options->backend_info > 0)
 1948     {
 1949 
 1950     }
 1951     else if (user_options->speed_only == true)
 1952     {
 1953 
 1954     }
 1955     else if (user_options->keyspace == true)
 1956     {
 1957       if (user_options->hc_argc == 0)
 1958       {
 1959         user_options->custom_charset_1 = DEF_MASK_CS_1;
 1960         user_options->custom_charset_2 = DEF_MASK_CS_2;
 1961         user_options->custom_charset_3 = DEF_MASK_CS_3;
 1962 
 1963         user_options->increment = true;
 1964       }
 1965     }
 1966     else if (user_options->stdout_flag == true)
 1967     {
 1968       if (user_options->hc_argc == 0)
 1969       {
 1970         user_options->custom_charset_1 = DEF_MASK_CS_1;
 1971         user_options->custom_charset_2 = DEF_MASK_CS_2;
 1972         user_options->custom_charset_3 = DEF_MASK_CS_3;
 1973 
 1974         user_options->increment = true;
 1975       }
 1976     }
 1977     else
 1978     {
 1979       if (user_options->hc_argc == 1)
 1980       {
 1981         user_options->custom_charset_1 = DEF_MASK_CS_1;
 1982         user_options->custom_charset_2 = DEF_MASK_CS_2;
 1983         user_options->custom_charset_3 = DEF_MASK_CS_3;
 1984 
 1985         user_options->increment = true;
 1986       }
 1987     }
 1988   }
 1989 
 1990   // association limitations
 1991 
 1992   if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 1993   {
 1994     user_options->potfile_disable = true;
 1995   }
 1996 
 1997   if (user_options->stdout_flag == false && user_options->benchmark == false && user_options->keyspace == false)
 1998   {
 1999     if (user_options->hash_mode == 0 && user_options->hash_mode_chgd == false)
 2000     {
 2001       user_options->autodetect = true;
 2002     }
 2003   }
 2004 }
 2005 
 2006 void user_options_postprocess (hashcat_ctx_t *hashcat_ctx)
 2007 {
 2008   user_options_t       *user_options       = hashcat_ctx->user_options;
 2009   user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
 2010 
 2011   // automatic status
 2012 
 2013   if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
 2014   {
 2015     user_options->status = true;
 2016   }
 2017 }
 2018 
 2019 void user_options_info (hashcat_ctx_t *hashcat_ctx)
 2020 {
 2021   const user_options_t *user_options = hashcat_ctx->user_options;
 2022 
 2023   if (user_options->quiet == true) return;
 2024 
 2025   if (user_options->benchmark == false) return;
 2026 
 2027   if (user_options->machine_readable == false)
 2028   {
 2029     event_log_info (hashcat_ctx, "Benchmark relevant options:");
 2030     event_log_info (hashcat_ctx, "===========================");
 2031 
 2032     if (user_options->benchmark_all == true)
 2033     {
 2034       event_log_info (hashcat_ctx, "* --benchmark-all");
 2035     }
 2036 
 2037     if (user_options->force == true)
 2038     {
 2039       event_log_info (hashcat_ctx, "* --force");
 2040     }
 2041 
 2042     if (user_options->backend_devices)
 2043     {
 2044       event_log_info (hashcat_ctx, "* --backend-devices=%s", user_options->backend_devices);
 2045     }
 2046 
 2047     if (user_options->opencl_device_types)
 2048     {
 2049       event_log_info (hashcat_ctx, "* --opencl-device-types=%s", user_options->opencl_device_types);
 2050     }
 2051 
 2052     if (user_options->optimized_kernel_enable == true)
 2053     {
 2054       event_log_info (hashcat_ctx, "* --optimized-kernel-enable");
 2055     }
 2056 
 2057     if (user_options->multiply_accel_disable == true)
 2058     {
 2059       event_log_info (hashcat_ctx, "* --multiply-accel-disable");
 2060     }
 2061 
 2062     if (user_options->backend_vector_width_chgd == true)
 2063     {
 2064       event_log_info (hashcat_ctx, "* --backend-vector-width=%u", user_options->backend_vector_width);
 2065     }
 2066 
 2067     if (user_options->kernel_accel_chgd == true)
 2068     {
 2069       event_log_info (hashcat_ctx, "* --kernel-accel=%u", user_options->kernel_accel);
 2070     }
 2071     else if (user_options->kernel_loops_chgd == true)
 2072     {
 2073       event_log_info (hashcat_ctx, "* --kernel-loops=%u", user_options->kernel_loops);
 2074     }
 2075     else if (user_options->kernel_threads_chgd == true)
 2076     {
 2077       event_log_info (hashcat_ctx, "* --kernel-threads=%u", user_options->kernel_threads);
 2078     }
 2079     else
 2080     {
 2081       if (user_options->workload_profile_chgd == true)
 2082       {
 2083         event_log_info (hashcat_ctx, "* --workload-profile=%u", user_options->workload_profile);
 2084       }
 2085     }
 2086 
 2087     event_log_info (hashcat_ctx, NULL);
 2088   }
 2089   else
 2090   {
 2091     if (user_options->benchmark_all == true)
 2092     {
 2093       event_log_info (hashcat_ctx, "# option: --benchmark-all");
 2094     }
 2095 
 2096     if (user_options->force == true)
 2097     {
 2098       event_log_info (hashcat_ctx, "# option: --force");
 2099     }
 2100 
 2101     if (user_options->backend_devices)
 2102     {
 2103       event_log_info (hashcat_ctx, "# option: --backend-devices=%s", user_options->backend_devices);
 2104     }
 2105 
 2106     if (user_options->opencl_device_types)
 2107     {
 2108       event_log_info (hashcat_ctx, "# option: --opencl-device-types=%s", user_options->opencl_device_types);
 2109     }
 2110 
 2111     if (user_options->optimized_kernel_enable == true)
 2112     {
 2113       event_log_info (hashcat_ctx, "# option: --optimized-kernel-enable");
 2114     }
 2115 
 2116     if (user_options->multiply_accel_disable == true)
 2117     {
 2118       event_log_info (hashcat_ctx, "# option: --multiply-accel-disable");
 2119     }
 2120 
 2121     if (user_options->backend_vector_width_chgd == true)
 2122     {
 2123       event_log_info (hashcat_ctx, "# option: --backend-vector-width=%u", user_options->backend_vector_width);
 2124     }
 2125 
 2126     if (user_options->kernel_accel_chgd == true)
 2127     {
 2128       event_log_info (hashcat_ctx, "# option: --kernel-accel=%u", user_options->kernel_accel);
 2129     }
 2130     else if (user_options->kernel_loops_chgd == true)
 2131     {
 2132       event_log_info (hashcat_ctx, "# option: --kernel-loops=%u", user_options->kernel_loops);
 2133     }
 2134     else if (user_options->kernel_threads_chgd == true)
 2135     {
 2136       event_log_info (hashcat_ctx, "# option: --kernel-threads=%u", user_options->kernel_threads);
 2137     }
 2138     else
 2139     {
 2140       if (user_options->workload_profile_chgd == true)
 2141       {
 2142         event_log_info (hashcat_ctx, "# option: --workload-profile=%u", user_options->workload_profile);
 2143       }
 2144     }
 2145   }
 2146 }
 2147 
 2148 void user_options_extra_init (hashcat_ctx_t *hashcat_ctx)
 2149 {
 2150   user_options_t       *user_options       = hashcat_ctx->user_options;
 2151   user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
 2152 
 2153   // separator
 2154 
 2155   if (user_options->separator)
 2156   {
 2157     user_options_extra->separator = user_options->separator[0];
 2158   }
 2159 
 2160   // attack-kern
 2161 
 2162   user_options_extra->attack_kern = ATTACK_KERN_NONE;
 2163 
 2164   switch (user_options->attack_mode)
 2165   {
 2166     case ATTACK_MODE_STRAIGHT:      user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break;
 2167     case ATTACK_MODE_COMBI:         user_options_extra->attack_kern = ATTACK_KERN_COMBI;    break;
 2168     case ATTACK_MODE_BF:            user_options_extra->attack_kern = ATTACK_KERN_BF;       break;
 2169     case ATTACK_MODE_HYBRID1:       user_options_extra->attack_kern = ATTACK_KERN_COMBI;    break;
 2170     case ATTACK_MODE_HYBRID2:       user_options_extra->attack_kern = ATTACK_KERN_COMBI;    break;
 2171     case ATTACK_MODE_ASSOCIATION:   user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break;
 2172   }
 2173 
 2174   // rules
 2175 
 2176   user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
 2177   user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
 2178 
 2179   // hc_hash and hc_work*
 2180 
 2181   user_options_extra->hc_hash  = NULL;
 2182   user_options_extra->hc_workv = NULL;
 2183   user_options_extra->hc_workc = 0;
 2184 
 2185   if (user_options->benchmark == true)
 2186   {
 2187 
 2188   }
 2189   else if (user_options->hash_info == true)
 2190   {
 2191 
 2192   }
 2193   else if (user_options->backend_info > 0)
 2194   {
 2195 
 2196   }
 2197   else if (user_options->keyspace == true)
 2198   {
 2199     user_options_extra->hc_workc = user_options->hc_argc;
 2200     user_options_extra->hc_workv = user_options->hc_argv;
 2201   }
 2202   else if (user_options->stdout_flag == true)
 2203   {
 2204     user_options_extra->hc_workc = user_options->hc_argc;
 2205     user_options_extra->hc_workv = user_options->hc_argv;
 2206   }
 2207   else
 2208   {
 2209     user_options_extra->hc_hash  = user_options->hc_argv[0];
 2210     user_options_extra->hc_workc = user_options->hc_argc - 1;
 2211     user_options_extra->hc_workv = user_options->hc_argv + 1;
 2212   }
 2213 
 2214   // wordlist_mode
 2215 
 2216   user_options_extra->wordlist_mode = WL_MODE_NONE;
 2217 
 2218   if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
 2219   {
 2220     user_options_extra->wordlist_mode = (user_options_extra->hc_workc >= 1) ? WL_MODE_FILE : WL_MODE_STDIN;
 2221   }
 2222   else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
 2223   {
 2224     user_options_extra->wordlist_mode = WL_MODE_FILE;
 2225   }
 2226   else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
 2227   {
 2228     user_options_extra->wordlist_mode = WL_MODE_MASK;
 2229   }
 2230 }
 2231 
 2232 void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx)
 2233 {
 2234   user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
 2235 
 2236   memset (user_options_extra, 0, sizeof (user_options_extra_t));
 2237 }
 2238 
 2239 u64 user_options_extra_amplifier (hashcat_ctx_t *hashcat_ctx)
 2240 {
 2241   const combinator_ctx_t     *combinator_ctx     = hashcat_ctx->combinator_ctx;
 2242   const mask_ctx_t           *mask_ctx           = hashcat_ctx->mask_ctx;
 2243   const straight_ctx_t       *straight_ctx       = hashcat_ctx->straight_ctx;
 2244   const user_options_t       *user_options       = hashcat_ctx->user_options;
 2245   const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
 2246 
 2247   if (user_options->slow_candidates == true)
 2248   {
 2249     return 1;
 2250   }
 2251 
 2252   if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
 2253   {
 2254     if (straight_ctx->kernel_rules_cnt)
 2255     {
 2256       return straight_ctx->kernel_rules_cnt;
 2257     }
 2258   }
 2259   else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
 2260   {
 2261     if (combinator_ctx->combs_cnt)
 2262     {
 2263       return combinator_ctx->combs_cnt;
 2264     }
 2265   }
 2266   else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
 2267   {
 2268     if (mask_ctx->bfs_cnt)
 2269     {
 2270       return mask_ctx->bfs_cnt;
 2271     }
 2272   }
 2273 
 2274   return 1;
 2275 }
 2276 
 2277 int user_options_check_files (hashcat_ctx_t *hashcat_ctx)
 2278 {
 2279   dictstat_ctx_t       *dictstat_ctx       = hashcat_ctx->dictstat_ctx;
 2280   folder_config_t      *folder_config      = hashcat_ctx->folder_config;
 2281   logfile_ctx_t        *logfile_ctx        = hashcat_ctx->logfile_ctx;
 2282   outcheck_ctx_t       *outcheck_ctx       = hashcat_ctx->outcheck_ctx;
 2283   outfile_ctx_t        *outfile_ctx        = hashcat_ctx->outfile_ctx;
 2284   pidfile_ctx_t        *pidfile_ctx        = hashcat_ctx->pidfile_ctx;
 2285   potfile_ctx_t        *potfile_ctx        = hashcat_ctx->potfile_ctx;
 2286   user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
 2287   user_options_t       *user_options       = hashcat_ctx->user_options;
 2288 
 2289   // brain
 2290 
 2291   #ifdef WITH_BRAIN
 2292   if (user_options->brain_host)
 2293   {
 2294     struct addrinfo hints;
 2295 
 2296     memset (&hints, 0, sizeof (hints));
 2297 
 2298     hints.ai_family = AF_INET;
 2299     hints.ai_socktype = SOCK_STREAM;
 2300 
 2301     struct addrinfo *address_info = NULL;
 2302 
 2303     const int rc_getaddrinfo = getaddrinfo (user_options->brain_host, NULL, &hints, &address_info);
 2304 
 2305     if (rc_getaddrinfo != 0)
 2306     {
 2307       fprintf (stderr, "%s: %s\n", user_options->brain_host, gai_strerror (rc_getaddrinfo));
 2308 
 2309       return -1;
 2310     }
 2311 
 2312     freeaddrinfo (address_info);
 2313   }
 2314   #endif
 2315 
 2316   // common folders
 2317 
 2318   #if defined (_WIN)
 2319   if (hc_path_read (".") == false)
 2320   {
 2321     event_log_error (hashcat_ctx, "%s: %s", ".", strerror (errno));
 2322 
 2323     return -1;
 2324   }
 2325   #else
 2326   if (hc_path_read (folder_config->cwd) == false)
 2327   {
 2328     event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno));
 2329 
 2330     return -1;
 2331   }
 2332   #endif
 2333 
 2334   if (hc_path_read (folder_config->install_dir) == false)
 2335   {
 2336     event_log_error (hashcat_ctx, "%s: %s", folder_config->install_dir, strerror (errno));
 2337 
 2338     return -1;
 2339   }
 2340 
 2341   if (hc_path_read (folder_config->profile_dir) == false)
 2342   {
 2343     event_log_error (hashcat_ctx, "%s: %s", folder_config->profile_dir, strerror (errno));
 2344 
 2345     return -1;
 2346   }
 2347 
 2348   if (hc_path_write (folder_config->session_dir) == false)
 2349   {
 2350     event_log_error (hashcat_ctx, "%s: %s", folder_config->session_dir, strerror (errno));
 2351 
 2352     return -1;
 2353   }
 2354 
 2355   if (hc_path_read (folder_config->shared_dir) == false)
 2356   {
 2357     event_log_error (hashcat_ctx, "%s: %s", folder_config->shared_dir, strerror (errno));
 2358 
 2359     return -1;
 2360   }
 2361 
 2362   if (hc_path_read (folder_config->cpath_real) == false)
 2363   {
 2364     event_log_error (hashcat_ctx, "%s: %s", folder_config->cpath_real, strerror (errno));
 2365 
 2366     return -1;
 2367   }
 2368 
 2369   // hashfile - can be NULL
 2370 
 2371   if (user_options_extra->hc_hash != NULL)
 2372   {
 2373     if (hc_path_exist (user_options_extra->hc_hash) == true)
 2374     {
 2375       if (hc_path_is_directory (user_options_extra->hc_hash) == true)
 2376       {
 2377         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a hashfile argument.", user_options_extra->hc_hash);
 2378 
 2379         return -1;
 2380       }
 2381 
 2382       if (hc_path_read (user_options_extra->hc_hash) == false)
 2383       {
 2384         event_log_error (hashcat_ctx, "%s: %s", user_options_extra->hc_hash, strerror (errno));
 2385 
 2386         return -1;
 2387       }
 2388 
 2389       if (hc_path_has_bom (user_options_extra->hc_hash) == true)
 2390       {
 2391         event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", user_options_extra->hc_hash);
 2392 
 2393         //return -1;
 2394       }
 2395     }
 2396   }
 2397 
 2398   // arguments - checks must depend on attack_mode
 2399 
 2400   if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 2401   {
 2402     for (int i = 0; i < user_options_extra->hc_workc; i++)
 2403     {
 2404       char *wlfile = user_options_extra->hc_workv[i];
 2405 
 2406       if (hc_path_exist (wlfile) == false)
 2407       {
 2408         event_log_error (hashcat_ctx, "%s: %s", wlfile, strerror (errno));
 2409 
 2410         return -1;
 2411       }
 2412     }
 2413 
 2414     for (int i = 0; i < (int) user_options->rp_files_cnt; i++)
 2415     {
 2416       char *rp_file = user_options->rp_files[i];
 2417 
 2418       if (hc_path_exist (rp_file) == false)
 2419       {
 2420         event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno));
 2421 
 2422         return -1;
 2423       }
 2424 
 2425       if (hc_path_is_directory (rp_file) == true)
 2426       {
 2427         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a rulefile argument.", rp_file);
 2428 
 2429         return -1;
 2430       }
 2431 
 2432       if (hc_path_read (rp_file) == false)
 2433       {
 2434         event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno));
 2435 
 2436         return -1;
 2437       }
 2438 
 2439       if (hc_path_has_bom (rp_file) == true)
 2440       {
 2441         event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", rp_file);
 2442 
 2443         //return -1;
 2444       }
 2445     }
 2446   }
 2447   else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 2448   {
 2449     // mode easy mode here because both files must exist and readable
 2450 
 2451     if (user_options_extra->hc_workc == 2)
 2452     {
 2453       char *dictfile1 = user_options_extra->hc_workv[0];
 2454       char *dictfile2 = user_options_extra->hc_workv[1];
 2455 
 2456       if (hc_path_exist (dictfile1) == false)
 2457       {
 2458         event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
 2459 
 2460         return -1;
 2461       }
 2462 
 2463       if (hc_path_is_directory (dictfile1) == true)
 2464       {
 2465         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a wordlist argument.", dictfile1);
 2466 
 2467         return -1;
 2468       }
 2469 
 2470       if (hc_path_read (dictfile1) == false)
 2471       {
 2472         event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
 2473 
 2474         return -1;
 2475       }
 2476 
 2477       if (hc_path_has_bom (dictfile1) == true)
 2478       {
 2479         event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", dictfile1);
 2480 
 2481         //return -1;
 2482       }
 2483 
 2484       if (hc_path_exist (dictfile2) == false)
 2485       {
 2486         event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
 2487 
 2488         return -1;
 2489       }
 2490 
 2491       if (hc_path_is_directory (dictfile2) == true)
 2492       {
 2493         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a wordlist argument.", dictfile2);
 2494 
 2495         return -1;
 2496       }
 2497 
 2498       if (hc_path_read (dictfile2) == false)
 2499       {
 2500         event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
 2501 
 2502         return -1;
 2503       }
 2504 
 2505       if (hc_path_has_bom (dictfile2) == true)
 2506       {
 2507         event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", dictfile2);
 2508 
 2509         //return -1;
 2510       }
 2511     }
 2512   }
 2513   else if (user_options->attack_mode == ATTACK_MODE_BF)
 2514   {
 2515     // if the file exist it's a maskfile and then it must be readable
 2516 
 2517     if (user_options_extra->hc_workc == 1)
 2518     {
 2519       char *maskfile = user_options_extra->hc_workv[0];
 2520 
 2521       if (hc_path_exist (maskfile) == true)
 2522       {
 2523         if (hc_path_is_directory (maskfile) == true)
 2524         {
 2525           event_log_error (hashcat_ctx, "%s: A directory cannot be used as a maskfile argument.", maskfile);
 2526 
 2527           return -1;
 2528         }
 2529 
 2530         if (hc_path_read (maskfile) == false)
 2531         {
 2532           event_log_error (hashcat_ctx, "%s: %s", maskfile, strerror (errno));
 2533 
 2534           return -1;
 2535         }
 2536 
 2537         if (hc_path_has_bom (maskfile) == true)
 2538         {
 2539           event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", maskfile);
 2540 
 2541           //return -1;
 2542         }
 2543       }
 2544     }
 2545   }
 2546   else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 2547   {
 2548     if (user_options_extra->hc_workc == 2)
 2549     {
 2550       char *wlfile = user_options_extra->hc_workv[0];
 2551 
 2552       char *maskfile = user_options_extra->hc_workv[1];
 2553 
 2554       // for wordlist: can be folder
 2555 
 2556       if (hc_path_exist (wlfile) == false)
 2557       {
 2558         event_log_error (hashcat_ctx, "%s: %s", wlfile, strerror (errno));
 2559 
 2560         return -1;
 2561       }
 2562 
 2563       // for mask: if the file exist it's a maskfile and then it must be readable
 2564 
 2565       if (hc_path_exist (maskfile) == true)
 2566       {
 2567         if (hc_path_is_directory (maskfile) == true)
 2568         {
 2569           event_log_error (hashcat_ctx, "%s: A directory cannot be used as a maskfile argument.", maskfile);
 2570 
 2571           return -1;
 2572         }
 2573 
 2574         if (hc_path_read (maskfile) == false)
 2575         {
 2576           event_log_error (hashcat_ctx, "%s: %s", maskfile, strerror (errno));
 2577 
 2578           return -1;
 2579         }
 2580 
 2581         if (hc_path_has_bom (maskfile) == true)
 2582         {
 2583           event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", maskfile);
 2584 
 2585           //return -1;
 2586         }
 2587       }
 2588     }
 2589   }
 2590   else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 2591   {
 2592     if (user_options_extra->hc_workc == 2)
 2593     {
 2594       char *wlfile = user_options_extra->hc_workv[1];
 2595 
 2596       char *maskfile = user_options_extra->hc_workv[0];
 2597 
 2598       // for wordlist: can be folder
 2599 
 2600       if (hc_path_exist (wlfile) == false)
 2601       {
 2602         event_log_error (hashcat_ctx, "%s: %s", wlfile, strerror (errno));
 2603 
 2604         return -1;
 2605       }
 2606 
 2607       // for mask: if the file exist it's a maskfile and then it must be readable
 2608 
 2609       if (hc_path_exist (maskfile) == true)
 2610       {
 2611         if (hc_path_is_directory (maskfile) == true)
 2612         {
 2613           event_log_error (hashcat_ctx, "%s: A directory cannot be used as a maskfile argument.", maskfile);
 2614 
 2615           return -1;
 2616         }
 2617 
 2618         if (hc_path_read (maskfile) == false)
 2619         {
 2620           event_log_error (hashcat_ctx, "%s: %s", maskfile, strerror (errno));
 2621 
 2622           return -1;
 2623         }
 2624 
 2625         if (hc_path_has_bom (maskfile) == true)
 2626         {
 2627           event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", maskfile);
 2628 
 2629           //return -1;
 2630         }
 2631       }
 2632     }
 2633   }
 2634   else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 2635   {
 2636     for (int i = 0; i < user_options_extra->hc_workc; i++)
 2637     {
 2638       char *wlfile = user_options_extra->hc_workv[i];
 2639 
 2640       if (hc_path_exist (wlfile) == false)
 2641       {
 2642         event_log_error (hashcat_ctx, "%s: %s", wlfile, strerror (errno));
 2643 
 2644         return -1;
 2645       }
 2646     }
 2647 
 2648     for (int i = 0; i < (int) user_options->rp_files_cnt; i++)
 2649     {
 2650       char *rp_file = user_options->rp_files[i];
 2651 
 2652       if (hc_path_exist (rp_file) == false)
 2653       {
 2654         event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno));
 2655 
 2656         return -1;
 2657       }
 2658 
 2659       if (hc_path_is_directory (rp_file) == true)
 2660       {
 2661         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a rulefile argument.", rp_file);
 2662 
 2663         return -1;
 2664       }
 2665 
 2666       if (hc_path_read (rp_file) == false)
 2667       {
 2668         event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno));
 2669 
 2670         return -1;
 2671       }
 2672 
 2673       if (hc_path_has_bom (rp_file) == true)
 2674       {
 2675         event_log_warning (hashcat_ctx, "%s: Byte Order Mark (BOM) was detected", rp_file);
 2676 
 2677         //return -1;
 2678       }
 2679     }
 2680   }
 2681 
 2682   // logfile
 2683 
 2684   if (logfile_ctx->enabled == true)
 2685   {
 2686     if (hc_path_exist (logfile_ctx->logfile) == true)
 2687     {
 2688       if (hc_path_is_directory (logfile_ctx->logfile) == true)
 2689       {
 2690         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a logfile argument.", logfile_ctx->logfile);
 2691 
 2692         return -1;
 2693       }
 2694 
 2695       if (hc_path_write (logfile_ctx->logfile) == false)
 2696       {
 2697         event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
 2698 
 2699         return -1;
 2700       }
 2701     }
 2702     else
 2703     {
 2704       if (hc_path_create (logfile_ctx->logfile) == false)
 2705       {
 2706         event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
 2707 
 2708         return -1;
 2709       }
 2710     }
 2711   }
 2712 
 2713   // outfile_check
 2714 
 2715   if (outcheck_ctx->enabled == true)
 2716   {
 2717     if (hc_path_exist (outcheck_ctx->root_directory) == true)
 2718     {
 2719       if (hc_path_is_directory (outcheck_ctx->root_directory) == false)
 2720       {
 2721         event_log_error (hashcat_ctx, "Directory specified in outfile-check '%s' is not a directory.", outcheck_ctx->root_directory);
 2722 
 2723         return -1;
 2724       }
 2725     }
 2726   }
 2727 
 2728   // outfile - can be NULL
 2729 
 2730   if (outfile_ctx->filename != NULL)
 2731   {
 2732     if (hc_path_exist (outfile_ctx->filename) == true)
 2733     {
 2734       if (hc_path_is_directory (outfile_ctx->filename) == true)
 2735       {
 2736         event_log_error (hashcat_ctx, "%s: A directory cannot be used as an outfile.", outfile_ctx->filename);
 2737 
 2738         return -1;
 2739       }
 2740 
 2741       if (hc_path_write (outfile_ctx->filename) == false)
 2742       {
 2743         event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
 2744 
 2745         return -1;
 2746       }
 2747     }
 2748     else
 2749     {
 2750       if (hc_path_create (outfile_ctx->filename) == false)
 2751       {
 2752         event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
 2753 
 2754         return -1;
 2755       }
 2756     }
 2757   }
 2758 
 2759   // check for outfile vs. hashfile
 2760 
 2761   if (hc_same_files (outfile_ctx->filename, user_options_extra->hc_hash) == true)
 2762   {
 2763     event_log_error (hashcat_ctx, "Outfile and hashfile cannot point to the same file.");
 2764 
 2765     return -1;
 2766   }
 2767 
 2768   // check for outfile vs. cached wordlists
 2769 
 2770   if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
 2771   {
 2772     for (int i = 0; i < user_options_extra->hc_workc; i++)
 2773     {
 2774       char *wlfile = user_options_extra->hc_workv[i];
 2775 
 2776       if (hc_same_files (outfile_ctx->filename, wlfile) == true)
 2777       {
 2778         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2779 
 2780         return -1;
 2781       }
 2782     }
 2783   }
 2784   else if (user_options->attack_mode == ATTACK_MODE_COMBI)
 2785   {
 2786     if (user_options_extra->hc_workc == 2)
 2787     {
 2788       char *dictfile1 = user_options_extra->hc_workv[0];
 2789       char *dictfile2 = user_options_extra->hc_workv[1];
 2790 
 2791       if (hc_same_files (outfile_ctx->filename, dictfile1) == true)
 2792       {
 2793         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2794 
 2795         return -1;
 2796       }
 2797 
 2798       if (hc_same_files (outfile_ctx->filename, dictfile2) == true)
 2799       {
 2800         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2801 
 2802         return -1;
 2803       }
 2804     }
 2805   }
 2806   else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
 2807   {
 2808     if (user_options_extra->hc_workc == 2)
 2809     {
 2810       char *wlfile = user_options_extra->hc_workv[0];
 2811 
 2812       if (hc_same_files (outfile_ctx->filename, wlfile) == true)
 2813       {
 2814         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2815 
 2816         return -1;
 2817       }
 2818     }
 2819   }
 2820   else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
 2821   {
 2822     if (user_options_extra->hc_workc == 2)
 2823     {
 2824       char *wlfile = user_options_extra->hc_workv[1];
 2825 
 2826       if (hc_same_files (outfile_ctx->filename, wlfile) == true)
 2827       {
 2828         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2829 
 2830         return -1;
 2831       }
 2832     }
 2833   }
 2834   else if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)
 2835   {
 2836     for (int i = 0; i < user_options_extra->hc_workc; i++)
 2837     {
 2838       char *wlfile = user_options_extra->hc_workv[i];
 2839 
 2840       if (hc_same_files (outfile_ctx->filename, wlfile) == true)
 2841       {
 2842         event_log_error (hashcat_ctx, "Outfile and wordlist cannot point to the same file.");
 2843 
 2844         return -1;
 2845       }
 2846     }
 2847   }
 2848 
 2849   // pidfile
 2850 
 2851   if (hc_path_exist (pidfile_ctx->filename) == true)
 2852   {
 2853     if (hc_path_is_directory (pidfile_ctx->filename) == true)
 2854     {
 2855       event_log_error (hashcat_ctx, "%s: A directory cannot be used as a pidfile argument.", pidfile_ctx->filename);
 2856 
 2857       return -1;
 2858     }
 2859 
 2860     if (hc_path_write (pidfile_ctx->filename) == false)
 2861     {
 2862       event_log_error (hashcat_ctx, "%s: %s", pidfile_ctx->filename, strerror (errno));
 2863 
 2864       return -1;
 2865     }
 2866   }
 2867   else
 2868   {
 2869     if (hc_path_create (pidfile_ctx->filename) == false)
 2870     {
 2871       event_log_error (hashcat_ctx, "%s: %s", pidfile_ctx->filename, strerror (errno));
 2872 
 2873       return -1;
 2874     }
 2875   }
 2876 
 2877   // potfile
 2878 
 2879   if (potfile_ctx->enabled == true)
 2880   {
 2881     if (hc_path_exist (potfile_ctx->filename) == true)
 2882     {
 2883       if (hc_path_is_directory (potfile_ctx->filename) == true)
 2884       {
 2885         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a potfile argument.", potfile_ctx->filename);
 2886 
 2887         return -1;
 2888       }
 2889 
 2890       if (hc_path_write (potfile_ctx->filename) == false)
 2891       {
 2892         event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
 2893 
 2894         return -1;
 2895       }
 2896     }
 2897     else
 2898     {
 2899       if (hc_path_create (potfile_ctx->filename) == false)
 2900       {
 2901         event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
 2902 
 2903         return -1;
 2904       }
 2905     }
 2906   }
 2907 
 2908   // dictstat
 2909 
 2910   if (dictstat_ctx->enabled == true)
 2911   {
 2912     if (hc_path_exist (dictstat_ctx->filename) == true)
 2913     {
 2914       if (hc_path_is_directory (dictstat_ctx->filename) == true)
 2915       {
 2916         event_log_error (hashcat_ctx, "%s: A directory cannot be used as a dictstat argument.", dictstat_ctx->filename);
 2917 
 2918         return -1;
 2919       }
 2920 
 2921       if (hc_path_write (dictstat_ctx->filename) == false)
 2922       {
 2923         event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
 2924 
 2925         return -1;
 2926       }
 2927     }
 2928     else
 2929     {
 2930       if (hc_path_create (dictstat_ctx->filename) == false)
 2931       {
 2932         event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
 2933 
 2934         return -1;
 2935       }
 2936     }
 2937   }
 2938 
 2939   // single kernel and module existence check to detect "7z e" errors
 2940 
 2941   char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY);
 2942 
 2943   module_filename (folder_config, 0, modulefile, HCBUFSIZ_TINY);
 2944 
 2945   if (hc_path_exist (modulefile) == false)
 2946   {
 2947     event_log_error (hashcat_ctx, "%s: %s", modulefile, strerror (errno));
 2948 
 2949     event_log_warning (hashcat_ctx, "If you are using the hashcat binary package, this may be an extraction issue.");
 2950     event_log_warning (hashcat_ctx, "For example, using \"7z e\" instead of using \"7z x\".");
 2951     event_log_warning (hashcat_ctx, NULL);
 2952 
 2953     hcfree (modulefile);
 2954 
 2955     return -1;
 2956   }
 2957 
 2958   hcfree (modulefile);
 2959 
 2960   const bool quiet_save = user_options->quiet;
 2961 
 2962   user_options->quiet = true;
 2963 
 2964   const int rc = hashconfig_init (hashcat_ctx);
 2965 
 2966   user_options->quiet = quiet_save;
 2967 
 2968   if (rc == -1) return -1;
 2969 
 2970   hashconfig_destroy (hashcat_ctx);
 2971 
 2972   // same check but for an backend kernel
 2973 
 2974   char *kernelfile = (char *) hcmalloc (HCBUFSIZ_TINY);
 2975 
 2976   generate_source_kernel_filename (false, ATTACK_EXEC_OUTSIDE_KERNEL, ATTACK_KERN_STRAIGHT, 400, 0, folder_config->shared_dir, kernelfile);
 2977 
 2978   if (hc_path_read (kernelfile) == false)
 2979   {
 2980     event_log_error (hashcat_ctx, "%s: %s", kernelfile, strerror (errno));
 2981 
 2982     event_log_warning (hashcat_ctx, "If you are using the hashcat binary package, this may be an extraction issue.");
 2983     event_log_warning (hashcat_ctx, "For example, using \"7z e\" instead of using \"7z x\".");
 2984     event_log_warning (hashcat_ctx, NULL);
 2985 
 2986     hcfree (kernelfile);
 2987 
 2988     return -1;
 2989   }
 2990 
 2991   hcfree (kernelfile);
 2992 
 2993   // loopback - can't check at this point
 2994 
 2995   // tuning file check already done
 2996 
 2997   // debugfile check already done
 2998 
 2999   // dictstat
 3000 
 3001   if (user_options->keyboard_layout_mapping != NULL)
 3002   {
 3003     if (hc_path_exist (user_options->keyboard_layout_mapping) == true)
 3004     {
 3005       if (hc_path_read (user_options->keyboard_layout_mapping) == false)
 3006       {
 3007         event_log_error (hashcat_ctx, "%s: %s", user_options->keyboard_layout_mapping, strerror (errno));
 3008 
 3009         return -1;
 3010       }
 3011     }
 3012     else
 3013     {
 3014       event_log_error (hashcat_ctx, "%s: %s", user_options->keyboard_layout_mapping, strerror (errno));
 3015 
 3016       return -1;
 3017     }
 3018   }
 3019 
 3020   /**
 3021    * default building options
 3022    */
 3023 
 3024   /* temporary disabled due to https://github.com/hashcat/hashcat/issues/2379
 3025   if (chdir (folder_config->cpath_real) == -1)
 3026   {
 3027     event_log_error (hashcat_ctx, "%s: %s", folder_config->cpath_real, strerror (errno));
 3028 
 3029     return -1;
 3030   }
 3031   */
 3032 
 3033   // include check
 3034   // this test needs to be done manually because of macOS opencl runtime
 3035   // if there's a problem with permission, its not reporting back and erroring out silently
 3036 
 3037   const char *files_names[] =
 3038   {
 3039     "inc_cipher_aes.cl",
 3040     "inc_cipher_serpent.cl",
 3041     "inc_cipher_twofish.cl",
 3042     "inc_common.cl",
 3043     "inc_comp_multi_bs.cl",
 3044     "inc_comp_multi.cl",
 3045     "inc_comp_single_bs.cl",
 3046     "inc_comp_single.cl",
 3047     "inc_rp_optimized.cl",
 3048     "inc_rp_optimized.h",
 3049     "inc_simd.cl",
 3050     "inc_scalar.cl",
 3051     "inc_types.h",
 3052     "inc_vendor.h",
 3053     NULL
 3054   };
 3055 
 3056   for (int i = 0; files_names[i] != NULL; i++)
 3057   {
 3058     char *temp_filename = NULL;
 3059 
 3060     hc_asprintf (&temp_filename, "%s/%s", folder_config->cpath_real, files_names[i]);
 3061 
 3062     if (hc_path_read (temp_filename) == false)
 3063     {
 3064       event_log_error (hashcat_ctx, "%s: %s", temp_filename, strerror (errno));
 3065 
 3066       hcfree (temp_filename);
 3067 
 3068       return -1;
 3069     }
 3070 
 3071     hcfree (temp_filename);
 3072   }
 3073 
 3074   // return back to the folder we came from initially (workaround)
 3075 
 3076   /* temporary disabled due to https://github.com/hashcat/hashcat/issues/2379
 3077   #if defined (_WIN)
 3078   if (chdir ("..") == -1)
 3079   {
 3080     event_log_error (hashcat_ctx, "%s: %s", "..", strerror (errno));
 3081 
 3082     return -1;
 3083   }
 3084   #else
 3085   if (chdir (folder_config->cwd) == -1)
 3086   {
 3087     event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno));
 3088 
 3089     return -1;
 3090   }
 3091   #endif
 3092   */
 3093 
 3094   return 0;
 3095 }
 3096 
 3097 void user_options_logger (hashcat_ctx_t *hashcat_ctx)
 3098 {
 3099   user_options_t *user_options = hashcat_ctx->user_options;
 3100   logfile_ctx_t  *logfile_ctx  = hashcat_ctx->logfile_ctx;
 3101 
 3102   #ifdef WITH_BRAIN
 3103   logfile_top_string (user_options->brain_session_whitelist);
 3104   #endif
 3105   logfile_top_string (user_options->cpu_affinity);
 3106   logfile_top_string (user_options->custom_charset_1);
 3107   logfile_top_string (user_options->custom_charset_2);
 3108   logfile_top_string (user_options->custom_charset_3);
 3109   logfile_top_string (user_options->custom_charset_4);
 3110   logfile_top_string (user_options->debug_file);
 3111   logfile_top_string (user_options->encoding_from);
 3112   logfile_top_string (user_options->encoding_to);
 3113   logfile_top_string (user_options->induction_dir);
 3114   logfile_top_string (user_options->keyboard_layout_mapping);
 3115   logfile_top_string (user_options->markov_hcstat2);
 3116   logfile_top_string (user_options->backend_devices);
 3117   logfile_top_string (user_options->opencl_device_types);
 3118   logfile_top_string (user_options->outfile);
 3119   logfile_top_string (user_options->outfile_check_dir);
 3120   logfile_top_string (user_options->potfile_path);
 3121   logfile_top_string (user_options->restore_file_path);
 3122   logfile_top_string (user_options->rp_files[0]);
 3123   logfile_top_string (user_options->rp_gen_func_sel);
 3124   logfile_top_string (user_options->rule_buf_l);
 3125   logfile_top_string (user_options->rule_buf_r);
 3126   logfile_top_string (user_options->session);
 3127   logfile_top_string (user_options->separator);
 3128   logfile_top_string (user_options->truecrypt_keyfiles);
 3129   logfile_top_string (user_options->veracrypt_keyfiles);
 3130   #ifdef WITH_BRAIN
 3131   logfile_top_string (user_options->brain_host);
 3132   #endif
 3133   logfile_top_uint64 (user_options->limit);
 3134   logfile_top_uint64 (user_options->skip);
 3135   logfile_top_uint   (user_options->attack_mode);
 3136   logfile_top_uint   (user_options->benchmark);
 3137   logfile_top_uint   (user_options->benchmark_all);
 3138   logfile_top_uint   (user_options->bitmap_max);
 3139   logfile_top_uint   (user_options->bitmap_min);
 3140   logfile_top_uint   (user_options->debug_mode);
 3141   logfile_top_uint   (user_options->hash_info);
 3142   logfile_top_uint   (user_options->force);
 3143   logfile_top_uint   (user_options->hwmon_disable);
 3144   logfile_top_uint   (user_options->hwmon_temp_abort);
 3145   logfile_top_uint   (user_options->hash_mode);
 3146   logfile_top_uint   (user_options->hex_charset);
 3147   logfile_top_uint   (user_options->hex_salt);
 3148   logfile_top_uint   (user_options->hex_wordlist);
 3149   logfile_top_uint   (user_options->hook_threads);
 3150   logfile_top_uint   (user_options->identify);
 3151   logfile_top_uint   (user_options->increment);
 3152   logfile_top_uint   (user_options->increment_max);
 3153   logfile_top_uint   (user_options->increment_min);
 3154   logfile_top_uint   (user_options->keep_guessing);
 3155   logfile_top_uint   (user_options->kernel_accel);
 3156   logfile_top_uint   (user_options->kernel_loops);
 3157   logfile_top_uint   (user_options->kernel_threads);
 3158   logfile_top_uint   (user_options->keyspace);
 3159   logfile_top_uint   (user_options->left);
 3160   logfile_top_uint   (user_options->logfile_disable);
 3161   logfile_top_uint   (user_options->loopback);
 3162   logfile_top_uint   (user_options->machine_readable);
 3163   logfile_top_uint   (user_options->markov_classic);
 3164   logfile_top_uint   (user_options->markov_disable);
 3165   logfile_top_uint   (user_options->markov_inverse);
 3166   logfile_top_uint   (user_options->markov_threshold);
 3167   logfile_top_uint   (user_options->multiply_accel_disable);
 3168   logfile_top_uint   (user_options->backend_info);
 3169   logfile_top_uint   (user_options->backend_vector_width);
 3170   logfile_top_uint   (user_options->optimized_kernel_enable);
 3171   logfile_top_uint   (user_options->outfile_autohex);
 3172   logfile_top_uint   (user_options->outfile_check_timer);
 3173   logfile_top_uint   (user_options->outfile_format);
 3174   logfile_top_uint   (user_options->wordlist_autohex_disable);
 3175   logfile_top_uint   (user_options->potfile_disable);
 3176   logfile_top_uint   (user_options->progress_only);
 3177   logfile_top_uint   (user_options->quiet);
 3178   logfile_top_uint   (user_options->remove);
 3179   logfile_top_uint   (user_options->remove_timer);
 3180   logfile_top_uint   (user_options->restore);
 3181   logfile_top_uint   (user_options->restore_disable);
 3182   logfile_top_uint   (user_options->restore_timer);
 3183   logfile_top_uint   (user_options->rp_files_cnt);
 3184   logfile_top_uint   (user_options->rp_gen);
 3185   logfile_top_uint   (user_options->rp_gen_func_max);
 3186   logfile_top_uint   (user_options->rp_gen_func_min);
 3187   logfile_top_uint   (user_options->rp_gen_seed);
 3188   logfile_top_uint   (user_options->runtime);
 3189   logfile_top_uint   (user_options->scrypt_tmto);
 3190   logfile_top_uint   (user_options->segment_size);
 3191   logfile_top_uint   (user_options->self_test_disable);
 3192   logfile_top_uint   (user_options->slow_candidates);
 3193   logfile_top_uint   (user_options->show);
 3194   logfile_top_uint   (user_options->speed_only);
 3195   logfile_top_uint   (user_options->spin_damp);
 3196   logfile_top_uint   (user_options->status);
 3197   logfile_top_uint   (user_options->status_json);
 3198   logfile_top_uint   (user_options->status_timer);
 3199   logfile_top_uint   (user_options->stdout_flag);
 3200   logfile_top_uint   (user_options->usage);
 3201   logfile_top_uint   (user_options->username);
 3202   logfile_top_uint   (user_options->veracrypt_pim_start);
 3203   logfile_top_uint   (user_options->veracrypt_pim_stop);
 3204   logfile_top_uint   (user_options->version);
 3205   logfile_top_uint   (user_options->workload_profile);
 3206   #ifdef WITH_BRAIN
 3207   logfile_top_uint   (user_options->brain_client);
 3208   logfile_top_uint   (user_options->brain_client_features);
 3209   logfile_top_uint   (user_options->brain_server);
 3210   logfile_top_uint   (user_options->brain_server_timer);
 3211   logfile_top_uint   (user_options->brain_port);
 3212   logfile_top_uint   (user_options->brain_session);
 3213   #endif
 3214 }