mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-06 04:51:40 -07:00
working algo after a change
This commit is contained in:
parent
490bd3e7cd
commit
fc82b52505
2 changed files with 29 additions and 20 deletions
48
bfg.c
48
bfg.c
|
@ -59,8 +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
|
// note that we check for -x .:.:ab but not for -x .:.:ba
|
||||||
//
|
//
|
||||||
int32_t bf_init(char *arg) {
|
int32_t bf_init(char *arg) {
|
||||||
bf_options.rotate = 0;
|
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t crs_len = 0;
|
int32_t crs_len = 0;
|
||||||
char flags = 0;
|
char flags = 0;
|
||||||
|
@ -176,7 +174,9 @@ int32_t bf_init(char *arg) {
|
||||||
|
|
||||||
bf_options.crs_len = crs_len;
|
bf_options.crs_len = crs_len;
|
||||||
bf_options.current = bf_options.from;
|
bf_options.current = bf_options.from;
|
||||||
|
bf_options.strafe = 0;
|
||||||
|
bf_options.rotate = 0;
|
||||||
|
|
||||||
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
|
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -202,14 +202,6 @@ uint64_t bf_get_pcount() {
|
||||||
return foo;
|
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(_Bool rainy) {
|
||||||
int32_t i, pos = bf_options.current - 1;
|
int32_t i, pos = bf_options.current - 1;
|
||||||
|
|
||||||
|
@ -223,16 +215,30 @@ char *bf_next(_Bool rainy) {
|
||||||
|
|
||||||
if(rainy)
|
if(rainy)
|
||||||
{
|
{
|
||||||
//the first character cannot be taken into account
|
if(bf_options.current > 2) {
|
||||||
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
|
if(bf_options.current % 2) {
|
||||||
for(i=1; i<bf_options.current; ++i) {
|
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
|
||||||
bf_options.ptr[i] = bf_options.crs[(bf_options.state[i] + bf_options.rotate) % bf_options.crs_len];
|
bf_options.ptr[1] = bf_options.crs[bf_options.state[1]];
|
||||||
bf_options.rotate += i+3;
|
bf_options.ptr[2] = bf_options.crs[bf_options.state[2]];
|
||||||
|
|
||||||
|
for(i=3; i<bf_options.current; ++i) {
|
||||||
|
bf_options.ptr[i] = bf_options.crs[(bf_options.state[(i+bf_options.strafe)%(bf_options.current-3)+3] + bf_options.rotate) % bf_options.crs_len];
|
||||||
|
bf_options.rotate ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//we don't subtract the same depending on wether the length is odd or even
|
else {
|
||||||
for(i=1+bf_options.current%2; i<bf_options.current+bf_options.current%2; ++i)
|
if(bf_options.current % 2) {
|
||||||
bf_options.rotate -= i+1;
|
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
|
||||||
}
|
bf_options.ptr[1] = bf_options.crs[bf_options.state[1]];
|
||||||
|
for(i=2; i<bf_options.current; ++i) {
|
||||||
|
bf_options.ptr[i] = bf_options.crs[(bf_options.state[(i+bf_options.strafe)%(bf_options.current-2)+2] + bf_options.rotate) % bf_options.crs_len];
|
||||||
|
bf_options.rotate ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//we don't subtract the same depending on wether the length is odd or even
|
||||||
|
bf_options.strafe++;
|
||||||
bf_options.ptr[bf_options.current] = 0;
|
bf_options.ptr[bf_options.current] = 0;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -256,6 +262,8 @@ char *bf_next(_Bool rainy) {
|
||||||
|
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
bf_options.current++;
|
bf_options.current++;
|
||||||
|
bf_options.strafe = 0;
|
||||||
|
bf_options.rotate = 0;
|
||||||
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
bfg.h
1
bfg.h
|
@ -44,6 +44,7 @@ typedef struct {
|
||||||
char *ptr; /* ptr to the last generated password */
|
char *ptr; /* ptr to the last generated password */
|
||||||
uint32_t disable_symbols;
|
uint32_t disable_symbols;
|
||||||
uint64_t rotate;
|
uint64_t rotate;
|
||||||
|
uint64_t strafe;
|
||||||
} bf_option;
|
} bf_option;
|
||||||
|
|
||||||
extern bf_option bf_options;
|
extern bf_option bf_options;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue