no more rain

This commit is contained in:
owein 2019-10-07 14:20:02 +02:00 committed by yvain douard
commit 9de29d4cb7
4 changed files with 9 additions and 36 deletions

28
bfg.c
View file

@ -59,7 +59,6 @@ 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;
@ -199,15 +198,7 @@ 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;
}
char *bf_next(_Bool rainy) {
char *bf_next() {
int32_t i, pos = bf_options.current - 1;
if (bf_options.current > bf_options.to)
@ -217,21 +208,8 @@ char *bf_next(_Bool rainy) {
fprintf(stderr, "Error: Can not allocate memory for -x data!\n");
return NULL;
}
if (rainy) {
for (i = 0; i < bf_options.current; i++) {
bf_options.ptr[i] = bf_options.crs[(bf_options.state[i] + bf_options.rain) % bf_options.crs_len];
bf_options.rain += i + 1;
}
if (bf_options.crs_len % 10 == 0)
bf_options.rain -= accu(bf_options.current) - 2;
else if (bf_options.crs_len % 2 == 0)
bf_options.rain -= accu(bf_options.current) - 4;
else if (bf_options.crs_len % 2)
bf_options.rain -= accu(bf_options.current) - 1;
} else
for (i = 0; i < bf_options.current; i++)
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
for (i = 0; i < bf_options.current; i++)
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
bf_options.ptr[bf_options.current] = 0;
if (debug) {

3
bfg.h
View file

@ -43,7 +43,6 @@ 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 */
} bf_option;
extern bf_option bf_options;
@ -51,7 +50,7 @@ extern bf_option bf_options;
#ifdef HAVE_MATH_H
extern uint64_t bf_get_pcount();
extern int32_t bf_init(char *arg);
extern char *bf_next(_Bool rainy);
extern char *bf_next();
#endif
#endif

13
hydra.c
View file

@ -490,7 +490,7 @@ void help(int32_t ext) {
"[service://server[:PORT][/OPT]]\n");
PRINT_NORMAL(ext, "\nOptions:\n");
PRINT_EXTEND(ext, " -R restore a previous aborted/crashed session\n"
" -I ignore an existing restore file (don't wait 10 seconds)\n"
" -I ignore an existing restore file (don't wait 10 seconds)\n"
#ifdef LIBOPENSSL
" -S perform an SSL connect\n"
#endif
@ -505,7 +505,6 @@ 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"
#endif
" -e nsr try \"n\" null password, \"s\" login as pass "
"and/or \"r\" reversed login\n"
@ -1777,7 +1776,7 @@ int32_t hydra_send_next_pair(int32_t target_no, int32_t head_no) {
#ifndef HAVE_MATH_H
sleep(1);
#else
hydra_targets[target_no]->pass_ptr = bf_next(hydra_options.rainy);
hydra_targets[target_no]->pass_ptr = bf_next();
if (debug)
printf("[DEBUG] bfg new password for next child: %s\n", hydra_targets[target_no]->pass_ptr);
#endif
@ -2277,7 +2276,6 @@ int main(int argc, char *argv[]) {
hydra_brains.ofp = stdout;
hydra_brains.targets = 1;
hydra_options.waittime = waittime = WAITTIME;
hydra_options.rainy = 0;
bf_options.disable_symbols = 0;
// command line processing
@ -2312,9 +2310,6 @@ int main(int argc, char *argv[]) {
hydra_options.restore = 1;
hydra_restore_read();
break;
case 'r':
hydra_options.rainy = 1;
break;
case 'I':
ignore_restore = 1; // this is not to be saved in hydra_options!
break;
@ -3428,8 +3423,8 @@ int main(int argc, char *argv[]) {
if (hydra_options.bfg) {
#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);
exit(-1); // error description is handled by bf_init
pass_ptr = bf_next();
hydra_brains.countpass += bf_get_pcount();
hydra_brains.sizepass += BF_BUFLEN;
#else

View file

@ -208,6 +208,7 @@ typedef struct {
char bfg;
_Bool rainy;
int32_t skip_redo;
_Bool rainy;
} hydra_option;
#define _HYDRA_H