Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating hydra support for freedrdp 3 #538

Merged
merged 10 commits into from
Jul 7, 2020
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ install: strip
-cp -f *.csv $(DESTDIR)$(PREFIX)$(DATADIR)
-mkdir -p $(DESTDIR)$(PREFIX)$(MANDIR)
-cp -f hydra.1 xhydra.1 pw-inspector.1 $(DESTDIR)$(PREFIX)$(MANDIR)
-ldconfig
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why that? that would only be needed if a new shared library would be installed (which hydra does not have).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for "libfreerdp3.so.3" which is loaded as a shared library, not sure why this is the case for v3 and not for v2. This is the error I get when ldconfig is not done:

/usr/local/bin/hydra: error while loading shared libraries: libfreerdp3.so.3: cannot open shared object file: No such file or directory


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
Expand Down
100 changes: 96 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ MANDIR=""
XHYDRA_SUPPORT=""
FREERDP2_PATH=""
WINPR2_PATH=""
FREERDP3_PATH=""
WINPR3_PATH=""
SMBC_PATH=""
SMBC_IPATH=""

Expand Down Expand Up @@ -1017,7 +1019,6 @@ fi
MCACHED_IPATH=""
fi


echo "Checking for Freerdp2 (libfreerdp2.so, freerdp/*.h, libwinpr2.so, winpr/*.h) ..."

for i in $LIBDIRS ; do
Expand Down Expand Up @@ -1083,13 +1084,85 @@ fi
echo " ... found"
fi
if [ "X" = "X$FREERDP2_PATH" -o "X" = "X$FREERDP2_IPATH" -o "X" = "X$WINPR2_PATH" -o "X" = "X$WINPR2_IPATH" ]; then
echo " ... NOT found, module rdp disabled"
echo " ... NOT found, checking freerdp3 module next..."
FREERDP2_PATH=""
FREERDP2_IPATH=""
WINPR2_PATH=""
WINPR2_IPATH=""
fi

echo "Checking for Freerdp3 (libfreerdp3.so, freerdp/*.h, libwinpr3.so, winpr/*.h) ..."

for i in $LIBDIRS ; do
if [ "X" = "X$FREERDP2_PATH" ] && [ "X" = "X$FREERDP3_PATH" ]; then
if [ -f "$i/libfreerdp3.so" -o -f "$i/libfreerdp3.dylib" -o -f "$i/libfreerdp3.a" -o -f "$i/libfreerdp3.dll.a" ]; then
FREERDP3_PATH="$i"
fi
fi
if [ "X" = "X$FREERDP2_PATH" ] && [ "X" = "X$FREERDP3_PATH" ]; then
TMP_LIB=`/bin/ls $i/libfreerdp3*.so* 2> /dev/null | grep libfreerdp3`
if [ -n "$TMP_LIB" ]; then
FREERDP3_PATH="$i"
fi
fi
done

FREERDP3_IPATH=
for i in $INCDIRS ; do
if [ "X" = "X$FREERDP2_IPATH" ] && [ "X" = "X$FREERDP3_IPATH" ]; then
if [ -f "$i/freerdp/freerdp.h" ]; then
FREERDP3_IPATH="$i/freerdp3"
fi
if [ -f "$i/freerdp3/freerdp/freerdp.h" ]; then
FREERDP3_IPATH="$i/freerdp3"
fi
fi
done

for i in $LIBDIRS ; do
if [ "X" = "X$WINPR2_PATH" ] && [ "X" = "X$WINPR3_PATH" ]; then
if [ -f "$i/libwinpr3.so" -o -f "$i/libwinpr3.dylib" -o -f "$i/libwinpr3.a" ]; then
WINPR3_PATH="$i"
fi
fi
if [ "X" = "X$WINPR2_PATH" ] && [ "X" = "X$WINPR3_PATH" ]; then
TMP_LIB=`/bin/ls $i/libwinpr3.dll.a 2> /dev/null | grep winpr`
if [ -n "$TMP_LIB" ]; then
WINPR3_PATH="$i"
fi
fi
done

WINPR3_IPATH=
for i in $INCDIRS ; do
if [ "X" = "X$WINPR2_IPATH" ] && [ "X" = "X$WINPR3_IPATH" ]; then
if [ -f "$i/winpr.h" ]; then
WINPR3_IPATH="$i"
fi
if [ -f "$i/winpr3/winpr/winpr.h" ]; then
WINPR3_IPATH="$i/winpr3"
fi
fi
done

if [ "X" != "X$DEBUG" ]; then
echo DEBUG: FREERDP3_PATH=$FREERDP3_PATH/
echo DEBUG: FREERDP3_IPATH=$FREERDP3_IPATH/
echo DEBUG: WINPR3_PATH=$WINPR3_PATH/
echo DEBUG: WINPR3_IPATH=$WINPR3_IPATH/
fi

if [ -n "$FREERDP3_PATH" -a -n "$FREERDP3_IPATH" -a -n "$WINPR3_PATH" -a -n "$WINPR3_IPATH" ]; then
echo " ... found"
fi
if [ "X" = "X$FREERDP3_PATH" -o "X" = "X$FREERDP3_IPATH" -o "X" = "X$WINPR3_PATH" -o "X" = "X$WINPR3_IPATH" ]; then
echo " ... NOT found, module rdp disabled"
FREERDP3_PATH=""
FREERDP3_IPATH=""
WINPR3_PATH=""
WINPR3_IPATH=""
fi

echo "Checking for Mongodb (libmongoc-1.0.so, mongoc.h, libbson-1.0.so, bson.h) ..."

for i in $LIBDIRS ; do
Expand Down Expand Up @@ -1342,6 +1415,8 @@ if [ -n "$FIREBIRD_PATH" -o \
-n "$MONGOD_PATH" -o \
-n "$FREERDP2_PATH" -o \
-n "$WINPR2_PATH" -o \
-n "$FREERDP3_PATH" -o \
-n "$WINPR3_PATH" -o \
-n "$SMBC_PATH" \
]; then
if [ "$SYSS" = "Darwin" ] && [ ! -d "/lib" ]; then
Expand Down Expand Up @@ -1426,11 +1501,17 @@ if [ -n "$BSON_PATH" ]; then
XDEFINES="$XDEFINES -DLIBBSON"
fi
if [ -n "$FREERDP2_PATH" ]; then
XDEFINES="$XDEFINES -DLIBFREERDP2"
XDEFINES="$XDEFINES -DLIBFREERDP"
fi
if [ -n "$WINPR2_PATH" ]; then
XDEFINES="$XDEFINES -DLIBWINPR2"
fi
if [ -n "$FREERDP3_PATH" ]; then
XDEFINES="$XDEFINES -DLIBFREERDP"
fi
if [ -n "$WINPR3_PATH" ]; then
XDEFINES="$XDEFINES -DLIBWINPR3"
fi
if [ -n "$SMBC_PATH" ]; then
XDEFINES="$XDEFINES -DLIBSMBCLIENT"
fi
Expand Down Expand Up @@ -1459,6 +1540,8 @@ for i in $SSL_PATH \
$BSON_PATH \
$FREERDP2_PATH \
$WINPR2_PATH \
$FREERDP3_PATH \
$WINPR3_PATH \
$SMBC_PATH; do
if [ "$OLDPATH" = "$i" ]; then
OLDPATH="$i"
Expand Down Expand Up @@ -1518,9 +1601,12 @@ fi
if [ -n "$MONGODB_IPATH" ]; then
XIPATHS="$XIPATHS -I$MONGODB_IPATH -I$BSON_IPATH"
fi
if [ -n "$FREERDP2_IPATH" ]; then
if [ -n "$FREERDP3_IPATH" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is wrong, you moved the check to RDP3, but then copy RDP2_IPATH. as the real RDP3 one is below this has to be $FREERDP2_IPATH :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bug is still present

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this today and will update when finished

XIPATHS="$XIPATHS -I$FREERDP2_IPATH -I$WINPR2_IPATH"
fi
if [ -n "$FREERDP3_IPATH" ]; then
XIPATHS="$XIPATHS -I$FREERDP3_IPATH -I$WINPR3_IPATH"
fi
if [ -n "$SMBC_IPATH" ]; then
XIPATHS="$XIPATHS -I$SMBC_IPATH"
fi
Expand Down Expand Up @@ -1605,6 +1691,12 @@ fi
if [ -n "$WINPR2_PATH" ]; then
XLIBS="$XLIBS -lwinpr2"
fi
if [ -n "$FREERDP3_PATH" ]; then
XLIBS="$XLIBS -lfreerdp3"
fi
if [ -n "$WINPR3_PATH" ]; then
XLIBS="$XLIBS -lwinpr3"
Copy link
Owner

@vanhauser-thc vanhauser-thc Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you have not reestablished the previous librdp2 for XLIBS, only librdp3. same for the include paths above and defines etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed the XLIBS and XDEFINES paths

fi
if [ -n "$SMBC_PATH" ]; then
XLIBS="$XLIBS -lsmbclient"
fi
Expand Down
4 changes: 2 additions & 2 deletions hydra-rdp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
This module is using freerdp2 lib
This module is using freerdp3 lib

Tested on:
- Windows 7 pro SP1
Expand All @@ -10,7 +10,7 @@
#include "hydra-mod.h"

extern char *HYDRA_EXIT;
#ifndef LIBFREERDP2
#ifndef LIBFREERDP
void dummy_rdp() { printf("\n"); }
#else

Expand Down
10 changes: 5 additions & 5 deletions hydra.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extern int32_t service_oracle_sid_init(char *ip, int32_t sp, unsigned char optio
extern void service_sip(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname);
extern int32_t service_sip_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname);
#endif
#ifdef LIBFREERDP2
#ifdef LIBFREERDP
extern void service_rdp(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname);
extern int32_t service_rdp_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname);
#endif
Expand Down Expand Up @@ -426,7 +426,7 @@ static const struct {
#endif
SERVICE(redis),
SERVICE(rexec),
#ifdef LIBFREERDP2
#ifdef LIBFREERDP
SERVICE3("rdp", rdp),
#endif
SERVICE(rlogin),
Expand Down Expand Up @@ -2237,7 +2237,7 @@ int main(int argc, char *argv[]) {
strcat(unsupported, "SSL-services (ftps, sip, rdp, oracle-services, ...) ");
#endif

#ifndef LIBFREERDP2
#ifndef LIBFREERDP
// for rdp
SERVICES = hydra_string_replace(SERVICES, " rdp", "");
#endif
Expand Down Expand Up @@ -2905,8 +2905,8 @@ int main(int argc, char *argv[]) {
}

if (strcmp(hydra_options.service, "rdp") == 0) {
#ifndef LIBFREERDP2
bail("Compiled without FREERDP2 support, module not available!");
#ifndef LIBFREERDP
bail("Compiled without FREERDP support, modules not available!");
#endif
}
if (strcmp(hydra_options.service, "pcnfs") == 0) {
Expand Down