Skip to content

Commit

Permalink
remove rain mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Mar 11, 2021
1 parent ac2fd35 commit f423875
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
29 changes: 3 additions & 26 deletions bfg.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/* code original by Jan Dlabal <[email protected]>, partially rewritten by vh,
rainy tweaks by owein <[email protected]>*/
/* code original by Jan Dlabal <[email protected]>, partially rewritten by vh. */

#include <ctype.h>
#include <math.h>
Expand Down Expand Up @@ -174,8 +173,6 @@ int32_t bf_init(char *arg) {

bf_options.crs_len = crs_len;
bf_options.current = bf_options.from;
bf_options.rain = 0;
bf_options.gcounter = 0;

memset((char *) bf_options.state, 0, sizeof(bf_options.state));

Expand All @@ -202,7 +199,7 @@ uint64_t bf_get_pcount() {
return foo;
}

char *bf_next(_Bool rainy) {
char *bf_next() {
int32_t i, pos = bf_options.current - 1;

if (bf_options.current > bf_options.to)
Expand All @@ -213,18 +210,7 @@ char *bf_next(_Bool rainy) {
return NULL;
}

if(rainy)
{
bf_options.rain = bf_options.gcounter;
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
for(i=1; 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 -= bf_options.rain / bf_options.crs_len;
}
bf_options.gcounter++;
}
else
for(i=0; i<bf_options.current; ++i)
for(i=0; i<bf_options.current; ++i)
bf_options.ptr[i] = bf_options.crs[bf_options.state[i]];
//we don't subtract the same depending on wether the length is odd or even
bf_options.ptr[bf_options.current] = 0;
Expand All @@ -237,22 +223,13 @@ char *bf_next(_Bool rainy) {
}

//we revert the ordering of the bruteforce to fix the first static character
if(rainy) {
pos = 0;
while (pos < bf_options.current && (++bf_options.state[pos]) >= 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 || pos >= bf_options.current) {
bf_options.current++;
bf_options.rain = 0;
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
}

Expand Down
4 changes: 1 addition & 3 deletions bfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ typedef struct {
char *crs; /* internal representation of charset */
char *ptr; /* ptr to the last generated password */
uint32_t disable_symbols;
uint64_t rain;
uint64_t gcounter;
} bf_option;

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
7 changes: 3 additions & 4 deletions hydra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,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
Expand Down Expand Up @@ -2280,7 +2280,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
Expand Down Expand Up @@ -2316,7 +2315,7 @@ int main(int argc, char *argv[]) {
hydra_restore_read();
break;
case 'r':
hydra_options.rainy = 1;
fprintf(stderr, "Warning: the option -r has been removed.\n");
break;
case 'I':
ignore_restore = 1; // this is not to be saved in hydra_options!
Expand Down Expand Up @@ -3433,7 +3432,7 @@ int main(int argc, char *argv[]) {
if (bf_init(bf_options.arg))
exit(-1); // error description is handled by bf_init

pass_ptr = bf_next(hydra_options.rainy);
pass_ptr = bf_next();
hydra_brains.countpass += bf_get_pcount();
hydra_brains.sizepass += BF_BUFLEN;
#else
Expand Down
1 change: 0 additions & 1 deletion hydra.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ typedef struct {
char *server;
char *service;
char bfg;
int8_t rainy;
int32_t skip_redo;
} hydra_option;

Expand Down

0 comments on commit f423875

Please sign in to comment.