mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-21 22:03:46 -07:00
stdin mode
This commit is contained in:
parent
42f75763d9
commit
70c8b6ee6d
5 changed files with 26 additions and 44 deletions
29
bfg.c
29
bfg.c
|
@ -174,8 +174,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));
|
||||
|
||||
|
@ -202,7 +200,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)
|
||||
|
@ -212,19 +210,8 @@ char *bf_next(_Bool rainy) {
|
|||
fprintf(stderr, "Error: Can not allocate memory for -x data!\n");
|
||||
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;
|
||||
|
@ -236,15 +223,6 @@ char *bf_next(_Bool rainy) {
|
|||
printf(", x: %s\n", bf_options.ptr);
|
||||
}
|
||||
|
||||
//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--;
|
||||
|
@ -252,7 +230,6 @@ char *bf_next(_Bool rainy) {
|
|||
|
||||
if (pos < 0 || pos >= bf_options.current) {
|
||||
bf_options.current++;
|
||||
bf_options.rain = 0;
|
||||
memset((char *)bf_options.state, 0, sizeof(bf_options.state));
|
||||
}
|
||||
|
||||
|
|
4
bfg.h
4
bfg.h
|
@ -43,8 +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;
|
||||
uint64_t gcounter;
|
||||
} bf_option;
|
||||
|
||||
extern bf_option bf_options;
|
||||
|
@ -52,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
|
||||
|
|
6
configure
vendored
6
configure
vendored
|
@ -17,12 +17,10 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
|||
echo " --help this here"
|
||||
echo
|
||||
echo If the CC environment variable is set, this is used as the compiler for the configure tests. The default is \"gcc\" otherwise.
|
||||
echo You can also set PKG_CONFIG if necessary.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
test -z "$CC" && CC=gcc
|
||||
test -z "$PKG_CONFIG" && PKG_CONFIG=pkg-config
|
||||
|
||||
FHS=""
|
||||
SIXFOUR=""
|
||||
|
@ -1307,9 +1305,9 @@ echo "Checking for smbclient (libsmbclient/libsmbclient.h) ..."
|
|||
|
||||
if [ "X" = "X$XHYDRA_SUPPORT" ]; then
|
||||
echo "Checking for GUI req's (pkg-config/gtk+-2.0) ..."
|
||||
XHYDRA_SUPPORT=`$PKG_CONFIG --help > /dev/null 2>&1 || echo disabled`
|
||||
XHYDRA_SUPPORT=`pkg-config --help > /dev/null 2>&1 || echo disabled`
|
||||
if [ "X" = "X$XHYDRA_SUPPORT" ]; then
|
||||
XHYDRA_SUPPORT=`$PKG_CONFIG --modversion gtk+-2.0 2> /dev/null`
|
||||
XHYDRA_SUPPORT=`pkg-config --modversion gtk+-2.0 2> /dev/null`
|
||||
else
|
||||
XHYDRA_SUPPORT=""
|
||||
fi
|
||||
|
|
28
hydra.c
28
hydra.c
|
@ -503,8 +503,11 @@ void help(int32_t ext) {
|
|||
"[-C FILE]] [-e nsr]"
|
||||
" [-o FILE] [-t TASKS] [-M FILE [-T TASKS]] [-w TIME] [-W "
|
||||
"TIME] [-f] [-s PORT]"
|
||||
#ifdef HAVE_MATH_H
|
||||
" [-x MIN:MAX:CHARSET]"
|
||||
#ifndef HAVE_MATH_H
|
||||
" [-x +LINES]"
|
||||
#else
|
||||
" [ [-x MIN:MAX:CHARSET] | [-x +LINES] ]"
|
||||
|
||||
#endif
|
||||
" [-c TIME] [-ISOuvVd46] [-m MODULE_OPT] "
|
||||
//"[server service [OPT]]|"
|
||||
|
@ -522,11 +525,14 @@ void help(int32_t ext) {
|
|||
" -p PASS or -P FILE try password PASS, or load several "
|
||||
"passwords from FILE\n");
|
||||
PRINT_EXTEND(ext,
|
||||
#ifdef HAVE_MATH_H
|
||||
" -x MIN:MAX:CHARSET password bruteforce generation, type "
|
||||
#ifndef HAVE_MATH_H
|
||||
" -x +LINES read from stdin\n"
|
||||
"\"-x -h\" to get help\n"
|
||||
#else
|
||||
" -x +LINES read from stdin\n"
|
||||
" -x MIN:MAX:CHARSET password bruteforce generation, type\n"
|
||||
"\"-x -h\" to get help\n"
|
||||
" -y disable use of symbols in bruteforce, see above\n"
|
||||
" -r use a non-random shuffling method for option -x\n"
|
||||
#endif
|
||||
" -e nsr try \"n\" null password, \"s\" login as pass "
|
||||
"and/or \"r\" reversed login\n"
|
||||
|
@ -612,9 +618,10 @@ void help_bfg() {
|
|||
" 'A' for uppercase letters, '1' for numbers, and for all "
|
||||
"others,\n"
|
||||
" just add their real representation.\n"
|
||||
" -y disable the use of the above letters as placeholders\n"
|
||||
" -r use a shuffling method called 'rain' to try to break\n"
|
||||
" the linearity of the bruteforce\n"
|
||||
" -y disable the use of the above letters as placeholders\n\n"
|
||||
" -x +LINES\n\n"
|
||||
" LINES is the numer of lines read from standard input,\n"
|
||||
" you must not set it above what stdin is going to produce.\n"
|
||||
"Examples:\n"
|
||||
" -x 3:5:a generate passwords from length 3 to 5 with all "
|
||||
"lowercase letters\n"
|
||||
|
@ -626,6 +633,7 @@ void help_bfg() {
|
|||
"only of /%%,.-\n"
|
||||
" -x 3:5:aA1 -y generate passwords from length 3 to 5 with a, A and "
|
||||
"1 only\n"
|
||||
" -x +250 test with the first 250 lines of standard input\n"
|
||||
"\nThe bruteforce mode was made by Jan Dlabal, "
|
||||
"http://houbysoft.com/bfg/\n");
|
||||
exit(-1);
|
||||
|
@ -2476,11 +2484,11 @@ int main(int argc, char *argv[]) {
|
|||
modusage = 1;
|
||||
break;
|
||||
case 'x':
|
||||
if(optarg[0] == '-') {
|
||||
if(optarg[0] == '+') {
|
||||
hydra_options.read_stdin = 1;
|
||||
hydra_options.stdin_lines = atoi(&optarg[1]);
|
||||
if(hydra_options.stdin_lines < 1) {
|
||||
fprintf(stderr, "Using stdin, you must give the numbers of lines to treat: -x -250");
|
||||
fprintf(stderr, "Using stdin, you must give the numbers of lines to treat: -x +250\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
|
3
hydra.h
3
hydra.h
|
@ -206,7 +206,8 @@ typedef struct {
|
|||
char *server;
|
||||
char *service;
|
||||
char bfg;
|
||||
int8_t rainy;
|
||||
int32_t read_stdin;
|
||||
int32_t stdin_lines;
|
||||
int32_t skip_redo;
|
||||
} hydra_option;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue