mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-19 21:03:52 -07:00
update efficient rain option
This commit is contained in:
parent
3fa6d372cf
commit
c65e3a26fc
2 changed files with 15 additions and 32 deletions
42
bfg.c
42
bfg.c
|
@ -60,7 +60,6 @@ static int32_t add_single_char(char ch, char flags, int32_t *crs_len) {
|
||||||
//
|
//
|
||||||
int32_t bf_init(char *arg) {
|
int32_t bf_init(char *arg) {
|
||||||
bf_options.rotate = 0;
|
bf_options.rotate = 0;
|
||||||
bf_options.strafe = 0;
|
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t crs_len = 0;
|
int32_t crs_len = 0;
|
||||||
|
@ -224,34 +223,16 @@ char *bf_next(_Bool rainy) {
|
||||||
|
|
||||||
if(rainy)
|
if(rainy)
|
||||||
{
|
{
|
||||||
//only strafe the index above length 3
|
//the first character cannot be taken into account
|
||||||
if(bf_options.current > 3) {
|
bf_options.ptr[0] = bf_options.crs[bf_options.state[0]];
|
||||||
for(i=0; i<bf_options.current; ++i) {
|
for(i=1; i<bf_options.current; ++i) {
|
||||||
bf_options.ptr[i] = bf_options.crs[(bf_options.state[(bf_options.strafe[loop]/(bf_options.current/4)+i) % bf_options.current] + bf_options.rotate) % bf_options.crs_len];
|
|
||||||
bf_options.rotate += (i+1)%(bf_options.current/2+1);
|
|
||||||
bf_options.strafe += 2 * (2-bf_options.current%2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(i=0; 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.ptr[i] = bf_options.crs[(bf_options.state[i] + bf_options.rotate) % bf_options.crs_len];
|
||||||
bf_options.rotate += (i+1)%(bf_options.current/2+1);;
|
bf_options.rotate += i+3;
|
||||||
}
|
}
|
||||||
|
//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; ++i)
|
||||||
|
bf_options.rotate -= i+1;
|
||||||
}
|
}
|
||||||
#define accu(i) \
|
|
||||||
do { \
|
|
||||||
int j; \
|
|
||||||
for(j=1; j<=i; ++j) k += j; \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
int k = 0;
|
|
||||||
accu(bf_options.current);
|
|
||||||
bf_options.rotate -= k;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
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;
|
bf_options.ptr[bf_options.current] = 0;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -261,11 +242,16 @@ char *bf_next(_Bool rainy) {
|
||||||
printf(", x: %s\n", bf_options.ptr);
|
printf(", x: %s\n", bf_options.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//we revert the ordering of the bruteforce to fix the first static character
|
||||||
|
if(rainy)
|
||||||
|
while (pos >= 0 && (++bf_options.state[bf_options.current-1-pos]) >= bf_options.crs_len) {
|
||||||
|
bf_options.state[bf_options.current-1-pos] = 0;
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
else
|
||||||
while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) {
|
while (pos >= 0 && (++bf_options.state[pos]) >= bf_options.crs_len) {
|
||||||
bf_options.state[pos] = 0;
|
bf_options.state[pos] = 0;
|
||||||
pos--;
|
pos--;
|
||||||
bf_options.strafe = 0;
|
|
||||||
bf_options.rotate = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
|
|
3
bfg.h
3
bfg.h
|
@ -43,10 +43,7 @@ typedef struct {
|
||||||
char *crs; /* internal representation of charset */
|
char *crs; /* internal representation of charset */
|
||||||
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