>From f246d20074c84166d1064be4428c638ae54bceae Mon Sep 17 00:00:00 2001 From: magnum Date: Thu, 10 May 2012 21:37:27 +0200 Subject: [PATCH] New (hidden) options: --list=[inc-modes|rules|externals] --- src/config.c | 17 +++++++++++++++++ src/config.h | 6 ++++++ src/john.c | 16 ++++++++++++++++ src/options.c | 5 ++++- src/options.h | 2 ++ 5 files changed, 45 insertions(+), 1 deletions(-) diff --git a/src/config.c b/src/config.c index c95ef46..e38066c 100644 --- a/src/config.c +++ b/src/config.c @@ -195,6 +195,23 @@ struct cfg_list *cfg_get_list(char *section, char *subsection) return NULL; } +void cfg_print_subsections(char *section) +{ + struct cfg_section *current; + char *p1, *p2; + + if ((current = cfg_database)) + do { + p1 = current->name; p2 = section; + while (*p1 && *p1 == tolower((int)(unsigned char)*p2)) { + p1++; p2++; + } + if (*p1++ != ':') continue; + if (!*p1 || *p2) continue; + printf("%s\n", p1); + } while ((current = current->next)); +} + char *cfg_get_param(char *section, char *subsection, char *param) { struct cfg_section *current_section; diff --git a/src/config.h b/src/config.h index e0e30e5..de6fcf8 100644 --- a/src/config.h +++ b/src/config.h @@ -64,6 +64,12 @@ extern void cfg_init(char *name, int allow_missing); extern struct cfg_list *cfg_get_list(char *section, char *subsection); /* + * Searches for sections with the supplied name, and prints a list of + * valid subsections. + */ +void cfg_print_subsections(char *section); + +/* * Searches for a section with the supplied name and a parameter within the * section, and returns the parameter's value, or NULL if not found. */ diff --git a/src/john.c b/src/john.c index fe98bb2..291a109 100644 --- a/src/john.c +++ b/src/john.c @@ -556,6 +556,22 @@ static void john_init(char *name, int argc, char **argv) exit(0); } + if (options.listconf && !strcasecmp(options.listconf, "inc-modes")) + { + cfg_print_subsections("Incremental"); + exit(0); + } + if (options.listconf && !strcasecmp(options.listconf, "rules")) + { + cfg_print_subsections("List.Rules"); + exit(0); + } + if (options.listconf && !strcasecmp(options.listconf, "externals")) + { + cfg_print_subsections("List.External"); + exit(0); + } + initUnicode(UNICODE_UNICODE); /* Init the unicode system */ john_register_all(); /* maybe restricted to one format by options */ diff --git a/src/options.c b/src/options.c index e1261a1..fc52df8 100644 --- a/src/options.c +++ b/src/options.c @@ -114,6 +114,8 @@ static struct opt_entry opt_list[] = { {"subformat", FLG_NONE, FLG_NONE, 0, FLG_STDOUT | OPT_REQ_PARAM, OPT_FMT_STR_ALLOC, &options.subformat}, + {"list", FLG_NONE, FLG_NONE, 0, FLG_STDOUT | OPT_REQ_PARAM, + OPT_FMT_STR_ALLOC, &options.listconf}, #ifdef HAVE_DL {"plugin", FLG_DYNFMT, 0, 0, OPT_REQ_PARAM, OPT_FMT_ADD_LIST_MULTI, &options.fmt_dlls}, @@ -403,7 +405,8 @@ void opt_init(char *name, int argc, char **argv) exit(0); } - if (!(options.subformat && !strcasecmp(options.subformat, "list"))) + if (!(options.subformat && !strcasecmp(options.subformat, "list")) && + (!options.listconf)) if ((options.flags & (FLG_PASSWD | FLG_PWD_REQ)) == FLG_PWD_REQ) { #ifdef HAVE_MPI if (mpi_id == 0) diff --git a/src/options.h b/src/options.h index c3c7dcf..26b944d 100644 --- a/src/options.h +++ b/src/options.h @@ -204,6 +204,8 @@ struct options_main { #elif defined(HAVE_CUDA) char *ocl_device; #endif +/* -list=WHAT Get a config list (eg. a list of incremental modes available) */ + char *listconf; }; extern struct options_main options; -- 1.7.5.4