From 65a2c8d49741dd2e12a5f38887c2208ffbe9c342 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 9 Dec 2014 12:16:55 +0100 Subject: [PATCH] debug enhancements --- configure | 164 +++++++++++++++++++++++++++++++++++++++++------------- hydra.c | 30 ++++++++-- 2 files changed, 151 insertions(+), 43 deletions(-) diff --git a/configure b/configure index 85eea5b..ec4f1c7 100755 --- a/configure +++ b/configure @@ -10,16 +10,61 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then echo " --with-oracle-lib=prefix prefix for oracle lib dir" echo " --disable-xhydra disable compilation of hydra GUI" echo " --nostrip do not per default strip binaries before install" + echo " --debug show debug output to trace errors" echo " --help this here" exit 0 fi +SIXFOUR="" +DEBUG="" + +if [ '!' "X" = "X$*" ]; then + while [ $# -gt 0 ] ; do + if [ "X" = "X$PREFIX" ]; then + PREFIX_TMP=`echo "$1"|sed 's/.*--prefix=//'` + if [ "$PREFIX_TMP" != "$1" ]; then + PREFIX=$PREFIX_TMP + fi + fi + if [ "X" = "X$NOSTRIP" ]; then + NOSTRIP_TMP=`echo "$1"|sed 's/.*--nostrip//'` + if [ -z "$NOSTRIP_TMP" ]; then + NOSTRIP="yes" + fi + fi + if [ "X" = "X$DEBUG" ]; then + DEBUG_TMP=`echo "$1"|sed 's/.*--debug//'` + if [ -z "$DEBUG_TMP" ]; then + DEBUG="yes" + fi + fi + if [ "X" = "X$XHYDRA_SUPPORT" ]; then + XHYDRA_SUPPORT_TMP=`echo "$1"|sed 's/.*--disable-xhydra//'` + if [ -z "$XHYDRA_SUPPORT_TMP" ]; then + XHYDRA_SUPPORT="disable" + fi + fi + if [ "X" = "X$WORACLE_PATH" ]; then + WORACLE_PATH_TMP=`echo "$1"|sed 's/.*--with-oracle=//'` + if [ "$WORACLE_PATH_TMP" != "$1" ]; then + WORACLE_PATH="$WORACLE_PATH_TMP" + fi + fi + if [ "X" = "X$WORACLE_LIB_PATH" ]; then + WORACLE_LIB_PATH_TMP=`echo "$1"|sed 's/.*--with-oracle-lib=//'` + if [ "$WORACLE_LIB_PATH_TMP" != "$1" ]; then + WORACLE_LIB_PATH="$WORACLE_LIB_PATH_TMP" + fi + fi + shift + done +fi + echo echo "Starting hydra auto configuration ..." rm -f Makefile.in SYSS=`uname -s 2> /dev/null` SYSO=`uname -o 2> /dev/null` -SIXFOUR="" if [ "$SYSS" = "Linux" -o "$SYSS" = "OpenBSD" -o "$SYSS" = "FreeBSD" -o "$SYSS" = "NetBSD" -o "$SYSS" = "Darwin" ]; then SF=`uname -m | grep 64` if [ `uname -m` = "s390x" ]; then @@ -79,6 +124,11 @@ STRIP="strip" echo echo "Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ..." +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: SSL_LIB=$LIBDIRS `ls -d /*ssl /usr/*ssl /opt/*ssl /usr/local/*ssl /opt/local/*ssl /*ssl/lib /usr/*ssl/lib /opt/*ssl/lib /usr/local/*ssl/lib /opt/local/*ssl/lib 2> /dev/null` + echo DEBUG: SSL_INC=$INCDIRS `ls -d /*ssl/include /opt/*ssl/include /usr/*ssl/include /usr/local/*ssl/include 2> /dev/null` +fi + for i in $LIBDIRS \ /*ssl /usr/*ssl /opt/*ssl /usr/local/*ssl /opt/local/*ssl \ /*ssl/lib /usr/*ssl/lib /opt/*ssl/lib /usr/local/*ssl/lib /opt/local/*ssl/lib @@ -117,6 +167,11 @@ do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: SSL_PATH=$SSL_PATH/libssl + echo DEBUG: CRYPTO_PATH=$CRYPTO_PATH/libcrypto + echo DEBUG: SSL_INC=$SSL_IPATH/openssl/ssl.h +fi if [ "X" = "X$SSL_PATH" ]; then SSL_IPATH="" @@ -167,6 +222,11 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: IDN_PATH=$IDN_PATH/libidn + echo DEBUG: IDN_IPATH=$IDN_IPATH/stringprep.h + echo DEBUG: PR29_IPATH=$PR29_IPATH/pr29.h +fi if [ -n "$IDN_PATH" -a -n "$IDN_IPATH" ]; then echo " ... found" fi @@ -208,6 +268,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: CURSES_PATH=$CURSES_PATH/libcurses + echo DEBUG: CURSES_IPATH=$CURSES_IPATH/term.h +fi if [ -n "$CURSES_PATH" -a -n "$CURSES_IPATH" ]; then echo " ... found, color output enabled" fi @@ -244,6 +308,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: PCRE_PATH=$PCRE_PATH/libpcre + echo DEBUG: PCRE_IPATH=$PCRE_IPATH/pcre.h +fi if [ -n "$PCRE_PATH" -a -n "$PCRE_IPATH" ]; then echo " ... found" fi @@ -295,6 +363,10 @@ echo "Checking for Postgres (libpq.so, libpq-fe.h) ..." fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: POSTGRES_PATH=$POSTGRES_PATH/libpq + echo DEBUG: POSTGRES_IPATH=$POSTGRES_IPATH/libpq-fe.h +fi if [ -n "$POSTGRES_PATH" -a -n "$POSTGRES_IPATH" ]; then echo " ... found" fi @@ -371,6 +443,12 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: SVN_PATH=$SVN_PATH/libsvn_client-1 + echo DEBUG: APR_PATH="$APR_PATH/libarp*" + echo DEBUG: SVN_IPATH=$APR_IPATH/ + echo DEBUG: APR_IPATH=$APR_IPATH/ +fi if [ "X" = "X$SVN_PATH" -o "X" = "X$SVN_IPATH" -o "X" = "X$APR_IPATH" ]; then SVN_PATH="" @@ -418,6 +496,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: FIREBIRD_PATH=$FIREBIRD_PATH/libfbclient + echo DEBUG: FIREBIRD_IPATH=$FIREBIRD_IPATH/ibase.h +fi if [ -n "$FIREBIRD_PATH" -a -n "$FIREBIRD_IPATH" ]; then echo " ... found" fi @@ -459,6 +541,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: MYSQL_PATH=$MYSQL_PATH/libmysqlclient + echo DEBUG: MYSQL_IPATH=$MYSQL_IPATH/mysql.h +fi MATH="" if [ -f "/usr/include/math.h" ]; then MATH="-DHAVE_MATH_H" @@ -499,6 +585,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: AFP_PATH=$AFP_PATH/libafpclient + echo DEBUG: AFP_IPATH=$AFP_IPATH/afp.h +fi if [ -n "$AFP_PATH" -a -n "$AFP_IPATH" ]; then echo " ... found" fi @@ -535,6 +625,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: NCP_PATH=$NCP_PATH/libncp + echo DEBUG: NCP_IPATH=$NCP_IPATH/ncp/nwcalls.h +fi if [ -n "$NCP_PATH" -a -n "$NCP_IPATH" ]; then echo " ... found" fi @@ -565,6 +659,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: SAPR3_PATH=$SAPR3_PATH/librfc + echo DEBUG: SAPR3_IPATH=$SAPR3_IPATH/saprfc.h +fi if [ "X" = "X$SAPR3_PATH" ]; then SAPR3_IPATH="" fi @@ -609,6 +707,10 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: SSH_PATH=$SSH_PATH/libssh + echo DEBUG: SSH_IPATH=$SSH_IPATH/libssh/libssh.h +fi if [ "X" = "X$SSH_PATH" ]; then SSH_IPATH="" fi @@ -626,43 +728,6 @@ if [ "$SSH_IPATH" = "/usr/include" ]; then SSH_IPATH="" fi -if [ '!' "X" = "X$*" ]; then - while [ $# -gt 0 ] ; do - if [ "X" = "X$PREFIX" ]; then - PREFIX_TMP=`echo "$1"|sed 's/.*--prefix=//'` - if [ "$PREFIX_TMP" != "$1" ]; then - PREFIX=$PREFIX_TMP - fi - fi - if [ "X" = "X$NOSTRIP" ]; then - NOSTRIP_TMP=`echo "$1"|sed 's/.*--nostrip//'` - if [ -z "$NOSTRIP_TMP" ]; then - NOSTRIP="yes" - fi - fi - if [ "X" = "X$XHYDRA_SUPPORT" ]; then - XHYDRA_SUPPORT_TMP=`echo "$1"|sed 's/.*--disable-xhydra//'` - if [ -z "$XHYDRA_SUPPORT_TMP" ]; then - XHYDRA_SUPPORT="disable" - fi - fi - if [ "X" = "X$WORACLE_PATH" ]; then - WORACLE_PATH_TMP=`echo "$1"|sed 's/.*--with-oracle=//'` - if [ "$WORACLE_PATH_TMP" != "$1" ]; then - WORACLE_PATH="$WORACLE_PATH_TMP" - fi - fi - if [ "X" = "X$WORACLE_LIB_PATH" ]; then - WORACLE_LIB_PATH_TMP=`echo "$1"|sed 's/.*--with-oracle-lib=//'` - if [ "$WORACLE_LIB_PATH_TMP" != "$1" ]; then - WORACLE_LIB_PATH="$WORACLE_LIB_PATH_TMP" - fi - fi - shift - done -fi - - echo "Checking for Oracle (libocci.so libclntsh.so / oci.h and libaio.so) ..." #assume if we find oci.h other headers should also be in that dir #for libs we will test the 2 @@ -672,6 +737,10 @@ fi if [ "X" != "X$WORACLE_LIB_PATH" ]; then LIBDIRS="$LIBDIRS $WORACLE_LIB_PATH" fi +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: ORACLE_LIB=$LIBDIRS + echo DEBUG: ORACLE_INC=$INCDIRS +fi for i in $LIBDIRS ; do if [ "X" = "X$ORACLE_PATH" ]; then @@ -714,6 +783,9 @@ for i in $LIBDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: ORACLE_PATH=$ORACLE_PATH/libocci +fi #check for Kernel Asynchronous I/O (AIO) lib support if [ "X" != "X$ORACLE_PATH" ]; then LIBAIO="" @@ -738,6 +810,9 @@ if [ "X" != "X$ORACLE_PATH" ]; then ORACLE_PATH="" fi fi +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: ORACLE_PATH=$ORACLE_PATH/libaio +fi for i in $INCDIRS ; do if [ "X" != "X$ORACLE_PATH" ]; then @@ -746,6 +821,9 @@ for i in $INCDIRS ; do fi fi done +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: ORACLE_IPATH=$ORACLE_IPATH/oci.h +fi if [ -n "$ORACLE_PATH" -a -n "$ORACLE_IPATH" ]; then echo " ... found" fi @@ -1017,6 +1095,16 @@ echo "Hydra will be installed into .../bin of: $PREFIX" echo " (change this by running ./configure --prefix=path)" echo +if [ "X" != "X$DEBUG" ]; then + echo DEBUG: XDEFINES=$XDEFINES $MATH + echo DEBUG: XLIBS=$XLIBS + echo DEBUG: XLIBPATHS=$XLIBPATHS + echo DEBUG: XIPATHS=$XIPATHS + echo DEBUG: PREFIX=$PREFIX + echo DEBUG: XHYDRA_SUPPORT=$XHYDRA_SUPPORT + echo DEBUG: STRIP=$STRIP +fi + echo "Writing Makefile.in ..." echo "XDEFINES=$XDEFINES $MATH" >> Makefile.in echo "XLIBS=$XLIBS" >> Makefile.in diff --git a/hydra.c b/hydra.c index 99e5e48..df962a7 100644 --- a/hydra.c +++ b/hydra.c @@ -158,7 +158,7 @@ char *SERVICES = #define RESTOREFILE "./hydra.restore" #define PROGRAM "Hydra" -#define VERSION "v8.2-dev" +#define VERSION "v8.1" #define AUTHOR "van Hauser/THC" #define EMAIL "" #define RESOURCE "http://www.thc.org/thc-hydra" @@ -753,9 +753,10 @@ void hydra_restore_write(int print_msg) { void hydra_restore_read() { FILE *f; char mynull[4]; - int i, j; + int i, j, orig_debug = debug; char out[1024]; + if (debug) printf("[DEBUG] reading restore file %s\n", RESTOREFILE); if ((f = fopen(RESTOREFILE, "r")) == NULL) { fprintf(stderr, "[ERROR] restore file (%s) not found - ", RESTOREFILE); perror(""); @@ -771,6 +772,7 @@ void hydra_restore_read() { } fck = (int) fread(&bf_options, sizeof(bf_options), 1, f); fck = (int) fread(mynull, sizeof(mynull), 1, f); + if (debug) printf("[DEBUG] reading restore file: Step 1 complete\n"); if (mynull[0] + mynull[1] + mynull[2] + mynull[3] == 0) { bf_options.crs = NULL; } else { @@ -778,6 +780,7 @@ void hydra_restore_read() { memcpy(bf_options.crs, mynull, sizeof(mynull)); fck = fread(bf_options.crs + sizeof(mynull), BF_CHARSMAX - sizeof(mynull), 1, f); } + if (debug) printf("[DEBUG] reading restore file: Step 2 complete\n"); fck = (int) fread(&hydra_brains, sizeof(hydra_brain), 1, f); hydra_brains.ofp = stdout; @@ -785,6 +788,11 @@ void hydra_restore_read() { hydra_options.restore = 1; verbose = hydra_options.verbose; debug = hydra_options.debug; + if (debug || orig_debug) printf("[DEBUG] run_debug %d, orig_debug %d\n", debug, orig_debug); + if (orig_debug) { + debug = 1; + hydra_options.debug = 1; + } waittime = hydra_options.waittime; conwait = hydra_options.conwait; port = hydra_options.port; @@ -795,28 +803,35 @@ void hydra_restore_read() { sck = fgets(out, sizeof(out), f); if (out[0] != 0 && out[strlen(out) - 1] == '\n') out[strlen(out) - 1] = 0; + if (debug) printf("[DEBUG] reading restore file: Step 3 complete\n"); if (strlen(out) > 0) { hydra_options.outfile_ptr = malloc(strlen(out) + 1); strcpy(hydra_options.outfile_ptr, out); } else hydra_options.outfile_ptr = NULL; + if (debug) printf("[DEBUG] reading restore file: Step 4 complete\n"); sck = fgets(out, sizeof(out), f); if (out[0] != 0 && out[strlen(out) - 1] == '\n') out[strlen(out) - 1] = 0; + if (debug) printf("[DEBUG] reading restore file: Step 5 complete\n"); if (strlen(out) == 0) hydra_options.miscptr = NULL; else { hydra_options.miscptr = malloc(strlen(out) + 1); strcpy(hydra_options.miscptr, out); } + if (debug) printf("[DEBUG] reading restore file: Step 6 complete\n"); sck = fgets(out, sizeof(out), f); if (out[0] != 0 && out[strlen(out) - 1] == '\n') out[strlen(out) - 1] = 0; + if (debug) printf("[DEBUG] reading restore file: Step 7 complete\n"); hydra_options.service = malloc(strlen(out) + 1); strcpy(hydra_options.service, out); + if (debug) printf("[DEBUG] reading restore file: Step 8 complete\n"); login_ptr = malloc(hydra_brains.sizelogin); fck = (int) fread(login_ptr, hydra_brains.sizelogin, 1, f); + if (debug) printf("[DEBUG] reading restore file: Step 9 complete\n"); if ((hydra_options.mode & 64) != 64) { // NOT colonfile mode pass_ptr = malloc(hydra_brains.sizepass); fck = (int) fread(pass_ptr, hydra_brains.sizepass, 1, f); @@ -824,6 +839,7 @@ void hydra_restore_read() { hydra_options.colonfile = empty_login; // dummy pass_ptr = csv_ptr = login_ptr; } + if (debug) printf("[DEBUG] reading restore file: Step 10 complete\n"); hydra_targets = malloc((hydra_brains.targets + 3) * sizeof(hydra_targets)); for (j = 0; j < hydra_brains.targets; j++) { @@ -873,6 +889,7 @@ void hydra_restore_read() { hydra_targets[j]->use_count = 0; hydra_targets[j]->failed = 0; } + if (debug) printf("[DEBUG] reading restore file: Step 11 complete\n"); hydra_heads = malloc((hydra_options.max_use + 2) * sizeof(int) + 8); for (j = 0; j < hydra_options.max_use; j++) { hydra_heads[j] = malloc(sizeof(hydra_head)); @@ -890,6 +907,7 @@ void hydra_restore_read() { if (hydra_heads[j]->redo) { if (out[0] != 0 && out[strlen(out) - 1] == '\n') out[strlen(out) - 1] = 0; +if (debug) printf("[DEBUG] TEMP head %d: out[0] == %d, hydra_heads[j]->current_login_ptr[0] == %d\n", j, out[0], hydra_heads[j]->current_login_ptr[0]); if (out[0] != 0 || hydra_heads[j]->current_login_ptr[0] != 0) { hydra_heads[j]->current_pass_ptr = malloc(strlen(out) + 1); strcpy(hydra_heads[j]->current_pass_ptr, out); @@ -904,6 +922,7 @@ void hydra_restore_read() { hydra_heads[j]->current_login_ptr = hydra_heads[j]->current_pass_ptr = empty_login; } } + if (debug) printf("[DEBUG] reading restore file: Step 12 complete\n"); sck = fgets(out, sizeof(out), f); if (out[0] != 0 && out[strlen(out) - 1] == '\n') out[strlen(out) - 1] = 0; @@ -2161,7 +2180,7 @@ int main(int argc, char *argv[]) { // command line processing if (argc > 1 && strncmp(argv[1], "-h", 2) == 0) help(1); - if (argc < 3 && (argc < 2 || strcmp(argv[1], "-R") != 0)) + if (argc < 2) help(0); while ((i = getopt(argc, argv, "hq64Rde:vVl:fFg:L:p:P:o:M:C:t:T:m:w:W:s:SUux:")) >= 0) { switch (i) { @@ -2182,8 +2201,6 @@ int main(int argc, char *argv[]) { break; case 'R': hydra_options.restore = 1; - if (argc > 2 + debug + verbose) - bail("no option may be supplied together with -R"); break; case 'd': hydra_options.debug = debug = 1; @@ -2322,6 +2339,9 @@ int main(int argc, char *argv[]) { if (debug) printf("[DEBUG] Ouput color flag is %d\n", colored_output); + if (hydra_options.restore && argc > 2 + debug + verbose) + bail("no option may be supplied together with -R"); + printf("%s (%s) starting at %s\n", PROGRAM, RESOURCE, hydra_build_time()); if (debug) { printf("[DEBUG] cmdline: ");