diff --git a/bfg.c b/bfg.c index 88580fe..912b61c 100644 --- a/bfg.c +++ b/bfg.c @@ -1,6 +1,6 @@ -/* code original by Jan Dlabal , partially rewritten by vh - */ +/* code original by Jan Dlabal , partially rewritten by vh, + rainy tweaks by owein */ #include #include @@ -59,12 +59,11 @@ static int32_t add_single_char(char ch, char flags, int32_t *crs_len) { // note that we check for -x .:.:ab but not for -x .:.:ba // int32_t bf_init(char *arg) { - bf_options.rain = 0; int32_t i = 0; int32_t crs_len = 0; char flags = 0; char *tmp = strchr(arg, ':'); - + if (!tmp) { fprintf(stderr, "Error: Invalid option format for -x\n"); return 1; @@ -172,10 +171,14 @@ int32_t bf_init(char *arg) { } } } - + bf_options.crs_len = crs_len; bf_options.current = bf_options.from; - memset((char *)bf_options.state, 0, sizeof(bf_options.state)); + bf_options.rain = 0; + bf_options.gcounter = 0; + + memset((char *) bf_options.state, 0, sizeof(bf_options.state)); + if (debug) printf("[DEBUG] bfg INIT: from %u, to %u, len: %u, set: %s\n", bf_options.from, bf_options.to, bf_options.crs_len, bf_options.crs); @@ -199,12 +202,12 @@ uint64_t bf_get_pcount() { return foo; } -int accu(int value) { - int i = 0, a; - for (a = 1; a <= value; ++a) { - i += a; - } - return i; + +int accu(int x) { + int a = 0, b; + for(b=1; b= bf_options.crs_len) { + bf_options.state[pos] = 0; + pos++; + } + } + else while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) { bf_options.state[pos] = 0; pos--; } - if (pos < 0) { + if (pos < 0 || pos >= bf_options.current) { bf_options.current++; + bf_options.rain = 0; memset((char *)bf_options.state, 0, sizeof(bf_options.state)); } diff --git a/bfg.h b/bfg.h index a3c36bb..602cee6 100644 --- a/bfg.h +++ b/bfg.h @@ -43,7 +43,8 @@ typedef struct { char *crs; /* internal representation of charset */ char *ptr; /* ptr to the last generated password */ uint32_t disable_symbols; - uint64_t rain; /* accumulator for the rain */ + uint64_t rain; + uint64_t gcounter; } bf_option; extern bf_option bf_options; diff --git a/hydra-http-form.c b/hydra-http-form.c index e6074cf..4cd2655 100644 --- a/hydra-http-form.c +++ b/hydra-http-form.c @@ -1283,6 +1283,7 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) { ptr++; if (*ptr != 0) *ptr++ = 0; + cond = ptr; if ((ptr2 = index(ptr, ':')) != NULL) { @@ -1341,7 +1342,7 @@ ptr_header_node initialize(char *ip, unsigned char options, char *miscptr) { // printf("miscptr: %s, url=%s, variables=%s, ptr=%s, optional1: %s, cond: %s // (%d)\n", miscptr, url, variables, ptr, optional1, cond, success_cond); - + /* * Parse the user-supplied options. * Beware of the backslashes (\)! diff --git a/hydra.c b/hydra.c index 9efbc05..852d0de 100644 --- a/hydra.c +++ b/hydra.c @@ -505,7 +505,7 @@ void help(int32_t ext) { " -x MIN:MAX:CHARSET password bruteforce generation, type " "\"-x -h\" to get help\n" " -y disable use of symbols in bruteforce, see above\n" - " -r rainy mode for password generation (-x)\n" + " -r use a non-random shuffling method for option -x\n" #endif " -e nsr try \"n\" null password, \"s\" login as pass " "and/or \"r\" reversed login\n" @@ -591,7 +591,9 @@ void help_bfg() { " 'A' for uppercase letters, '1' for numbers, and for all " "others,\n" " just add their real representation.\n" - " -y disable the use of the above letters as placeholders\n\n" + " -y disable the use of the above letters as placeholders\n" + " -r use a shuffling method called 'rain' to try to break\n" + " the linearity of the bruteforce\n" "Examples:\n" " -x 3:5:a generate passwords from length 3 to 5 with all " "lowercase letters\n" @@ -3183,7 +3185,6 @@ int main(int argc, char *argv[]) { printf("[INFO] Using HTTP Proxy: %s\n", getenv("HYDRA_PROXY_HTTP")); use_proxy = 1; } - if (strstr(hydra_options.miscptr, "\\:") != NULL) { fprintf(stderr, "[INFORMATION] escape sequence \\: detected in module " "option, no parameter verification is performed.\n"); @@ -3212,6 +3213,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "[ERROR] Wrong syntax of optional argument: %s\n", optional1); exit(-1); } + switch (optional1[0]) { case 'C': // fall through case 'c': @@ -3429,6 +3431,7 @@ int main(int argc, char *argv[]) { #ifdef HAVE_MATH_H if (bf_init(bf_options.arg)) exit(-1); // error description is handled by bf_init + pass_ptr = bf_next(hydra_options.rainy); hydra_brains.countpass += bf_get_pcount(); hydra_brains.sizepass += BF_BUFLEN; diff --git a/hydra.h b/hydra.h index 53b52d5..f0a0253 100644 --- a/hydra.h +++ b/hydra.h @@ -206,7 +206,7 @@ typedef struct { char *server; char *service; char bfg; - _Bool rainy; + int8_t rainy; int32_t skip_redo; } hydra_option;