mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-05 12:36:09 -07:00
Add module for mongodb
This commit is contained in:
parent
6575bf964d
commit
012fbe6d1b
10 changed files with 330 additions and 9 deletions
|
@ -41,6 +41,7 @@ LOCAL_SRC_FILES:= \
|
||||||
hydra-ldap.c\
|
hydra-ldap.c\
|
||||||
hydra-mod.c\
|
hydra-mod.c\
|
||||||
hydra-memcached.c\
|
hydra-memcached.c\
|
||||||
|
hydra-mongodb.c\
|
||||||
hydra-mssql.c\
|
hydra-mssql.c\
|
||||||
hydra-mysql.c\
|
hydra-mysql.c\
|
||||||
hydra-ncp.c\
|
hydra-ncp.c\
|
||||||
|
|
1
CHANGES
1
CHANGES
|
@ -6,6 +6,7 @@ Release 8.9-dev
|
||||||
* Fixed svn module memory leaks
|
* Fixed svn module memory leaks
|
||||||
* Fixed rtsp module potential buffer overflow
|
* Fixed rtsp module potential buffer overflow
|
||||||
* Added memcached module
|
* Added memcached module
|
||||||
|
* Added mongodb module
|
||||||
|
|
||||||
|
|
||||||
Release 8.9.1
|
Release 8.9.1
|
||||||
|
|
|
@ -12,7 +12,7 @@ DESTDIR ?=
|
||||||
SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
|
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-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-pop3.c hydra-smb.c hydra-icq.c hydra-cisco-enable.c hydra-ldap.c \
|
||||||
hydra-memcached.c hydra-mysql.c hydra-mssql.c hydra-xmpp.c \
|
hydra-memcached.c hydra-mongodb.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-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-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-postgres.c hydra-rsh.c hydra-rlogin.c hydra-oracle-listener.c \
|
||||||
|
@ -25,7 +25,7 @@ SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
|
||||||
OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
|
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-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-pop3.o hydra-smb.o hydra-icq.o hydra-cisco-enable.o hydra-ldap.o \
|
||||||
hydra-memcached.o hydra-mysql.o hydra-mssql.o hydra-xmpp.o \
|
hydra-memcached.o hydra-mongodb.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-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-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-postgres.o hydra-rsh.o hydra-rlogin.o hydra-oracle-listener.o \
|
||||||
|
|
2
README
2
README
|
@ -34,7 +34,7 @@ Currently this tool supports the following protocols:
|
||||||
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
|
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
|
||||||
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
|
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
|
||||||
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
|
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
|
||||||
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
|
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MONGODB, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
|
||||||
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin,
|
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin,
|
||||||
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
|
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
|
||||||
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
|
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
|
||||||
|
|
|
@ -34,7 +34,7 @@ Currently this tool supports the following protocols:
|
||||||
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
|
Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP,
|
||||||
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
|
HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY,
|
||||||
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
|
HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST,
|
||||||
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
|
HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MONGODB, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener,
|
||||||
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin,
|
Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin,
|
||||||
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
|
Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5,
|
||||||
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
|
SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth,
|
||||||
|
|
115
configure
vendored
115
configure
vendored
|
@ -50,6 +50,10 @@ MYSQL_PATH=""
|
||||||
MYSQL_IPATH=""
|
MYSQL_IPATH=""
|
||||||
MCACHED_PATH=""
|
MCACHED_PATH=""
|
||||||
MCACHED_IPATH=""
|
MCACHED_IPATH=""
|
||||||
|
MONGODB_PATH=""
|
||||||
|
MONGODB_IPATH=""
|
||||||
|
BSON_PATH=""
|
||||||
|
BSON_IPATH=""
|
||||||
AFP_PATH=""
|
AFP_PATH=""
|
||||||
AFP_IPATH=""
|
AFP_IPATH=""
|
||||||
NCP_PATH=""
|
NCP_PATH=""
|
||||||
|
@ -992,6 +996,97 @@ fi
|
||||||
MCACHED_IPATH=""
|
MCACHED_IPATH=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Checking for Mongodb (libmongoc-1.0.so, mongoc.h, libbson-1.0.so, bson.h) ..."
|
||||||
|
|
||||||
|
for i in $LIBDIRS ; do
|
||||||
|
if [ "X" = "X$MONGODB_PATH" ]; then
|
||||||
|
if [ -f "$i/libmongoc-1.0.so" -o -f "$i/libmongoc-1.0.dylib" -o -f "$i/libmongoc-1.0.a" ]; then
|
||||||
|
MONGODB_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "X" = "X$MONGODB_PATH" ]; then
|
||||||
|
TMP_LIB=`/bin/ls $i/libmongoc-*.so* 2> /dev/null | grep mongoc`
|
||||||
|
if [ -n "$TMP_LIB" ]; then
|
||||||
|
MONGODB_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "X" = "X$MONGODB_PATH" ]; then
|
||||||
|
TMP_LIB=`/bin/ls $i/libmongoc.dll* 2> /dev/null | grep mongoc`
|
||||||
|
if [ -n "$TMP_LIB" ]; then
|
||||||
|
MONGODB_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
MONGODB_IPATH=
|
||||||
|
for i in $INCDIRS ; do
|
||||||
|
if [ "X" = "X$MONGODB_IPATH" ]; then
|
||||||
|
if [ -f "$i/mongoc.h" ]; then
|
||||||
|
MONGODB_IPATH="$i"
|
||||||
|
fi
|
||||||
|
if [ -f "$i/libmongoc/mongoc.h" ]; then
|
||||||
|
MONGODB_IPATH="$i/libmongoc"
|
||||||
|
fi
|
||||||
|
if [ -f "$i/libmongoc-1.0/mongoc.h" ]; then
|
||||||
|
MONGODB_IPATH="$i/libmongoc-1.0"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in $LIBDIRS ; do
|
||||||
|
if [ "X" = "X$BSON_PATH" ]; then
|
||||||
|
if [ -f "$i/libbson-1.0.so" -o -f "$i/libbson-1.0.dylib" -o -f "$i/libbson-1.0.a" ]; then
|
||||||
|
BSON_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "X" = "X$BSON_PATH" ]; then
|
||||||
|
TMP_LIB=`/bin/ls $i/libbson-*.so* 2> /dev/null | grep mongoc`
|
||||||
|
if [ -n "$TMP_LIB" ]; then
|
||||||
|
BSON_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "X" = "X$BSON_PATH" ]; then
|
||||||
|
TMP_LIB=`/bin/ls $i/libbson.dll* 2> /dev/null | grep mongoc`
|
||||||
|
if [ -n "$TMP_LIB" ]; then
|
||||||
|
BSON_PATH="$i"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
BSON_IPATH=
|
||||||
|
for i in $INCDIRS ; do
|
||||||
|
if [ "X" = "X$BSON_IPATH" ]; then
|
||||||
|
if [ -f "$i/bson.h" ]; then
|
||||||
|
BSON_IPATH="$i"
|
||||||
|
fi
|
||||||
|
if [ -f "$i/libbson/bson.h" ]; then
|
||||||
|
BSON_IPATH="$i/libbson"
|
||||||
|
fi
|
||||||
|
if [ -f "$i/libbson-1.0/bson.h" ]; then
|
||||||
|
BSON_IPATH="$i/libbson-1.0"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "X" != "X$DEBUG" ]; then
|
||||||
|
echo DEBUG: MONGODB_PATH=$MONGODB_PATH/libmongoc
|
||||||
|
echo DEBUG: MONGODB_IPATH=$MONGODB_IPATH/libmongoc.h
|
||||||
|
echo DEBUG: BSON_PATH=$BSON_PATH/libbson
|
||||||
|
echo DEBUG: BSON_IPATH=$BSON_IPATH/libbson.h
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$MONGODB_PATH" -a -n "$MONGODB_IPATH" -a -n "$BSON_PATH" -a -n "$BSON_IPATH" ]; then
|
||||||
|
echo " ... found"
|
||||||
|
fi
|
||||||
|
if [ "X" = "X$MONGODB_PATH" -o "X" = "X$MONGODB_IPATH" -o "X" = "X$BSON_PATH" -o "X" = "X$BSON_IPATH" ]; then
|
||||||
|
echo " ... NOT found, module mongodb disabled"
|
||||||
|
MONGODB_PATH=""
|
||||||
|
MONGODB_IPATH=""
|
||||||
|
BSON_PATH=""
|
||||||
|
BSON_IPATH=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "X" = "X$XHYDRA_SUPPORT" ]; then
|
if [ "X" = "X$XHYDRA_SUPPORT" ]; then
|
||||||
echo "Checking for GUI req's (pkg-config, gtk+-2.0) ..."
|
echo "Checking for GUI req's (pkg-config, gtk+-2.0) ..."
|
||||||
XHYDRA_SUPPORT=`pkg-config --help > /dev/null 2>&1 || echo disabled`
|
XHYDRA_SUPPORT=`pkg-config --help > /dev/null 2>&1 || echo disabled`
|
||||||
|
@ -1085,7 +1180,7 @@ XLIBS=""
|
||||||
XLIBPATHS=""
|
XLIBPATHS=""
|
||||||
XIPATHS=""
|
XIPATHS=""
|
||||||
|
|
||||||
if [ -n "$FIREBIRD_PATH" -o -n "$PCRE_PATH" -o -n "$IDN_PATH" -o -n "$SSL_PATH" -o -n "$CRYPTO_PATH" -o -n "$NSL_PATH" -o -n "$SOCKET_PATH" -o -n "$RESOLV_PATH" -o -n "$SAPR3_PATH" -o -n "$SSH_PATH" -o -n "$POSTGRES_PATH" -o -n "$SVN_PATH" -o -n "$NCP_PATH" -o -n "$CURSES_PATH" -o -n "$ORACLE_PATH" -o -n "$AFP_PATH" -o -n "$MYSQL_PATH" -o -n "$MCACHED_PATH" ]; then
|
if [ -n "$FIREBIRD_PATH" -o -n "$PCRE_PATH" -o -n "$IDN_PATH" -o -n "$SSL_PATH" -o -n "$CRYPTO_PATH" -o -n "$NSL_PATH" -o -n "$SOCKET_PATH" -o -n "$RESOLV_PATH" -o -n "$SAPR3_PATH" -o -n "$SSH_PATH" -o -n "$POSTGRES_PATH" -o -n "$SVN_PATH" -o -n "$NCP_PATH" -o -n "$CURSES_PATH" -o -n "$ORACLE_PATH" -o -n "$AFP_PATH" -o -n "$MYSQL_PATH" -o -n "$MCACHED_PATH" -o -n "$MONGOD_PATH" ]; then
|
||||||
XLIBPATHS="-L/usr/lib -L/usr/local/lib -L/lib"
|
XLIBPATHS="-L/usr/lib -L/usr/local/lib -L/lib"
|
||||||
fi
|
fi
|
||||||
if [ -n "$MYSQL_IPATH" ]; then
|
if [ -n "$MYSQL_IPATH" ]; then
|
||||||
|
@ -1152,10 +1247,15 @@ fi
|
||||||
if [ -n "$MCACHED_PATH" ]; then
|
if [ -n "$MCACHED_PATH" ]; then
|
||||||
XDEFINES="$XDEFINES -DLIBMCACHED"
|
XDEFINES="$XDEFINES -DLIBMCACHED"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$MONGODB_PATH" ]; then
|
||||||
|
XDEFINES="$XDEFINES -DLIBMONGODB"
|
||||||
|
fi
|
||||||
|
if [ -n "$BSON_PATH" ]; then
|
||||||
|
XDEFINES="$XDEFINES -DLIBBSON"
|
||||||
|
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 $MCACHED_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 $MCACHED_PATH $MONGODB_PATH $BSON_PATH; do
|
||||||
if [ "$OLDPATH" = "$i" ]; then
|
if [ "$OLDPATH" = "$i" ]; then
|
||||||
OLDPATH="$i"
|
OLDPATH="$i"
|
||||||
else
|
else
|
||||||
|
@ -1211,6 +1311,9 @@ fi
|
||||||
if [ -n "$MCACHED_IPATH" ]; then
|
if [ -n "$MCACHED_IPATH" ]; then
|
||||||
XIPATHS="$XIPATHS -I$MCACHED_IPATH"
|
XIPATHS="$XIPATHS -I$MCACHED_IPATH"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$MONGODB_IPATH" ]; then
|
||||||
|
XIPATHS="$XIPATHS -I$MONGODB_IPATH -I$BSON_IPATH"
|
||||||
|
fi
|
||||||
if [ -n "$HAVE_GCRYPT" ]; then
|
if [ -n "$HAVE_GCRYPT" ]; then
|
||||||
XLIBS="$XLIBS -lgcrypt"
|
XLIBS="$XLIBS -lgcrypt"
|
||||||
fi
|
fi
|
||||||
|
@ -1277,6 +1380,12 @@ fi
|
||||||
if [ -n "$MCACHED_PATH" ]; then
|
if [ -n "$MCACHED_PATH" ]; then
|
||||||
XLIBS="$XLIBS -lmemcached"
|
XLIBS="$XLIBS -lmemcached"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$MONGODB_PATH" ]; then
|
||||||
|
XLIBS="$XLIBS -lmongoc-1.0"
|
||||||
|
fi
|
||||||
|
if [ -n "$BSON_PATH" ]; then
|
||||||
|
XLIBS="$XLIBS -lbson-1.0"
|
||||||
|
fi
|
||||||
if [ -d /usr/kerberos/include ]; then
|
if [ -d /usr/kerberos/include ]; then
|
||||||
XIPATHS="$XIPATHS -I/usr/kerberos/include"
|
XIPATHS="$XIPATHS -I/usr/kerberos/include"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -249,6 +249,7 @@ GtkWidget *create_wndMain(void) {
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-crammd5");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-crammd5");
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-digestmd5");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ldap3-digestmd5");
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "memcached");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "memcached");
|
||||||
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mongodb");
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mssql");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mssql");
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mysql");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "mysql");
|
||||||
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ncp");
|
cmbProtocol_items = g_list_append(cmbProtocol_items, (gpointer) "ncp");
|
||||||
|
|
184
hydra-mongodb.c
Normal file
184
hydra-mongodb.c
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
//This plugin was written by <david dot maciejak at gmail D O T com>
|
||||||
|
//Tested on mongodb-server 1:3.6.3-0ubuntu1
|
||||||
|
//MONGODB-CR is been deprecated
|
||||||
|
|
||||||
|
#ifdef LIBMONGODB
|
||||||
|
#include <mongoc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "hydra-mod.h"
|
||||||
|
|
||||||
|
#ifndef LIBMONGODB
|
||||||
|
void dummy_mcached() {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);
|
||||||
|
|
||||||
|
extern char *HYDRA_EXIT;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
#define DEFAULT_DB "admin"
|
||||||
|
|
||||||
|
int is_error_msg(char *msg) {
|
||||||
|
if (strstr(msg, "errmsg ")) {
|
||||||
|
if (debug)
|
||||||
|
hydra_report(stderr, "[ERROR] %s\n", msg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int require_auth(int32_t sock) {
|
||||||
|
unsigned char m_hdr[] =
|
||||||
|
"\x3f\x00\x00\x00" //messageLength (63)
|
||||||
|
"\x00\x00\x00\x41" //requestID
|
||||||
|
"\xff\xff\xff\xff" //responseTo
|
||||||
|
"\xd4\x07\x00\x00" //opCode (2004 OP_QUERY)
|
||||||
|
"\x00\x00\x00\x00" //flags
|
||||||
|
"\x61\x64\x6d\x69\x6e\x2e\x24\x63\x6d\x64\x00" //fullCollectionName (admin.$cmd)
|
||||||
|
"\x00\x00\x00\x00" //numberToSkip (0)
|
||||||
|
"\x01\x00\x00\x00" //numberToReturn (1)
|
||||||
|
"\x18\x00\x00\x00\x10\x6c\x69\x73\x74\x44\x61\x74\x61\x62\x61\x73\x65\x73\x00\x01\x00\x00\x00\x00"; //query ({"listDatabases"=>1})
|
||||||
|
|
||||||
|
if (hydra_send(sock, m_hdr, sizeof(m_hdr), 0) > 0) {
|
||||||
|
if (hydra_data_ready_timed(sock, 0, 1000) > 0) {
|
||||||
|
buf = hydra_receive_line(sock);
|
||||||
|
return is_error_msg(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t start_mongodb(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp) {
|
||||||
|
char *empty = "";
|
||||||
|
char *login, *pass;
|
||||||
|
char uri[256];
|
||||||
|
mongoc_client_t *client;
|
||||||
|
mongoc_database_t *database;
|
||||||
|
mongoc_collection_t *collection;
|
||||||
|
mongoc_cursor_t *cursor;
|
||||||
|
bson_t q;
|
||||||
|
const bson_t *doc;
|
||||||
|
bson_error_t error;
|
||||||
|
bool r;
|
||||||
|
|
||||||
|
if (strlen(login = hydra_get_next_login()) == 0)
|
||||||
|
login = empty;
|
||||||
|
if (strlen(pass = hydra_get_next_password()) == 0)
|
||||||
|
pass = empty;
|
||||||
|
|
||||||
|
mongoc_init();
|
||||||
|
mongoc_log_set_handler (NULL, NULL);
|
||||||
|
bson_init(&q);
|
||||||
|
|
||||||
|
snprintf(uri, sizeof(uri), "mongodb://%s:%s@%s/?authSource=%s",login, pass, hydra_address2string(ip), miscptr);
|
||||||
|
client = mongoc_client_new(uri);
|
||||||
|
if (!client)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
mongoc_client_set_appname(client, "hydra");
|
||||||
|
collection = mongoc_client_get_collection(client, miscptr, "test");
|
||||||
|
cursor = mongoc_collection_find_with_opts(collection, &q, NULL, NULL);
|
||||||
|
r = mongoc_cursor_next(cursor, &doc);
|
||||||
|
if (!r) {
|
||||||
|
r = mongoc_cursor_error(cursor, &error);
|
||||||
|
if (r) {
|
||||||
|
if (verbose)
|
||||||
|
hydra_report(stderr, "[ERROR] Can not read document: %s\n", error.message);
|
||||||
|
mongoc_cursor_destroy(cursor);
|
||||||
|
mongoc_collection_destroy(collection);
|
||||||
|
mongoc_client_destroy(client);
|
||||||
|
mongoc_cleanup();
|
||||||
|
hydra_completed_pair_skip();
|
||||||
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mongoc_cursor_destroy(cursor);
|
||||||
|
mongoc_collection_destroy(collection);
|
||||||
|
mongoc_client_destroy(client);
|
||||||
|
mongoc_cleanup();
|
||||||
|
|
||||||
|
hydra_report_found_host(port, ip, "mongodb", fp);
|
||||||
|
hydra_completed_pair_found();
|
||||||
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void service_mongodb(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
|
||||||
|
int32_t run = 1, next_run = 1, sock = -1;
|
||||||
|
|
||||||
|
if (!miscptr) {
|
||||||
|
if (verbose)
|
||||||
|
hydra_report(stderr, "[INFO] Using default database \"admin\"\n");
|
||||||
|
miscptr = DEFAULT_DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
hydra_register_socket(sp);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (run) {
|
||||||
|
case 1:
|
||||||
|
next_run = start_mongodb(sock, ip, port, options, miscptr, fp);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
hydra_child_exit(0);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
if (!verbose)
|
||||||
|
hydra_report(stderr, "[ERROR] Caught unknown return code, try verbose option for more details\n");
|
||||||
|
hydra_child_exit(2);
|
||||||
|
}
|
||||||
|
run = next_run;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t service_mongodb_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {
|
||||||
|
// called before the childrens are forked off, so this is the function
|
||||||
|
// which should be filled if initial connections and service setup has to be
|
||||||
|
// performed once only.
|
||||||
|
|
||||||
|
int32_t myport = PORT_MONGODB;
|
||||||
|
int32_t sock = -1;
|
||||||
|
|
||||||
|
if (port != 0)
|
||||||
|
myport = port;
|
||||||
|
|
||||||
|
if ((options & OPTION_SSL) == 0)
|
||||||
|
sock = hydra_connect_tcp(ip, myport);
|
||||||
|
else
|
||||||
|
sock = hydra_connect_ssl(ip, myport, hostname);
|
||||||
|
|
||||||
|
if (sock < 0) {
|
||||||
|
if (verbose || debug)
|
||||||
|
hydra_report(stderr, "[ERROR] Can not connect\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!require_auth(sock)) {
|
||||||
|
hydra_report_found_host(port, ip, "mongodb", fp);
|
||||||
|
hydra_report(stderr, "[ERROR] Mongodb server does not require any authentication\n");
|
||||||
|
if (sock >= 0)
|
||||||
|
sock = hydra_disconnect(sock);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (sock >= 0)
|
||||||
|
sock = hydra_disconnect(sock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usage_mongodb(const char* service) {
|
||||||
|
printf("Module mongodb is optionally taking a database name to attack, default is \"admin\"\n\n");
|
||||||
|
}
|
28
hydra.c
28
hydra.c
|
@ -30,6 +30,7 @@ void usage_svn(const char* service);
|
||||||
void usage_ncp(const char* service);
|
void usage_ncp(const char* service);
|
||||||
void usage_firebird(const char* service);
|
void usage_firebird(const char* service);
|
||||||
void usage_mysql(const char* service);
|
void usage_mysql(const char* service);
|
||||||
|
void usage_mongodb(const char* service);
|
||||||
void usage_irc(const char* service);
|
void usage_irc(const char* service);
|
||||||
void usage_postgres(const char* service);
|
void usage_postgres(const char* service);
|
||||||
void usage_telnet(const char* service);
|
void usage_telnet(const char* service);
|
||||||
|
@ -150,6 +151,10 @@ extern int32_t service_radmin2_init(char *ip, int32_t sp, unsigned char options,
|
||||||
extern void service_mcached(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
extern void service_mcached(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
extern int32_t service_mcached_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
extern int32_t service_mcached_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LIBMONGODB
|
||||||
|
extern void service_mongodb(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
|
extern int32_t service_mongodb_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int32_t service_adam6500_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
extern int32_t service_adam6500_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
extern int32_t service_cisco_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
extern int32_t service_cisco_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname);
|
||||||
|
@ -189,7 +194,7 @@ extern int32_t service_rpcap_init(char *ip, int32_t sp, unsigned char options, c
|
||||||
|
|
||||||
// ADD NEW SERVICES HERE
|
// ADD NEW SERVICES HERE
|
||||||
char *SERVICES =
|
char *SERVICES =
|
||||||
"adam6500 asterisk afp cisco cisco-enable cvs firebird ftp[s] http[s]-{head|get|post} http[s]-{get|post}-form http-proxy http-proxy-urlenum icq imap[s] irc ldap2[s] ldap3[-{cram|digest}md5][s] memcached mssql mysql ncp nntp oracle oracle-listener oracle-sid pcanywhere pcnfs pop3[s] postgres radmin2 rdp redis rexec rlogin rpcap rsh rtsp s7-300 sapr3 sip smb smtp[s] smtp-enum snmp socks5 ssh sshkey svn teamspeak telnet[s] vmauthd vnc xmpp";
|
"adam6500 asterisk afp cisco cisco-enable cvs firebird ftp[s] http[s]-{head|get|post} http[s]-{get|post}-form http-proxy http-proxy-urlenum icq imap[s] irc ldap2[s] ldap3[-{cram|digest}md5][s] memcached mongodb mssql mysql ncp nntp oracle oracle-listener oracle-sid pcanywhere pcnfs pop3[s] postgres radmin2 rdp redis rexec rlogin rpcap rsh rtsp s7-300 sapr3 sip smb smtp[s] smtp-enum snmp socks5 ssh sshkey svn teamspeak telnet[s] vmauthd vnc xmpp";
|
||||||
|
|
||||||
#define MAXBUF 520
|
#define MAXBUF 520
|
||||||
#define MAXLINESIZE ( ( MAXBUF / 2 ) - 4 )
|
#define MAXLINESIZE ( ( MAXBUF / 2 ) - 4 )
|
||||||
|
@ -388,6 +393,9 @@ static const struct {
|
||||||
{"memcached", service_mcached_init, service_mcached, NULL},
|
{"memcached", service_mcached_init, service_mcached, NULL},
|
||||||
#endif
|
#endif
|
||||||
SERVICE(mssql),
|
SERVICE(mssql),
|
||||||
|
#ifdef LIBMONGODB
|
||||||
|
SERVICE3("mongodb", mongodb),
|
||||||
|
#endif
|
||||||
#ifdef HAVE_MATH_H
|
#ifdef HAVE_MATH_H
|
||||||
SERVICE3("mysql", mysql),
|
SERVICE3("mysql", mysql),
|
||||||
#endif
|
#endif
|
||||||
|
@ -1246,6 +1254,7 @@ int32_t hydra_lookup_port(char *service) {
|
||||||
{"oracle-sid", PORT_ORACLE, PORT_ORACLE_SSL},
|
{"oracle-sid", PORT_ORACLE, PORT_ORACLE_SSL},
|
||||||
{"oracle", PORT_ORACLE, PORT_ORACLE_SSL},
|
{"oracle", PORT_ORACLE, PORT_ORACLE_SSL},
|
||||||
{"memcached", PORT_MCACHED, PORT_MCACHED_SSL},
|
{"memcached", PORT_MCACHED, PORT_MCACHED_SSL},
|
||||||
|
{"mongodb", PORT_MONGODB, PORT_MONGODB},
|
||||||
{"mssql", PORT_MSSQL, PORT_MSSQL_SSL},
|
{"mssql", PORT_MSSQL, PORT_MSSQL_SSL},
|
||||||
{"mysql", PORT_MYSQL, PORT_MYSQL_SSL},
|
{"mysql", PORT_MYSQL, PORT_MYSQL_SSL},
|
||||||
{"postgres", PORT_POSTGRES, PORT_POSTGRES_SSL},
|
{"postgres", PORT_POSTGRES, PORT_POSTGRES_SSL},
|
||||||
|
@ -2083,6 +2092,10 @@ int main(int argc, char *argv[]) {
|
||||||
SERVICES = hydra_string_replace(SERVICES, "memcached ", "");
|
SERVICES = hydra_string_replace(SERVICES, "memcached ", "");
|
||||||
strcat(unsupported, "memcached ");
|
strcat(unsupported, "memcached ");
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef LIBMONGODB
|
||||||
|
SERVICES = hydra_string_replace(SERVICES, "mongodb ", "");
|
||||||
|
strcat(unsupported, "mongodb ");
|
||||||
|
#endif
|
||||||
#ifndef LIBMYSQLCLIENT
|
#ifndef LIBMYSQLCLIENT
|
||||||
SERVICES = hydra_string_replace(SERVICES, "mysql ", "mysql(v4) ");
|
SERVICES = hydra_string_replace(SERVICES, "mysql ", "mysql(v4) ");
|
||||||
strcat(unsupported, "mysql5 ");
|
strcat(unsupported, "mysql5 ");
|
||||||
|
@ -2539,7 +2552,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (strcmp(hydra_options.service, "afp") == 0 || strcmp(hydra_options.service, "firebird") == 0 || strncmp(hydra_options.service, "mysql", 5) == 0 ||
|
if (strcmp(hydra_options.service, "afp") == 0 || strcmp(hydra_options.service, "firebird") == 0 || strncmp(hydra_options.service, "mysql", 5) == 0 ||
|
||||||
strcmp(hydra_options.service, "ncp") == 0 || strcmp(hydra_options.service, "oracle") == 0 || strcmp(hydra_options.service, "postgres") == 0 ||
|
strcmp(hydra_options.service, "ncp") == 0 || strcmp(hydra_options.service, "oracle") == 0 || strcmp(hydra_options.service, "postgres") == 0 ||
|
||||||
strncmp(hydra_options.service, "ssh", 3) == 0 || strcmp(hydra_options.service, "sshkey") == 0 || strcmp(hydra_options.service, "svn") == 0 ||
|
strncmp(hydra_options.service, "ssh", 3) == 0 || strcmp(hydra_options.service, "sshkey") == 0 || strcmp(hydra_options.service, "svn") == 0 ||
|
||||||
strcmp(hydra_options.service, "sapr3") == 0 || strcmp(hydra_options.service, "memcached") == 0) {
|
strcmp(hydra_options.service, "sapr3") == 0 || strcmp(hydra_options.service, "memcached") == 0 || strcmp(hydra_options.service, "mongodb") == 0) {
|
||||||
fprintf(stderr, "[WARNING] module %s does not support HYDRA_PROXY* !\n", hydra_options.service);
|
fprintf(stderr, "[WARNING] module %s does not support HYDRA_PROXY* !\n", hydra_options.service);
|
||||||
proxy_string = NULL;
|
proxy_string = NULL;
|
||||||
}
|
}
|
||||||
|
@ -2623,6 +2636,17 @@ int main(int argc, char *argv[]) {
|
||||||
bail("Compiled without LIBMCACHED support, module not available!");
|
bail("Compiled without LIBMCACHED support, module not available!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(hydra_options.service, "mongodb") == 0)
|
||||||
|
#ifdef LIBMONGODB
|
||||||
|
{
|
||||||
|
i = 1;
|
||||||
|
if (hydra_options.miscptr == NULL || (strlen(hydra_options.miscptr) == 0))
|
||||||
|
fprintf(stderr, "[INFO] The mongodb db wasn't passed so using admin by default\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
bail("Compiled without LIBMONGODB support, module not available!");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (strcmp(hydra_options.service, "mysql") == 0) {
|
if (strcmp(hydra_options.service, "mysql") == 0) {
|
||||||
i = 1;
|
i = 1;
|
||||||
if (hydra_options.tasks > 4) {
|
if (hydra_options.tasks > 4) {
|
||||||
|
|
1
hydra.h
1
hydra.h
|
@ -146,6 +146,7 @@
|
||||||
#define PORT_RADMIN2 4899
|
#define PORT_RADMIN2 4899
|
||||||
#define PORT_MCACHED 11211
|
#define PORT_MCACHED 11211
|
||||||
#define PORT_MCACHED_SSL 11211
|
#define PORT_MCACHED_SSL 11211
|
||||||
|
#define PORT_MONGODB 27017
|
||||||
|
|
||||||
#define False 0
|
#define False 0
|
||||||
#define True 1
|
#define True 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue