mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-05 20:41:39 -07:00
add gzip support for login and password files
* module hydra-teamspeak.c modified, because of conflict of crc32 with zlib crc32
This commit is contained in:
parent
adec22c69f
commit
1aeda5001c
6 changed files with 71 additions and 6 deletions
20
configure
vendored
20
configure
vendored
|
@ -126,6 +126,19 @@ INCDIRS="/usr/include /usr/local/include /opt/include /opt/local/include"
|
|||
STRIP="strip"
|
||||
echo
|
||||
|
||||
echo "Checking for zlib (libz.so, zlib.h) ..."
|
||||
for i in $INCDIRS; do
|
||||
if [ -f "$i/zlib.h" ]; then
|
||||
HAVE_ZLIB="y"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$HAVE_ZLIB" ]; then
|
||||
echo " ... found"
|
||||
else
|
||||
echo " ... zlib not found, gzip support disabled"
|
||||
fi
|
||||
|
||||
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`
|
||||
|
@ -1023,6 +1036,10 @@ fi
|
|||
if [ -n "$RSA" ]; then
|
||||
XDEFINES="$XDEFINES -DNO_RSA_LEGACY"
|
||||
fi
|
||||
if [ -n "$HAVE_ZLIB" ]; then
|
||||
XDEFINES="$XDEFINES -DHAVE_ZLIB"
|
||||
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
|
||||
if [ "$OLDPATH" = "$i" ]; then
|
||||
|
@ -1077,6 +1094,9 @@ fi
|
|||
if [ -n "$ORACLE_IPATH" ]; then
|
||||
XIPATHS="$XIPATHS -I$ORACLE_IPATH"
|
||||
fi
|
||||
if [ -n "$HAVE_ZLIB" ]; then
|
||||
XLIBS="$XLIBS -lz"
|
||||
fi
|
||||
if [ -n "$CURSES_PATH" ]; then
|
||||
XLIBS="$XLIBS -lcurses"
|
||||
fi
|
||||
|
|
4
crc32.c
4
crc32.c
|
@ -89,6 +89,8 @@ unsigned int crc32_tab[] = {
|
|||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
#ifndef HAVE_ZLIB
|
||||
|
||||
unsigned int crc32(const void *buf, unsigned int size) {
|
||||
const unsigned char *p;
|
||||
unsigned int crc;
|
||||
|
@ -101,3 +103,5 @@ unsigned int crc32(const void *buf, unsigned int size) {
|
|||
|
||||
return crc ^ ~0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
2
crc32.h
2
crc32.h
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef HAVE_ZLIB
|
||||
unsigned int crc32(const void *buf, unsigned int size);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "hydra-mod.h"
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include "crc32.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
|
@ -65,7 +70,11 @@ int start_teamspeak(int s, char *ip, int port, unsigned char options, char *misc
|
|||
teamspeak.loginlen = 0;
|
||||
strcpy((char *) &teamspeak.login, "");
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
teamspeak.crc = crc32(0L, &teamspeak, sizeof(struct team_speak));
|
||||
#else
|
||||
teamspeak.crc = crc32(&teamspeak, sizeof(struct team_speak));
|
||||
#endif
|
||||
|
||||
if (hydra_send(s, (char *) &teamspeak, sizeof(struct team_speak), 0) < 0) {
|
||||
return 3;
|
||||
|
|
38
hydra.c
38
hydra.c
|
@ -7,7 +7,6 @@
|
|||
*
|
||||
* License: GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see LICENSE file
|
||||
*/
|
||||
|
||||
#include "hydra.h"
|
||||
#include "bfg.h"
|
||||
|
||||
|
@ -1000,14 +999,27 @@ void kill_children(int signo) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
unsigned long int countlines(FILE * fp, int colonmode) {
|
||||
unsigned long int countlines(FILE * fd, int colonmode) {
|
||||
size_t lines = 0;
|
||||
char *buf = malloc(MAXLINESIZE);
|
||||
int only_one_empty_line = 0;
|
||||
struct stat st;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
gzFile fp = gzdopen(fileno(fd), "r");
|
||||
#else
|
||||
FILE *fp = fd;
|
||||
#endif
|
||||
|
||||
size_of_data = 0;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
while (!gzeof(fp)) {
|
||||
if (gzgets(fp, buf, MAXLINESIZE) != NULL) {
|
||||
#else
|
||||
while (!feof(fp)) {
|
||||
if (fgets(buf, MAXLINESIZE, fp) != NULL) {
|
||||
#endif
|
||||
size_of_data += strlen(buf);
|
||||
if (buf[0] != 0) {
|
||||
if (buf[0] == '\r' || buf[0] == '\n') {
|
||||
if (only_one_empty_line == 0) {
|
||||
|
@ -1020,20 +1032,30 @@ unsigned long int countlines(FILE * fp, int colonmode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_ZLIB
|
||||
gzrewind(fp);
|
||||
#else
|
||||
rewind(fp);
|
||||
#endif
|
||||
free(buf);
|
||||
(void) fstat(fileno(fp), &st);
|
||||
size_of_data = st.st_size + 1;
|
||||
return lines;
|
||||
}
|
||||
|
||||
void fill_mem(char *ptr, FILE * fp, int colonmode) {
|
||||
void fill_mem(char *ptr, FILE * fd, int colonmode) {
|
||||
char tmp[MAXBUF + 4] = "", *ptr2;
|
||||
unsigned int len;
|
||||
int only_one_empty_line = 0;
|
||||
#ifdef HAVE_ZLIB
|
||||
gzFile fp = gzdopen(fileno(fd), "r");
|
||||
|
||||
while (!gzeof(fp)) {
|
||||
if (gzgets(fp, tmp, MAXLINESIZE) != NULL) {
|
||||
#else
|
||||
FILE *fp = fd;
|
||||
|
||||
while (!feof(fp)) {
|
||||
if (fgets(tmp, MAXLINESIZE, fp) != NULL) {
|
||||
#endif
|
||||
if (tmp[0] != 0) {
|
||||
if (tmp[strlen(tmp) - 1] == '\n')
|
||||
tmp[strlen(tmp) - 1] = '\0';
|
||||
|
@ -1069,7 +1091,11 @@ void fill_mem(char *ptr, FILE * fp, int colonmode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_ZLIB
|
||||
gzclose(fp);
|
||||
#else
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *hydra_build_time() {
|
||||
|
|
4
hydra.h
4
hydra.h
|
@ -35,6 +35,10 @@
|
|||
#include <libssh/libssh.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#define OPTION_SSL 1
|
||||
|
||||
#define PORT_NOPORT -1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue