From 06499ea036cefed596426a38b8e315738038425e Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 13 Feb 2015 23:41:52 +0100 Subject: [PATCH] Load only NUM words from input wordlist or use 0 to disable Most people dont think and just throw their biggest wordlist on prince. That's not how prince is supposed to be used. Let's help them in their ignorance a bit. For people that know what they do, they can use the 0 parameter to disable this check. --- CHANGES | 1 + src/pp.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 39c1e12..04ef1c4 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ - Fix for "Bug --pw-min" issue - Print position when stopped - Allow wordlist as fileparameter +- Load only NUM words from input wordlist or use 0 to disable * v0.19 -> v0.20: diff --git a/src/pp.c b/src/pp.c index 38cd8bd..66d9aea 100644 --- a/src/pp.c +++ b/src/pp.c @@ -31,6 +31,7 @@ #define ELEM_CNT_MIN 1 #define ELEM_CNT_MAX 8 #define WL_DIST_LEN 0 +#define WL_MAX 10000000 #define CASE_PERMUTE 0 #define DUPE_CHECK 1 #define SAVE_POS 1 @@ -193,6 +194,7 @@ static const char *USAGE_BIG[] = " --elem-cnt-min=NUM Minimum number of elements per chain", " --elem-cnt-max=NUM Maximum number of elements per chain", " --wl-dist-len Calculate output length distribution from wordlist", + " --wl-max=NUM Load only NUM words from input wordlist or use 0 to disable", " -c, --dupe-check-disable Disable dupes check for faster inital load", " --save-pos-disable Save the position for later resume with -s", "", @@ -694,6 +696,7 @@ int main (int argc, char *argv[]) int elem_cnt_min = ELEM_CNT_MIN; int elem_cnt_max = ELEM_CNT_MAX; int wl_dist_len = WL_DIST_LEN; + int wl_max = WL_MAX; int case_permute = CASE_PERMUTE; int dupe_check = DUPE_CHECK; int save_pos = SAVE_POS; @@ -707,8 +710,9 @@ int main (int argc, char *argv[]) #define IDX_ELEM_CNT_MAX 0x4000 #define IDX_KEYSPACE 0x5000 #define IDX_WL_DIST_LEN 0x6000 - #define IDX_CASE_PERMUTE 0x7000 - #define IDX_SAVE_POS_DISABLE 0x8000 + #define IDX_WL_MAX 0x7000 + #define IDX_CASE_PERMUTE 0x8000 + #define IDX_SAVE_POS_DISABLE 0x9000 #define IDX_DUPE_CHECK_DISABLE 'c' #define IDX_SKIP 's' #define IDX_LIMIT 'l' @@ -724,6 +728,7 @@ int main (int argc, char *argv[]) {"elem-cnt-min", required_argument, 0, IDX_ELEM_CNT_MIN}, {"elem-cnt-max", required_argument, 0, IDX_ELEM_CNT_MAX}, {"wl-dist-len", no_argument, 0, IDX_WL_DIST_LEN}, + {"wl-max", required_argument, 0, IDX_WL_MAX}, {"case-permute", no_argument, 0, IDX_CASE_PERMUTE}, {"dupe-check-disable", no_argument, 0, IDX_DUPE_CHECK_DISABLE}, {"save-pos-disable", no_argument, 0, IDX_SAVE_POS_DISABLE}, @@ -752,6 +757,7 @@ int main (int argc, char *argv[]) case IDX_ELEM_CNT_MAX: elem_cnt_max = atoi (optarg); elem_cnt_max_chgd = 1; break; case IDX_WL_DIST_LEN: wl_dist_len = 1; break; + case IDX_WL_MAX: wl_max = atoi (optarg); break; case IDX_CASE_PERMUTE: case_permute = 1; break; case IDX_DUPE_CHECK_DISABLE: dupe_check = 0; break; case IDX_SAVE_POS_DISABLE: save_pos = 0; break; @@ -948,6 +954,8 @@ int main (int argc, char *argv[]) } } + int wl_cnt = 0; + while (!feof (read_fp)) { char buf[BUFSIZ]; @@ -1009,6 +1017,10 @@ int main (int argc, char *argv[]) } } } + + wl_cnt++; + + if (wl_max > 0 && wl_cnt == wl_max) break; } if (wordlist)