1 /* 2 * This file is part of John the Ripper password cracker, 3 * Copyright (c) 1996-98,2003,2006,2013 by Solar Designer 4 * 5 * ...with changes in the jumbo patch, by JimF and magnum (and various others?) 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted. 9 * 10 * There's ABSOLUTELY NO WARRANTY, express or implied. 11 */ 12 13 /* 14 * John's command line options definition. 15 */ 16 17 #ifndef _JOHN_OPTIONS_H 18 #define _JOHN_OPTIONS_H 19 20 #if AC_BUILT 21 #include "autoconfig.h" 22 #endif 23 24 #include "list.h" 25 #include "loader.h" 26 #include "getopt.h" 27 #include "john_mpi.h" 28 29 /* 30 * Core Option flags bitmasks (low 32 bits): 31 */ 32 /* An action requested */ 33 #define FLG_ACTION 0x00000001 34 /* Password files specified */ 35 #define FLG_PASSWD 0x00000002 36 /* An option supports password files */ 37 #define FLG_PWD_SUP 0x00000004 38 /* An option requires password files */ 39 #define FLG_PWD_REQ (0x00000008 | FLG_PWD_SUP) 40 /* Some option that doesn't have its own flag is specified */ 41 #define FLG_NONE 0x00000010 42 /* A cracking mode enabled */ 43 #define FLG_CRACKING_CHK 0x00000020 44 #define FLG_CRACKING_SUP 0x00000040 45 #define FLG_CRACKING_SET \ 46 (FLG_CRACKING_CHK | FLG_CRACKING_SUP | FLG_ACTION | FLG_PWD_REQ) 47 /* Wordlist mode enabled, options.wordlist is set to the file name, or 48 * we get it from john.conf */ 49 #define FLG_WORDLIST_CHK 0x00000080 50 #define FLG_WORDLIST_SET \ 51 (FLG_WORDLIST_CHK | FLG_CRACKING_SET | FLG_RULES_ALLOW) 52 /* Wordlist mode enabled, reading from stdin */ 53 #define FLG_STDIN_CHK 0x00000100 54 #define FLG_STDIN_SET (FLG_STDIN_CHK | FLG_WORDLIST_SET) 55 /* Wordlist rules enabled */ 56 #define FLG_RULES 0x00000200 57 /* "Single crack" mode enabled */ 58 #define FLG_SINGLE_CHK 0x00000400 59 #define FLG_SINGLE_SET (FLG_SINGLE_CHK | FLG_CRACKING_SET) 60 /* Incremental mode enabled */ 61 #define FLG_INC_CHK 0x00000800 62 #define FLG_INC_SET (FLG_INC_CHK | FLG_CRACKING_SET) 63 /* Mask mode enabled (might be hybrid) */ 64 #define FLG_MASK_CHK 0x00001000 65 #define FLG_MASK_SET \ 66 (FLG_MASK_CHK | FLG_ACTION | FLG_CRACKING_SUP | FLG_PWD_SUP) 67 /* External mode or word filter enabled */ 68 #define FLG_EXTERNAL_CHK 0x00002000 69 #define FLG_EXTERNAL_SET \ 70 (FLG_EXTERNAL_CHK | FLG_ACTION | FLG_CRACKING_SUP | FLG_PWD_SUP) 71 /* Batch cracker */ 72 #define FLG_BATCH_CHK 0x00004000 73 #define FLG_BATCH_SET (FLG_BATCH_CHK | FLG_CRACKING_SET) 74 /* Stdout mode */ 75 #define FLG_STDOUT 0x00008000 76 /* Restoring an interrupted session */ 77 #define FLG_RESTORE_CHK 0x00010000 78 #define FLG_RESTORE_SET (FLG_RESTORE_CHK | FLG_ACTION) 79 /* A session name is set */ 80 #define FLG_SESSION 0x00020000 81 /* Print status of a session */ 82 #define FLG_STATUS_CHK 0x00040000 83 #define FLG_STATUS_SET (FLG_STATUS_CHK | FLG_ACTION) 84 /* Make a charset */ 85 #define FLG_MAKECHR_CHK 0x00100000 86 #define FLG_MAKECHR_SET \ 87 (FLG_MAKECHR_CHK | FLG_ACTION | FLG_PWD_SUP) 88 /* Show cracked passwords */ 89 #define FLG_SHOW_CHK 0x00200000 90 #define FLG_SHOW_SET \ 91 (FLG_SHOW_CHK | FLG_ACTION | FLG_PWD_REQ) 92 /* Perform a benchmark */ 93 #define FLG_TEST_CHK 0x00400000 94 #define FLG_TEST_SET \ 95 (FLG_TEST_CHK | FLG_CRACKING_SUP | FLG_ACTION) 96 #ifdef HAVE_FUZZ 97 /* Perform a fuzzing */ 98 #define FLG_FUZZ_CHK 0x08000000 99 #define FLG_FUZZ_SET \ 100 (FLG_FUZZ_CHK | FLG_CRACKING_SUP | FLG_ACTION) 101 /* Dump fuzzed hashes */ 102 #define FLG_FUZZ_DUMP_CHK 0x40000000 103 #define FLG_FUZZ_DUMP_SET \ 104 (FLG_FUZZ_DUMP_CHK | FLG_CRACKING_SUP | FLG_ACTION) 105 #endif 106 /* Passwords per salt requested */ 107 #define FLG_SALTS 0x01000000 108 /* Ciphertext format forced */ 109 #define FLG_FORMAT 0x02000000 110 /* Memory saving enabled */ 111 #define FLG_SAVEMEM 0x04000000 112 /* Node number(s) specified */ 113 #define FLG_NODE 0x10000000 114 /* fork() requested, and process count specified */ 115 #define FLG_FORK 0x20000000 116 117 /* Note that 0x80000000 is taken for OPT_REQ_PARAM, see getopt.h */ 118 119 /* 120 * Jumbo Options flags bitmasks (high 32 bits) 121 * 122 * Tip: For your private patches, pick first free from MSB. When 123 * sharing your patch, pick first free from LSB of high 32 bits. 124 * 125 * In Jumbo, the combination flg_set == FLG_ZERO and req_clr == OPT_REQ_PARAM 126 * gets dupe checking automatically, without a specific flag. 127 */ 128 #define FLG_ZERO 0x0 129 130 /* .pot file used as wordlist, options.wordlist is set to the file name, or 131 * we use the active .pot file */ 132 #define FLG_LOOPBACK_CHK 0x0000000100000000ULL 133 #define FLG_LOOPBACK_SET \ 134 (FLG_LOOPBACK_CHK | FLG_WORDLIST_SET | FLG_CRACKING_SET | FLG_DUPESUPP) 135 /* pipe mode enabled, reading from stdin with rules support */ 136 #define FLG_PIPE_CHK 0x0000000200000000ULL 137 #define FLG_PIPE_SET (FLG_PIPE_CHK | FLG_WORDLIST_SET) 138 /* Dynamic load of foreign format module */ 139 #define FLG_DYNFMT 0x0000000400000000ULL 140 /* Turn off logging */ 141 #define FLG_NOLOG 0x0000000800000000ULL 142 /* Log to stderr */ 143 #define FLG_LOG_STDERR 0x0000001000000000ULL 144 /* Markov mode enabled */ 145 #define FLG_MKV_CHK 0x0000002000000000ULL 146 #define FLG_MKV_SET (FLG_MKV_CHK | FLG_CRACKING_SET) 147 /* Emit a status line for every password cracked */ 148 #define FLG_CRKSTAT 0x0000004000000000ULL 149 /* Wordlist dupe suppression */ 150 #define FLG_DUPESUPP 0x0000008000000000ULL 151 /* Force scalar mode */ 152 #define FLG_SCALAR 0x0000010000000000ULL 153 #define FLG_VECTOR 0x0000020000000000ULL 154 /* Reject printable binaries */ 155 #define FLG_REJECT_PRINTABLE 0x0000040000000000ULL 156 /* Skip self tests */ 157 #define FLG_NOTESTS 0x0000080000000000ULL 158 /* Regex cracking mode */ 159 #define FLG_REGEX_CHK 0x0000100000000000ULL 160 #define FLG_REGEX_SET \ 161 (FLG_REGEX_CHK | FLG_ACTION | FLG_CRACKING_SUP | FLG_PWD_SUP) 162 /* Encodings. You can only give one of --internal-enc or --target-enc */ 163 #define FLG_INPUT_ENC 0x0000200000000000ULL 164 #define FLG_SECOND_ENC 0x0000400000000000ULL 165 /* --verbosity */ 166 #define FLG_VERBOSITY 0x0000800000000000ULL 167 /* Sets FMT_NOT_EXACT, searching for cleartext collisions */ 168 #define FLG_KEEP_GUESSING 0x0001000000000000ULL 169 /* Loops self-test forever */ 170 #define FLG_LOOPTEST 0x0002000000000000ULL 171 /* Mask mode is stacked */ 172 #define FLG_MASK_STACKED 0x0004000000000000ULL 173 /* Stacking modes */ 174 #define FLG_STACKING (FLG_MASK_CHK | FLG_REGEX_CHK) 175 /* Any stacking mode is active */ 176 #define FLG_STACKED (FLG_MASK_STACKED | FLG_REGEX_STACKED) 177 /* PRINCE mode enabled, options.wordlist is set to the file name, or 178 * we get it from john.conf */ 179 #define FLG_PRINCE_CHK 0x0008000000000000ULL 180 #define FLG_PRINCE_SET \ 181 (FLG_PRINCE_CHK | FLG_CRACKING_SET | FLG_RULES_ALLOW) 182 #define FLG_PRINCE_DIST 0x0010000000000000ULL 183 #define FLG_PRINCE_KEYSPACE 0x0020000000000000ULL 184 #define FLG_PRINCE_CASE_PERMUTE 0x0040000000000000ULL 185 #define FLG_PRINCE_LOOPBACK 0x0080000000000000ULL 186 #define FLG_PRINCE_MMAP 0x0100000000000000ULL 187 #define FLG_RULES_ALLOW 0x0200000000000000ULL 188 #define FLG_REGEX_STACKED 0x0400000000000000ULL 189 /* Subsets cracking mode */ 190 #define FLG_SUBSETS_CHK 0x0800000000000000ULL 191 #define FLG_SUBSETS_SET \ 192 (FLG_SUBSETS_CHK | FLG_CRACKING_SET) 193 194 /* 195 * Macro for getting correct node number regardless of if MPI or not 196 */ 197 #if HAVE_MPI 198 #define NODE (mpi_p > 1 ? mpi_id + 1 : options.node_min) 199 #else 200 #define NODE options.node_min 201 #endif 202 203 /* 204 * Structure with option flags and all the parameters. 205 */ 206 struct options_main { 207 /* Option flags */ 208 opt_flags flags; 209 210 /* Password files */ 211 struct list_main *passwd; 212 213 /* Password file loader options */ 214 struct db_options loader; 215 216 /* Session name */ 217 char *session; 218 219 /* Ciphertext format name */ 220 char *format; 221 222 /* Wordlist file name */ 223 char *wordlist; 224 225 /* Incremental mode name or charset file name */ 226 const char *charset; 227 228 /* External mode or word filter name */ 229 char *external; 230 231 /* Maximum plaintext length for stdout mode */ 232 int length; 233 234 /* Parallel processing options */ 235 char *node_str; 236 unsigned int node_min, node_max, node_count, fork; 237 238 /* 239 * ---- Jumbo options below this point ---- 240 * Do NOT place any new Jumbo stuff above 'subformat'. It's used to 241 * calculate offset for a memset at resuming a session. 242 */ 243 244 /* Ciphertext subformat name */ 245 char *subformat; 246 247 /* Single mode seed word (--single-seed) */ 248 char *seed_word; 249 250 /* Single mode seed wordlist file name (--single-wordlist) */ 251 char *seed_file; 252 253 /* Override config's SingleRetestGuess */ 254 char *single_retest_guess; 255 256 /* Configuration file name */ 257 char *config; 258 259 /* Markov stuff */ 260 char *mkv_param; 261 char *mkv_stats; 262 263 #ifdef HAVE_FUZZ 264 /* Fuzz dictionary file name */ 265 char *fuzz_dic; 266 267 /* Fuzz dump hashes between from and to */ 268 char *fuzz_dump; 269 #endif 270 271 /* Mask mode's requested mask (as given) */ 272 char *mask; 273 274 /* Mask mode's effective mask (as used, may be default from john.conf etc.) */ 275 char *eff_mask; 276 277 /* Can't use HAVE_WINDOWS_H here so the below need to be maintained */ 278 #if defined (_MSC_VER) || defined (__MINGW32__) || defined (__CYGWIN32__) 279 /* if built for Win32, then the pipe/stdin is VERY slow. We allow special 280 * processing to use the pipe command, but in a -pipe=sharedmemoryfilename 281 * so that the producer app, and JtR can be written to work properly with 282 * named shared memory, which is MUCH faster than using a pipe to xfer data 283 * between the 2 apps. */ 284 char *sharedmemoryfilename; 285 #endif 286 287 /* Maximum size of a wordlist file to be 'preloaded' into memory */ 288 size_t max_wordfile_memory; 289 290 /* number of times fix_state_delay is called in wordlist.c before any fseek() 291 is done. */ 292 unsigned int max_fix_state_delay; 293 294 /* In general, an encoding of 0 (CP_UNDEF) means no conversion and we will 295 behave more or less like core John. */ 296 297 /* Currently initialized non-utf8 encoding */ 298 int unicode_cp; 299 300 /* Input encoding for word lists, and/or pot file clear-texts. */ 301 int input_enc; 302 303 /* Replacement character for "EmulateBrokenEncoding" feature. */ 304 unsigned char replacement_character; 305 306 /* True if encoding was set from john.conf as opposed to command line. */ 307 int default_enc; 308 int default_target_enc; 309 310 /* Output encoding. This must match what the hash origin used. An exception 311 is UTF-16 formats like NT, which can use any codepage (or UTF-8) if FMT_ENC 312 is set, or ISO-8859-1 only if FMT_ENC is false. */ 313 int target_enc; 314 315 /* If different from target_enc, this is an intermediate encoding only 316 used within rules/mask processing. This is only applicable for the case 317 "UTF-8 -> rules -> UTF-8" or "mask -> UTF-8". Since the rules engine can't 318 do proper case conversion etc. in UTF-8, we can pick this intermediate 319 encoding (use one that matches most input) but the double conversions may 320 come with a speed penalty. */ 321 int internal_cp; 322 323 /* Store UTF-8 in pot file. Default is no conversion. */ 324 int store_utf8; 325 326 /* Show/log/report UTF-8. Default is no conversion. */ 327 int report_utf8; 328 329 /* Pot file used (default is $JOHN/john.pot) */ 330 char *activepot; 331 332 /* the wordlist rules section (default if none entered is Wordlist) */ 333 const char *activewordlistrules; 334 335 /* the 'single' rules section (default if none entered is Single) */ 336 const char *activesinglerules; 337 338 /* Stacked rules applied within cracker.c for any mode */ 339 char *rule_stack; 340 341 /* This is a 'special' flag. It causes john to add 'extra' code to search for 342 * some salted types, when we have only the hashes. The only type supported is 343 * PHPS (at this time.). So PHPS will set this to a 1. OTherwise it will 344 * always be zero. LIKELY we will add the same type logic for the OSC 345 * (mscommerse) type, which has only a 2 byte salt. That will set this field 346 * to be a 2. If we add other types, then we will have other values which can 347 * be assigned to this variable. This var is set by the undocummented 348 * --regen_lost_salts=# */ 349 int regen_lost_salts; 350 351 /* Requested max_keys_per_crypt (for testing purposes) */ 352 int force_maxkeys; 353 354 /* Requested min/max plaintext_length. if options weren't used, req_min == -1 355 * and/or req_maxlength == 0 */ 356 int req_minlength, req_maxlength; 357 358 /* Effective min/max plaintext_length. Always set. If hybrid mask is used, 359 * mask_add_len is subtracted from them so parents should use these as-is */ 360 int eff_minlength, eff_maxlength; 361 362 /* Forced MaxLen (if set, we will reject longer candidates unless FMT_TRUNC) */ 363 int force_maxlength; 364 365 /* 366 * Graceful exit after this many seconds of cracking. If the number is 367 * negative, we exit after that many seconds of not cracking anything. 368 */ 369 int max_run_time; 370 371 /* Graceful exit after this many candidates tried. */ 372 long long max_cands; 373 374 /* Emit a status line every N seconds */ 375 int status_interval; 376 377 /* Resync pot file when saving */ 378 int reload_at_save; 379 380 /* Send a resync trigger (to others) when new cracks are written to pot */ 381 int reload_at_crack; 382 383 /* Pause/abort on trigger files */ 384 const char *pause_file; 385 const char *abort_file; 386 387 /* Force dynamic format to always treat bare hashes as valid. If not set 388 then dynamic format only uses bare hashes if -form=dynamic_xxx is used. 389 If this is 'N', then original logic used. If 'Y' or 'y' then we always 390 use bare hashes as valid in dynamic. */ 391 char dynamic_bare_hashes_always_valid; 392 393 #ifdef HAVE_OPENCL 394 /* Vector width of OpenCL kernel */ 395 unsigned int v_width; 396 397 /* GPU Worksizes */ 398 size_t lws, gws; 399 #endif 400 #if defined(HAVE_OPENCL) || defined(HAVE_ZTEX) 401 /* Allow to set and select OpenCL device(s) or ztex boards */ 402 struct list_main *acc_devices; 403 #endif 404 /* -list=WHAT Get a config list (eg. a list of incremental modes available) */ 405 char *listconf; 406 /* Verbosity level, 1-5. Three is normal for jumbo, four is "legacy". */ 407 int verbosity; 408 /* Secure mode. Do not output, log or store cracked passwords. */ 409 int secure; 410 /* Mode that appended the uid to the user name (on display) */ 411 int show_uid_in_cracks; 412 /* regular expression */ 413 char *regex; 414 /* Custom masks */ 415 char *custom_mask[MAX_NUM_CUST_PLHDR]; 416 /* Tune options */ 417 char *tune; 418 /* Incremental CharCount override */ 419 int charcount; 420 /* Subsets full charset */ 421 char *subset_full; 422 /* Subsets, required first partition */ 423 int subset_must; 424 /* Subsets, min. diff */ 425 int subset_min_diff; 426 /* Subsets, max. diff */ 427 int subset_max_diff; 428 }; 429 430 extern struct options_main options; 431 432 /* 433 * Initializes the options structure. 434 */ 435 extern void opt_init(char *name, int argc, char **argv, int show_usage); 436 437 /* 438 * Prints the "hidden" options usage 439 */ 440 extern void opt_print_hidden_usage(void); 441 442 #endif 443