From 1503c8a381236b3f99ad57ed17c2c4dce501502c Mon Sep 17 00:00:00 2001 From: catatonic Date: Fri, 7 Jul 2017 19:34:52 +0000 Subject: [PATCH] Checking for gcrypt support & disabling radmin2 when it is unavailable. --- Makefile.am | 2 +- configure | 24 ++++++++++++++++++++++++ hydra-radmin2.c | 4 ++++ hydra.c | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 843bac6..6e7b287 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ # OPTS=-I. -O3 # -Wall -g -pedantic -LIBS=-lm -lgcrypt +LIBS=-lm BINDIR = /bin MANDIR ?= /man/man1/ DATADIR ?= /etc diff --git a/configure b/configure index ef77d8f..766fd98 100755 --- a/configure +++ b/configure @@ -36,6 +36,7 @@ CURSES_IPATH="" CRYPTO_PATH="" IDN_PATH="" IDN_IPATH="" +GCRYPT_PATH="" PR29_IPATH="" PCRE_PATH="" PCRE_IPATH="" @@ -242,6 +243,22 @@ if [ "$SSL_IPATH" = "/usr/include" ]; then SSL_IPATH="" fi +echo "Checking for gcrypt (libgcrypt.so) ..." +for i in $LIBDIRS ; do + if [ "X" = "X$GCRYPT_PATH" ]; then + if [ -f "$i/libgcrypt.so" -o -f "$i/libgcrypt.dylib" -o -f "$i/libgcrypt.a" -o -f "$i/libgcrypt.dll.a" -o -f "$i/libgcrypt.la" ]; then + HAVE_GCRYPT="y" + fi + fi +done +if [ -n "$HAVE_GCRYPT" ]; then + echo " ... found" +else + echo " ... gcrypt not found, gcrypt support disabled" +fi + + + echo "Checking for idn (libidn.so) ..." for i in $LIBDIRS ; do if [ "X" = "X$IDN_PATH" ]; then @@ -1069,6 +1086,10 @@ fi if [ -n "$HAVE_ZLIB" ]; then XDEFINES="$XDEFINES -DHAVE_ZLIB" fi +if [ -n "$HAVE_GCRYPT" ]; then + XDEFINES="$XDEFINES -DHAVE_GCRYPT" +fi + OLDPATH="" for i in $SSL_PATH $FIREBIRD_PATH $WORACLE_LIB_PATH $PCRE_PATH $IDN_PATH $CRYPTO_PATH $SSH_PATH $NSL_PATH $SOCKET_PATH $RESOLV_PATH $SAPR3_PATH $POSTGRES_PATH $SVN_PATH $NCP_PATH $CURSES_PATH $ORACLE_PATH $AFP_PATH $MYSQL_PATH; do @@ -1124,6 +1145,9 @@ fi if [ -n "$ORACLE_IPATH" ]; then XIPATHS="$XIPATHS -I$ORACLE_IPATH" fi +if [ -n "$HAVE_GCRYPT" ]; then + XLIBS="$XLIBS -lgcrypt" +fi if [ -n "$HAVE_ZLIB" ]; then XLIBS="$XLIBS -lz" fi diff --git a/hydra-radmin2.c b/hydra-radmin2.c index 9985b52..7c09b3b 100644 --- a/hydra-radmin2.c +++ b/hydra-radmin2.c @@ -1,7 +1,9 @@ #include "hydra-mod.h" #include #include +#ifdef HAVE_GCRYPT #include +#endif extern char *HYDRA_EXIT; @@ -167,6 +169,7 @@ int start_radmin2(int s, char *ip, int port, unsigned char options, char *miscpt } void service_radmin2(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname) { +#ifdef HAVE_GCRYPT int sock = -1; int index; int bytecount; @@ -341,6 +344,7 @@ void service_radmin2(char *ip, int sp, unsigned char options, char *miscptr, FIL hydra_child_exit(2); } } +#endif } int service_radmin2_init(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname) { diff --git a/hydra.c b/hydra.c index 2061a31..2c90c5a 100644 --- a/hydra.c +++ b/hydra.c @@ -57,7 +57,9 @@ extern void service_http_proxy_urlenum(char *ip, int sp, unsigned char options, extern void service_s7_300(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); extern void service_rtsp(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); extern void service_rpcap(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); +#ifdef HAVE_GCRYPT extern void service_radmin2(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); +#endif // ADD NEW SERVICES HERE @@ -148,7 +150,9 @@ extern int service_xmpp_init(char *ip, int sp, unsigned char options, char *misc extern int service_s7_300_init(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); extern int service_rtsp_init(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); extern int service_rpcap_init(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); +#ifdef HAVE_GCRYPT extern int service_radmin2_init(char *ip, int sp, unsigned char options, char *miscptr, FILE * fp, int port, char *hostname); +#endif // ADD NEW SERVICES HERE @@ -1265,8 +1269,10 @@ void hydra_service_init(int target_no) { x = service_rtsp_init(hydra_targets[target_no]->ip, -1, options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[target_no]->target); if (strcmp(hydra_options.service, "rpcap") == 0) x = service_rpcap_init(hydra_targets[target_no]->ip, -1, options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[target_no]->target); +#ifdef HAVE_GCRYPT if (strcmp(hydra_options.service, "radmin2") == 0) x = service_radmin2_init(hydra_targets[target_no]->ip, -1, options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[target_no]->target); +#endif // ADD NEW SERVICES HERE @@ -1473,8 +1479,10 @@ int hydra_spawn_head(int head_no, int target_no) { service_rtsp(hydra_targets[target_no]->ip, hydra_heads[head_no]->sp[1], options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[hydra_heads[head_no]->target_no]->target); if (strcmp(hydra_options.service, "rpcap") == 0) service_rpcap(hydra_targets[target_no]->ip, hydra_heads[head_no]->sp[1], options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[hydra_heads[head_no]->target_no]->target); +#ifdef HAVE_GCRYPT if (strcmp(hydra_options.service, "radmin2") == 0) service_radmin2(hydra_targets[target_no]->ip, hydra_heads[head_no]->sp[1], options, hydra_options.miscptr, hydra_brains.ofp, hydra_targets[target_no]->port, hydra_targets[hydra_heads[head_no]->target_no]->target); +#endif // ADD NEW SERVICES HERE @@ -3275,7 +3283,11 @@ int main(int argc, char *argv[]) { i = 1; } if (strcmp(hydra_options.service, "radmin2") == 0) +#ifdef HAVE_GCRYPT i = 1; +#else + bail("Compiled without gcrypt support"); +#endif // ADD NEW SERVICES HERE