mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-20 21:33:51 -07:00
Merge pull request #69 from renatoalencar/master
Add gzip support as proposed in issue #68
This commit is contained in:
commit
8eacfaec9f
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"
|
STRIP="strip"
|
||||||
echo
|
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) ..."
|
echo "Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ..."
|
||||||
if [ "X" != "X$DEBUG" ]; then
|
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_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
|
if [ -n "$RSA" ]; then
|
||||||
XDEFINES="$XDEFINES -DNO_RSA_LEGACY"
|
XDEFINES="$XDEFINES -DNO_RSA_LEGACY"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$HAVE_ZLIB" ]; then
|
||||||
|
XDEFINES="$XDEFINES -DHAVE_ZLIB"
|
||||||
|
fi
|
||||||
|
|
||||||
OLDPATH=""
|
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
|
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
|
if [ "$OLDPATH" = "$i" ]; then
|
||||||
|
@ -1077,6 +1094,9 @@ fi
|
||||||
if [ -n "$ORACLE_IPATH" ]; then
|
if [ -n "$ORACLE_IPATH" ]; then
|
||||||
XIPATHS="$XIPATHS -I$ORACLE_IPATH"
|
XIPATHS="$XIPATHS -I$ORACLE_IPATH"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$HAVE_ZLIB" ]; then
|
||||||
|
XLIBS="$XLIBS -lz"
|
||||||
|
fi
|
||||||
if [ -n "$CURSES_PATH" ]; then
|
if [ -n "$CURSES_PATH" ]; then
|
||||||
XLIBS="$XLIBS -lcurses"
|
XLIBS="$XLIBS -lcurses"
|
||||||
fi
|
fi
|
||||||
|
|
4
crc32.c
4
crc32.c
|
@ -89,6 +89,8 @@ unsigned int crc32_tab[] = {
|
||||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef HAVE_ZLIB
|
||||||
|
|
||||||
unsigned int crc32(const void *buf, unsigned int size) {
|
unsigned int crc32(const void *buf, unsigned int size) {
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
unsigned int crc;
|
unsigned int crc;
|
||||||
|
@ -101,3 +103,5 @@ unsigned int crc32(const void *buf, unsigned int size) {
|
||||||
|
|
||||||
return crc ^ ~0U;
|
return crc ^ ~0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
2
crc32.h
2
crc32.h
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_ZLIB
|
||||||
unsigned int crc32(const void *buf, unsigned int size);
|
unsigned int crc32(const void *buf, unsigned int size);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#include "hydra-mod.h"
|
#include "hydra-mod.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#else
|
||||||
#include "crc32.h"
|
#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;
|
teamspeak.loginlen = 0;
|
||||||
strcpy((char *) &teamspeak.login, "");
|
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));
|
teamspeak.crc = crc32(&teamspeak, sizeof(struct team_speak));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hydra_send(s, (char *) &teamspeak, sizeof(struct team_speak), 0) < 0) {
|
if (hydra_send(s, (char *) &teamspeak, sizeof(struct team_speak), 0) < 0) {
|
||||||
return 3;
|
return 3;
|
||||||
|
|
38
hydra.c
38
hydra.c
|
@ -7,7 +7,6 @@
|
||||||
*
|
*
|
||||||
* License: GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see LICENSE file
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see LICENSE file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hydra.h"
|
#include "hydra.h"
|
||||||
#include "bfg.h"
|
#include "bfg.h"
|
||||||
|
|
||||||
|
@ -1000,14 +999,27 @@ void kill_children(int signo) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long int countlines(FILE * fp, int colonmode) {
|
unsigned long int countlines(FILE * fd, int colonmode) {
|
||||||
size_t lines = 0;
|
size_t lines = 0;
|
||||||
char *buf = malloc(MAXLINESIZE);
|
char *buf = malloc(MAXLINESIZE);
|
||||||
int only_one_empty_line = 0;
|
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)) {
|
while (!feof(fp)) {
|
||||||
if (fgets(buf, MAXLINESIZE, fp) != NULL) {
|
if (fgets(buf, MAXLINESIZE, fp) != NULL) {
|
||||||
|
#endif
|
||||||
|
size_of_data += strlen(buf);
|
||||||
if (buf[0] != 0) {
|
if (buf[0] != 0) {
|
||||||
if (buf[0] == '\r' || buf[0] == '\n') {
|
if (buf[0] == '\r' || buf[0] == '\n') {
|
||||||
if (only_one_empty_line == 0) {
|
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);
|
rewind(fp);
|
||||||
|
#endif
|
||||||
free(buf);
|
free(buf);
|
||||||
(void) fstat(fileno(fp), &st);
|
|
||||||
size_of_data = st.st_size + 1;
|
|
||||||
return lines;
|
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;
|
char tmp[MAXBUF + 4] = "", *ptr2;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
int only_one_empty_line = 0;
|
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)) {
|
while (!feof(fp)) {
|
||||||
if (fgets(tmp, MAXLINESIZE, fp) != NULL) {
|
if (fgets(tmp, MAXLINESIZE, fp) != NULL) {
|
||||||
|
#endif
|
||||||
if (tmp[0] != 0) {
|
if (tmp[0] != 0) {
|
||||||
if (tmp[strlen(tmp) - 1] == '\n')
|
if (tmp[strlen(tmp) - 1] == '\n')
|
||||||
tmp[strlen(tmp) - 1] = '\0';
|
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);
|
fclose(fp);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *hydra_build_time() {
|
char *hydra_build_time() {
|
||||||
|
|
4
hydra.h
4
hydra.h
|
@ -35,6 +35,10 @@
|
||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OPTION_SSL 1
|
#define OPTION_SSL 1
|
||||||
|
|
||||||
#define PORT_NOPORT -1
|
#define PORT_NOPORT -1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue