mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-05 20:41:39 -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
|
||||
//
|
||||
int32_t bf_init(char *arg) {
|
||||
bf_options.rotate = 0;
|
||||
|
||||
int32_t i = 0;
|
||||
int32_t crs_len = 0;
|
||||
char flags = 0;
|
||||
|
@ -176,7 +174,9 @@ int32_t bf_init(char *arg) {
|
|||
|
||||
bf_options.crs_len = crs_len;
|
||||
bf_options.current = bf_options.from;
|
||||
|
||||
bf_options.strafe = 0;
|
||||
bf_options.rotate = 0;
|
||||
|
||||
memset((char *) bf_options.state, 0, sizeof(bf_options.state));
|
||||
|
||||
if (debug)
|
||||
|
@ -202,14 +202,6 @@ 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) {
|
||||
int32_t i, pos = bf_options.current - 1;
|
||||
|
||||
|
@ -223,16 +215,30 @@ char *bf_next(_Bool rainy) {
|
|||
|
||||
if(rainy)
|
||||
{
|
||||
//the first character cannot be taken into account
|
||||
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.rotate) % bf_options.crs_len];
|
||||
bf_options.rotate += i+3;
|
||||
if(bf_options.current > 2) {
|
||||
if(bf_options.current % 2) {
|
||||
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
|
||||
bf_options.ptr[1] = bf_options.crs[bf_options.state[1]];
|
||||
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
|
||||
for(i=1+bf_options.current%2; i<bf_options.current+bf_options.current%2; ++i)
|
||||
bf_options.rotate -= i+1;
|
||||
}
|
||||
else {
|
||||
if(bf_options.current % 2) {
|
||||
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;
|
||||
|
||||
if (debug) {
|
||||
|
@ -256,6 +262,8 @@ char *bf_next(_Bool rainy) {
|
|||
|
||||
if (pos < 0) {
|
||||
bf_options.current++;
|
||||
bf_options.strafe = 0;
|
||||
bf_options.rotate = 0;
|
||||
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue