Skip to content

Commit

Permalink
configure CC support, strrchr over rindex
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Jan 31, 2017
1 parent 5ae1531 commit 9c3feee
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog for hydra
-------------------

Release 8.5-dev
* ./configure now honors the CC enviroment variable if present
* Favor strrchr() over rindex()


Release 8.4
! Reports came in that the rdp module is not working reliable sometimes, most likely against new Windows versions. please test, report and if possible send a fix
* Proxy support re-implemented:
Expand Down
26 changes: 15 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo " --nostrip do not per default strip binaries before install"
echo " --debug show debug output to trace errors"
echo " --help this here"
echo
echo If the CC environment variable is set, this is used as the compiler for the configure tests. The default is \"gcc\" otherwise.
exit 0
fi

test -z "$CC" && CC=gcc

FHS=""
SIXFOUR=""
DEBUG=""
Expand Down Expand Up @@ -966,37 +970,37 @@ fi

echo "Checking for Android specialities ..."
TMPC=comptest$$
RINDEX=" not"
STRRCHR=" not"
echo '#include <stdio.h>' > $TMPC.c
echo '#include <strings.h>' >> $TMPC.c
echo "int main() { char *x = rindex(\"test\", 'e'); if (x == NULL) return 0; else return 1; }" >> $TMPC.c
gcc -o $TMPC $TMPC.c > /dev/null 2>&1
test -x $TMPC && RINDEX=""
echo "int main() { char *x = strrchr(\"test\", 'e'); if (x == NULL) return 0; else return 1; }" >> $TMPC.c
$CC -o $TMPC $TMPC.c > /dev/null 2>&1
test -x $TMPC && STRRCHR=""
rm -f $TMPC $TMPC.c
echo " ... rindex()$RINDEX found"
echo " ... strrchr()$STRRCHR found"
if [ -n "$CRYPTO_PATH" ]; then
RSA=" not"
echo '#include <stdio.h>' > $TMPC.c
echo '#include <openssl/rsa.h>' >> $TMPC.c
echo "int main() { RSA *rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c
#echo "int main() { RSA *rsa; RSA_generate_key_ex(rsa, 1024, 0, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c
gcc -o $TMPC $TMPC.c -lssl -lcrypto > /dev/null 2>&1
$CC -o $TMPC $TMPC.c -lssl -lcrypto > /dev/null 2>&1
test -x $TMPC && RSA=""
rm -f $TMPC $TMPC.c
echo " ... RSA_generate_key()$RSA found"
fi

echo "Checking for secure compile option support in gcc ..."
echo "Checking for secure compile option support in $CC ..."
GCCSEC="no"
LDSEC="no"
GCCSECOPT="-fstack-protector-all --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
echo '#include <stdio.h>' > $TMPC.c
echo 'int main() { printf(""); return 0; }' >> $TMPC.c
gcc -pie -fPIE $GCCSEPOPT -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
$CC -pie -fPIE $GCCSEPOPT -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
test -x $TMPC && GCCSEC="yes"
grep -q fPI $TMPC.c.err || GCCSECOPT="-pie -fPIE $GCCSECOPT"
rm -f "$TMPC"
gcc $GCCSECOPT -Wl,-z,now -Wl,-z,relro -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
$CC $GCCSECOPT -Wl,-z,now -Wl,-z,relro -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
test -x $TMPC && { LDSEC="yes" ; GCCSECOPT="$GCCSECOPT -Wl,-z,now -Wl,-z,relro" ; }
rm -f $TMPC $TMPC.c $TMPC.c.err
echo " Compiling... $GCCSEC"
Expand Down Expand Up @@ -1060,8 +1064,8 @@ fi
if [ -n "$SSH_PATH" ]; then
XDEFINES="$XDEFINES -DLIBSSH"
fi
if [ -n "$RINDEX" ]; then
XDEFINES="$XDEFINES -DNO_RINDEX"
if [ -n "$STRRCHR" ]; then
XDEFINES="$XDEFINES -DNO_STRRCHR"
fi
if [ -n "$RSA" ]; then
XDEFINES="$XDEFINES -DNO_RSA_LEGACY"
Expand Down
6 changes: 3 additions & 3 deletions hydra-nntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ char *nntp_read_server_capacity(int sock) {
buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0;
#ifdef NO_RINDEX
if ((ptr = strrchr(buf, '\n')) != NULL) {
#else
#ifdef NO_STRRCHR
if ((ptr = rindex(buf, '\n')) != NULL) {
#else
if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif
ptr++;
if (isdigit((int) *ptr) && *(ptr + 3) == ' ')
Expand Down
6 changes: 3 additions & 3 deletions hydra-smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ char *smtp_read_server_capacity(int sock) {
buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0;
#ifdef NO_RINDEX
if ((ptr = strrchr(buf, '\n')) != NULL) {
#else
#ifdef NO_STRRCHR
if ((ptr = rindex(buf, '\n')) != NULL) {
#else
if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif
ptr++;
if (isdigit((int) *ptr) && *(ptr + 3) == ' ')
Expand Down
2 changes: 1 addition & 1 deletion hydra.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ char *SERVICES =
#define RESTOREFILE "./hydra.restore"

#define PROGRAM "Hydra"
#define VERSION "v8.4"
#define VERSION "v8.5-dev"
#define AUTHOR "van Hauser/THC"
#define EMAIL "<[email protected]>"
#define RESOURCE "http://www.thc.org/thc-hydra"
Expand Down

0 comments on commit 9c3feee

Please sign in to comment.