增加将结果输出到redis功能

This commit is contained in:
root 2018-04-03 07:10:37 -04:00
commit d9990f8654
6 changed files with 80 additions and 7 deletions

View file

@ -9,7 +9,7 @@ MANDIR ?= /man/man1/
DATADIR ?= /etc
DESTDIR ?=
SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
SRC = output-redis.c 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 \
@ -22,7 +22,7 @@ SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
hydra-s7-300.c hydra-redis.c hydra-adam6500.c hydra-rtsp.c \
hydra-rpcap.c hydra-radmin2.c \
hydra-time.c crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c
OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
OBJ = output-redis.o 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 \
@ -38,14 +38,14 @@ OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.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
hydra-mod.h output-redis.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)
$(CC) $(OPTS) $(SEC) $(LIBS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o hydra $(HYDRA_LOGO) hydra.c $(OBJ) $(LIBS) $(XLIBS) $(XLIBPATHS) $(XIPATHS) $(XDEFINES) -L./lib/hiredis -lhiredis
@echo
@echo If men could get pregnant, abortion would be a sacrament
@echo
@ -54,10 +54,10 @@ 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
-$(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o pw-inspector $(PWI_LOGO) pw-inspector.c
.c.o:
$(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) -c $< $(XDEFINES) $(XIPATHS)
cd ./lib/hiredis && make && cd ../../ && $(CC) $(OPTS) $(SEC) $(CFLAGS) $(CPPFLAGS) -c $< $(XDEFINES) $(XIPATHS) -L./lib/hiredis -lhiredis
strip: all
strip $(BINS)
@ -75,6 +75,7 @@ install: strip
-cp -f hydra.1 xhydra.1 pw-inspector.1 $(DESTDIR)$(PREFIX)$(MANDIR)
clean:
cd ./lib/hiredis && make clean && cd ../../
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

13
hydra.c Normal file → Executable file
View file

@ -9,6 +9,7 @@
*/
#include "hydra.h"
#include "bfg.h"
#include "output-redis.h"
#ifdef LIBNCURSES
#include <curses.h>
@ -2058,6 +2059,7 @@ void process_proxy_line(int32_t type, char *string) {
int main(int argc, char *argv[]) {
char *proxy_string = NULL, *device = NULL, *memcheck, *cmdtarget = NULL;
char *outfile_format_tmp;
char *output;
FILE *lfp = NULL, *pfp = NULL, *cfp = NULL, *ifp = NULL, *rfp = NULL, *proxyfp;
size_t countinfile = 1, sizeinfile = 0;
uint64_t math2;
@ -3511,12 +3513,18 @@ int main(int argc, char *argv[]) {
exit(-1);
}
if (hydra_options.outfile_format == FORMAT_JSONV1) {
sprintf(output,"%s", "{ \"generator\": {"
"\"software\": \"%s\", \"version\": \"%s\", \"built\": \"%s\","
"\"server\": \"%s\", \"service\": \"%s\", \"jsonoutputversion\": \"1.00\",\n"
"\"commandline\": \"%s");
fprintf(hydra_brains.ofp, "{ \"generator\": {\n"
"\t\"software\": \"%s\", \"version\": \"%s\", \"built\": \"%s\",\n"
"\t\"server\": \"%s\", \"service\": \"%s\", \"jsonoutputversion\": \"1.00\",\n"
"\t\"commandline\": \"%s",
PROGRAM, VERSION, hydra_build_time(),
hydra_options.server == NULL ? hydra_options.infile_ptr : hydra_options.server, hydra_options.service, prg);
set("a", "2");
for (i = 1; i < argc; i++) {
char *t = hydra_string_replace(argv[i],"\"","\\\"");
fprintf(hydra_brains.ofp, " %s", t);
@ -3787,6 +3795,7 @@ int main(int argc, char *argv[]) {
hydra_heads[head_no]->current_pass_ptr != NULL ? hydra_string_replace(hydra_heads[head_no]->current_pass_ptr,"\"","\\\"") : ""
);
fflush(hydra_brains.ofp);
set("a", "3");
} else if (hydra_options.outfile_ptr != NULL && hydra_brains.ofp != NULL) { // else output format == 0 aka text
if (hydra_heads[head_no]->current_login_ptr == NULL || strlen(hydra_heads[head_no]->current_login_ptr) == 0) {
if (hydra_heads[head_no]->current_pass_ptr == NULL || strlen(hydra_heads[head_no]->current_pass_ptr) == 0)
@ -4053,7 +4062,9 @@ int main(int argc, char *argv[]) {
}
fclose(hydra_brains.ofp);
}
set("output", output);
printf("%d", output);
redis_free();
fflush(NULL);
if (error || j != 0 || exit_condition < 0)
return -1;

View file

@ -28,6 +28,7 @@
#include <sys/resource.h>
#include <sys/wait.h>
#include <errno.h>
#include "output-redis.h"
#ifdef HAVE_OPENSSL
#define HYDRA_SSL

40
output-redis.c Executable file
View file

@ -0,0 +1,40 @@
//
// hydra-rtsp.c
// hydra-rtsp
//
// Created by Javier zhukun on 03/04/18.
//
//
#include "output-redis.h"
void set(const unsigned char *key, const unsigned char *value)
{
if (conn == NULL)
{
conn = redisConnect("127.0.0.1", 6379);
}
if(conn != NULL && conn->err)
{
printf("connection error: %s\n",conn->errstr);
}
redisReply *reply = (redisReply*)redisCommand(conn,"set %s %s", key, value);
freeReplyObject(reply);
/*reply = redisCommand(conn,"get %s", key);
printf("%s\n",reply->str);
freeReplyObject(reply); */
}
void redis_free()
{
redisFree(conn);
}
/*int main()
{
set("a", "1");
return 0;
}*/

15
output-redis.h Executable file
View file

@ -0,0 +1,15 @@
//
// hydra-rtsp.c
// hydra-rtsp
//
// Created by Javier zhukun on 03/04/18.
//
//
#include <stdio.h>
#include "lib/hiredis/hiredis.h"
redisContext *conn;
void set(const unsigned char *key, const unsigned char *value);
void redis_free();

5
quick Executable file
View file

@ -0,0 +1,5 @@
#rm -f output-redis
#gcc output-redis.c -o output-redis -L./lib/hiredis -lhiredis
make clean
./configure
make