Skip to content

Commit

Permalink
big int to stdint switch
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Jul 5, 2017
1 parent 74931e3 commit f124c26
Show file tree
Hide file tree
Showing 73 changed files with 1,367 additions and 1,238 deletions.
89 changes: 87 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,90 @@
all:
@echo Error: you must run "./configure" first
CC=gcc
STRIP=strip
XDEFINES= -DLIBOPENSSL -DHAVE_PCRE -DLIBSVN -DLIBSSH -DHAVE_ZLIB -DHAVE_MATH_H
XLIBS= -lz -lssl -lpcre -lsvn_client-1 -lapr-1 -laprutil-1 -lsvn_subr-1 -lssh -lcrypto
XLIBPATHS=-L/usr/lib -L/usr/local/lib -L/lib -L/lib -L/usr/local/lib -L/lib
XIPATHS= -I/usr/include -I/usr/local/include -I/usr/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/subversion-1
PREFIX=/usr/local
XHYDRA_SUPPORT=
STRIP=strip

HYDRA_LOGO=hydra-logo.o
PWI_LOGO=pw-inspector-logo.o
SEC=-fstack-protector-all --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2

#
# Makefile for Hydra - (c) 2001-2017 by van Hauser / THC <[email protected]>
#
OPTS=-I. -O3
# -Wall -g -pedantic
LIBS=-lm
BINDIR = /bin
MANDIR ?= /man/man1/
DATADIR ?= /etc
DESTDIR ?=

SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
hydra-telnet.c hydra-cisco.c hydra-http.c hydra-ftp.c hydra-imap.c \
hydra-pop3.c hydra-smb.c hydra-icq.c hydra-cisco-enable.c hydra-ldap.c \
hydra-mysql.c hydra-mssql.c hydra-xmpp.c hydra-http-proxy-urlenum.c \
hydra-snmp.c hydra-cvs.c hydra-smtp.c hydra-smtp-enum.c hydra-sapr3.c hydra-ssh.c \
hydra-sshkey.c hydra-teamspeak.c hydra-postgres.c hydra-rsh.c hydra-rlogin.c \
hydra-oracle-listener.c hydra-svn.c hydra-pcanywhere.c hydra-sip.c \
hydra-oracle.c hydra-vmauthd.c hydra-asterisk.c hydra-firebird.c hydra-afp.c hydra-ncp.c \
hydra-oracle-sid.c hydra-http-proxy.c hydra-http-form.c hydra-irc.c \
hydra-rdp.c hydra-s7-300.c hydra-redis.c hydra-adam6500.c \
crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c hydra-rtsp.c hydra-time.c hydra-rpcap.c
OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
hydra-telnet.o hydra-cisco.o hydra-http.o hydra-ftp.o hydra-imap.o \
hydra-pop3.o hydra-smb.o hydra-icq.o hydra-cisco-enable.o hydra-ldap.o \
hydra-mysql.o hydra-mssql.o hydra-xmpp.o hydra-http-proxy-urlenum.o \
hydra-snmp.o hydra-cvs.o hydra-smtp.o hydra-smtp-enum.o hydra-sapr3.o hydra-ssh.o \
hydra-sshkey.o hydra-teamspeak.o hydra-postgres.o hydra-rsh.o hydra-rlogin.o \
hydra-oracle-listener.o hydra-svn.o hydra-pcanywhere.o hydra-sip.o \
hydra-oracle-sid.o hydra-oracle.o hydra-vmauthd.o hydra-asterisk.o hydra-firebird.o hydra-afp.o hydra-ncp.o \
hydra-http-proxy.o hydra-http-form.o hydra-irc.o hydra-redis.o \
hydra-rdp.o hydra-s7-300.c hydra-adam6500.o \
crc32.o d3des.o bfg.o ntlm.o sasl.o hmacmd5.o hydra-mod.o hydra-rtsp.o hydra-time.o hydra-rpcap.o
BINS = hydra pw-inspector

EXTRA_DIST = README README.arm README.palm CHANGES TODO INSTALL LICENSE \
hydra-mod.h hydra.h crc32.h d3des.h

all: pw-inspector hydra $(XHYDRA_SUPPORT)
@echo
@echo Now type "make install"

hydra: hydra.c $(OBJ)
$(CC) $(OPTS) $(SEC) $(LIBS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o hydra $(HYDRA_LOGO) hydra.c $(OBJ) $(LIBS) $(XLIBS) $(XLIBPATHS) $(XIPATHS) $(XDEFINES)
@echo
@echo If men could get pregnant, abortion would be a sacrament
@echo

xhydra:
-cd hydra-gtk && sh ./make_xhydra.sh

pw-inspector: pw-inspector.c
-$(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o pw-inspector $(PWI_LOGO) pw-inspector.c

.c.o:
$(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) -c $< $(XDEFINES) $(XIPATHS)

strip: all
strip $(BINS)
-echo OK > /dev/null && test -x xhydra && strip xhydra || echo OK > /dev/null

install: strip
-mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
cp -f hydra-wizard.sh $(BINS) $(DESTDIR)$(PREFIX)$(BINDIR) && cd $(DESTDIR)$(PREFIX)$(BINDIR) && chmod 755 hydra-wizard.sh $(BINS)
-echo OK > /dev/null && test -x xhydra && cp xhydra $(DESTDIR)$(PREFIX)$(BINDIR) && cd $(DESTDIR)$(PREFIX)$(BINDIR) && chmod 755 xhydra || echo OK > /dev/null
-sed -e "s|^INSTALLDIR=.*|INSTALLDIR="$(PREFIX)"|" dpl4hydra.sh | sed -e "s|^LOCATION=.*|LOCATION="$(DATADIR)"|" > $(DESTDIR)$(PREFIX)$(BINDIR)/dpl4hydra.sh
-chmod 755 $(DESTDIR)$(PREFIX)$(BINDIR)/dpl4hydra.sh
-mkdir -p $(DESTDIR)$(PREFIX)$(DATADIR)
-cp -f *.csv $(DESTDIR)$(PREFIX)$(DATADIR)
-mkdir -p $(DESTDIR)$(PREFIX)$(MANDIR)
-cp -f hydra.1 xhydra.1 pw-inspector.1 $(DESTDIR)$(PREFIX)$(MANDIR)

clean:
rm -rf xhydra pw-inspector hydra *.o core *.core *.stackdump *~ Makefile.in Makefile dev_rfc hydra.restore arm/*.ipk arm/ipkg/usr/bin/* hydra-gtk/src/*.o hydra-gtk/src/xhydra hydra-gtk/stamp-h hydra-gtk/config.status hydra-gtk/errors hydra-gtk/config.log hydra-gtk/src/.deps hydra-gtk/src/Makefile hydra-gtk/Makefile
cp -f Makefile.orig Makefile

27 changes: 17 additions & 10 deletions bfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@
#include <string.h>
#include <math.h>
#include <ctype.h>
#ifdef __sun
#include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#include "bfg.h"

bf_option bf_options;

#ifdef HAVE_MATH_H

extern int debug;
extern int32_t debug;

static int add_single_char(char ch, char flags, int* crs_len) {
static int32_t add_single_char(char ch, char flags, int32_t* crs_len) {
if ((ch >= '2' && ch <= '9') || ch == '0') {
if ((flags & BF_NUMS) > 0) {
printf("[ERROR] character %c defined in -x although the whole number range was already defined by '1', ignored\n", ch);
return 0;
}
//printf("[WARNING] adding character %c for -x, note that '1' will add all numbers from 0-9\n", ch);
}
if (tolower((int) ch) >= 'b' && tolower((int) ch) <= 'z') {
if (tolower((int32_t) ch) >= 'b' && tolower((int32_t) ch) <= 'z') {
if ((ch <= 'Z' && (flags & BF_UPPER) > 0) || (ch > 'Z' && (flags & BF_UPPER) > 0)) {
printf("[ERROR] character %c defined in -x although the whole letter range was already defined by '%c', ignored\n", ch, ch <= 'Z' ? 'A' : 'a');
return 0;
Expand All @@ -43,9 +50,9 @@ static int add_single_char(char ch, char flags, int* crs_len) {
//
// note that we check for -x .:.:ab but not for -x .:.:ba
//
int bf_init(char *arg) {
int i = 0;
int crs_len = 0;
int32_t bf_init(char *arg) {
int32_t i = 0;
int32_t crs_len = 0;
char flags = 0;
char *tmp = strchr(arg, ':');

Expand Down Expand Up @@ -165,10 +172,10 @@ int bf_init(char *arg) {
}


unsigned long int bf_get_pcount() {
int i;
uint64_t bf_get_pcount() {
int32_t i;
double count = 0;
unsigned long int foo;
uint64_t foo;

for (i = bf_options.from; i <= bf_options.to; i++)
count += (pow((double) bf_options.crs_len, (double) i));
Expand All @@ -183,7 +190,7 @@ unsigned long int bf_get_pcount() {


char *bf_next() {
int i, pos = bf_options.current - 1;
int32_t i, pos = bf_options.current - 1;

if (bf_options.current > bf_options.to)
return NULL; // we are done
Expand Down
6 changes: 3 additions & 3 deletions bfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ typedef struct {
char *arg; /* argument received for bfg commandline option */
char *crs; /* internal representation of charset */
char *ptr; /* ptr to the last generated password */
unsigned int disable_symbols;
uint32_t disable_symbols;
} bf_option;

extern bf_option bf_options;

#ifdef HAVE_MATH_H
extern unsigned long int bf_get_pcount();
extern int bf_init(char *arg);
extern uint64_t bf_get_pcount();
extern int32_t bf_init(char *arg);
extern char *bf_next();
#endif

Expand Down
14 changes: 10 additions & 4 deletions crc32.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*-
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
Expand Down Expand Up @@ -42,8 +41,15 @@
*/

#include <sys/types.h>
#ifdef __sun
#include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h>
#else
#include <stdint.h>
#endif

unsigned int crc32_tab[] = {
uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
Expand Down Expand Up @@ -91,9 +97,9 @@ unsigned int crc32_tab[] = {

#ifndef HAVE_ZLIB

unsigned int crc32(const void *buf, unsigned int size) {
uint32_t crc32(const void *buf, uint32_t size) {
const unsigned char *p;
unsigned int crc;
uint32_t crc;

p = buf;
crc = ~0U;
Expand Down
2 changes: 1 addition & 1 deletion crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <sys/types.h>

#ifndef HAVE_ZLIB
unsigned int crc32(const void *buf, unsigned int size);
uint32_t crc32(const void *buf, uint32_t size);
#endif

#endif
9 changes: 4 additions & 5 deletions d3des.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* 2001 van Hauser for Hydra: commented out KnR Kn3 and Df_Key to remove
compiler warnings for unused definitions.
*/
Expand Down Expand Up @@ -84,9 +83,9 @@ static unsigned char pc2[48] = {

void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
unsigned char *key;
int edf;
int32_t edf;
{
register int i, j, l, m, n;
register int32_t i, j, l, m, n;
unsigned char pc1m[56], pcr[56];
unsigned long kn[32];

Expand Down Expand Up @@ -132,7 +131,7 @@ static void cookey(raw1)
{
register unsigned long *cook, *raw0;
unsigned long dough[32];
register int i;
register int32_t i;

cook = dough;
for (i = 0; i < 16; i++, raw1++) {
Expand Down Expand Up @@ -367,7 +366,7 @@ static void desfunc(block, keys)
register unsigned long *block, *keys;
{
register unsigned long fval, work, right, leftt;
register int round;
register int32_t round;

leftt = block[0];
right = block[1];
Expand Down
9 changes: 8 additions & 1 deletion d3des.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#ifdef __sun
#include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h>
#else
#include <stdint.h>
#endif

/*
* This is D3DES (V5.09) by Richard Outerbridge with the double and
Expand All @@ -23,7 +30,7 @@
#define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */

extern void deskey(unsigned char *, int);
extern void deskey(unsigned char *, int32_t);

/* hexkey[8] MODE
* Sets the internal key register according to the hexadecimal
Expand Down
12 changes: 6 additions & 6 deletions hmacmd5.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
the rfc 2104 version of hmac_md5 initialisation.
***********************************************************************/

void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context * ctx) {
int i;
void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context * ctx) {
int32_t i;
unsigned char tk[16];

/* if key is longer than 64 bytes reset it to key=MD5(key) */
Expand Down Expand Up @@ -79,8 +79,8 @@ void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context
the microsoft version of hmac_md5 initialisation.
***********************************************************************/

void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len, HMACMD5Context * ctx) {
int i;
void hmac_md5_init_limK_to_64(const unsigned char *key, int32_t key_len, HMACMD5Context * ctx) {
int32_t i;

/* if key is longer than 64 bytes truncate it */
if (key_len > 64) {
Expand All @@ -107,7 +107,7 @@ void hmac_md5_init_limK_to_64(const unsigned char *key, int key_len, HMACMD5Cont
update hmac_md5 "inner" buffer
***********************************************************************/

void hmac_md5_update(const unsigned char *text, int text_len, HMACMD5Context * ctx) {
void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context * ctx) {
MD5_Update(&ctx->ctx, (void *) text, text_len); /* then text of datagram */
}

Expand All @@ -131,7 +131,7 @@ void hmac_md5_final(unsigned char *digest, HMACMD5Context * ctx)
use the microsoft hmacmd5 init method because the key is 16 bytes.
************************************************************/

void hmac_md5(unsigned char key[16], unsigned char *data, int data_len, unsigned char *digest) {
void hmac_md5(unsigned char key[16], unsigned char *data, int32_t data_len, unsigned char *digest) {
HMACMD5Context ctx;

hmac_md5_init_limK_to_64(key, 16, &ctx);
Expand Down
15 changes: 11 additions & 4 deletions hmacmd5.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
*/

#ifdef __sun
#include <sys/int_types.h>
#elif defined(__FreeBSD__) || defined(__IBMCPP__) || defined(_AIX)
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#include <openssl/md5.h>
#ifndef _HMAC_MD5_H

Expand All @@ -41,10 +48,10 @@ typedef struct {
#endif /* _HMAC_MD5_H */


void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context *ctx);
void hmac_md5_init_limK_to_64(const unsigned char* key, int key_len,HMACMD5Context *ctx);
void hmac_md5_update(const unsigned char *text, int text_len, HMACMD5Context *ctx);
void hmac_md5_init_rfc2104(const unsigned char *key, int32_t key_len, HMACMD5Context *ctx);
void hmac_md5_init_limK_to_64(const unsigned char* key, int32_t key_len,HMACMD5Context *ctx);
void hmac_md5_update(const unsigned char *text, int32_t text_len, HMACMD5Context *ctx);
void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx);
void hmac_md5( unsigned char key[16], unsigned char *data, int data_len, unsigned char *digest);
void hmac_md5( unsigned char key[16], unsigned char *data, int32_t data_len, unsigned char *digest);


Loading

0 comments on commit f124c26

Please sign in to comment.