Skip to content

Commit

Permalink
support -W for modules that use libarries
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Aug 13, 2023
1 parent b4a2b0b commit 16b424a
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Changelog for hydra
-------------------

Release 9.5
* many modules did not support -W (all those that used a library for the
connection). All (or most?) should be fixed now.
* http-form:
- The help for http-form was wrong. the condition variable must always be
the *last* parameter, not the third
Expand Down
3 changes: 3 additions & 0 deletions hydra-firebird.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void dummy_firebird() { printf("\n"); }

#define DEFAULT_DB "C:\\Program Files\\Firebird\\Firebird_1_5\\security.fdb"

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

int32_t start_firebird(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
Expand Down Expand Up @@ -124,6 +125,8 @@ void service_firebird(char *ip, int32_t sp, unsigned char options, char *miscptr
*/

next_run = start_firebird(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3:

Expand Down
2 changes: 1 addition & 1 deletion hydra-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ int32_t service_http_init(char *ip, int32_t sp, unsigned char options, char *mis
start--;
memset(start, '\0', condition_len);
if (debug)
hydra_report(stderr, "Modificated options:%s\n", miscptr);
hydra_report(stderr, "Modified options:%s\n", miscptr);
} else {
if (debug)
hydra_report(stderr, "Condition not found\n");
Expand Down
3 changes: 3 additions & 0 deletions hydra-memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void dummy_mcached() { printf("\n"); }

extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

int mcached_send_com_quit(int32_t sock) {
Expand Down Expand Up @@ -117,6 +118,8 @@ void service_mcached(char *ip, int32_t sp, unsigned char options, char *miscptr,
switch (run) {
case 1:
next_run = start_mcached(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
hydra_child_exit(0);
Expand Down
3 changes: 3 additions & 0 deletions hydra-mongodb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void dummy_mongodb() { printf("\n"); }

extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
char *buf;

Expand Down Expand Up @@ -136,6 +137,8 @@ void service_mongodb(char *ip, int32_t sp, unsigned char options, char *miscptr,
switch (run) {
case 1:
next_run = start_mongodb(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
hydra_child_exit(0);
Expand Down
3 changes: 3 additions & 0 deletions hydra-mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ char *hydra_scramble(char *to, const char *message, const char *password);
extern int32_t internal__hydra_recv(int32_t socket, char *buf, int32_t length);
extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
char mysqlsalt[9];

Expand Down Expand Up @@ -332,6 +333,8 @@ void service_mysql(char *ip, int32_t sp, unsigned char options, char *miscptr, F
break;
case 2: /* run the cracking function */
next_run = start_mysql(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3: /* clean exit */
if (sock >= 0) {
Expand Down
3 changes: 3 additions & 0 deletions hydra-oracle-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void dummy_oracle_listener() { printf("\n"); }
#include <openssl/des.h>
#define HASHSIZE 17

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
char *buf;
unsigned char *hash;
Expand Down Expand Up @@ -304,6 +305,8 @@ void service_oracle_listener(char *ip, int32_t sp, unsigned char options, char *
}
/* run the cracking function */
next_run = start_oracle_listener(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3: /* clean exit */
if (sock >= 0)
Expand Down
3 changes: 3 additions & 0 deletions hydra-oracle-sid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void dummy_oracle_sid() { printf("\n"); }
#include <openssl/des.h>
#define HASHSIZE 16

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
char *buf;
unsigned char *hash;
Expand Down Expand Up @@ -113,6 +114,8 @@ void service_oracle_sid(char *ip, int32_t sp, unsigned char options, char *miscp
}
/* run the cracking function */
next_run = start_oracle_sid(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3: /* clean exit */
if (sock >= 0)
Expand Down
3 changes: 3 additions & 0 deletions hydra-oracle.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void dummy_oracle() { printf("\n"); }
#include <stdbool.h>
#include <sys/types.h>

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

OCIEnv *o_environment;
Expand Down Expand Up @@ -165,6 +166,8 @@ void service_oracle(char *ip, int32_t sp, unsigned char options, char *miscptr,
break;
case 2:
next_run = start_oracle(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3: /* clean exit */
if (sock >= 0)
Expand Down
3 changes: 3 additions & 0 deletions hydra-postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void dummy_postgres() { printf("\n"); }

#define DEFAULT_DB "template1"

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

int32_t start_postgres(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE *fp) {
Expand Down Expand Up @@ -99,6 +100,8 @@ void service_postgres(char *ip, int32_t sp, unsigned char options, char *miscptr
* Here we start the password cracking process
*/
next_run = start_postgres(sock, ip, port, options, miscptr, fp);
if ((next_run == 2 || next_run == 1) && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3:
if (sock >= 0)
Expand Down
2 changes: 2 additions & 0 deletions hydra-rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ void service_rdp(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
else
sleep(hydra_options.conwait);
next_run = start_rdp(ip, myport, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2: /* clean exit */
freerdp_disconnect(instance);
Expand Down
3 changes: 3 additions & 0 deletions hydra-sapr3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const int32_t *__ctype_b;

extern void flood(); /* for -lm */

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
RFC_ERROR_INFO_EX error_info;

Expand Down Expand Up @@ -99,6 +100,8 @@ void service_sapr3(char *ip, int32_t sp, unsigned char options, char *miscptr, F
switch (run) {
case 1: /* connect and service init function */
next_run = start_sapr3(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
hydra_child_exit(0);
Expand Down
8 changes: 8 additions & 0 deletions hydra-smb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

typedef struct creds {
Expand Down Expand Up @@ -173,10 +174,15 @@ bool smb2_run_test(creds_t *cr, const char *server, uint16_t port) {
}

void service_smb2(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE *fp, int32_t port, char *hostname) {
static int first_run = 0;
hydra_register_socket(sp);

while (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT))) {
char *login, *pass;

if (first_run && hydra_options.conwait)
sleep(hydra_options.conwait);

login = hydra_get_next_login();
pass = hydra_get_next_password();

Expand All @@ -191,6 +197,8 @@ void service_smb2(char *ip, int32_t sp, unsigned char options, char *miscptr, FI
} else {
hydra_completed_pair();
}

first_run = 1;
}
EXIT_NORMAL;
}
Expand Down
2 changes: 2 additions & 0 deletions hydra-ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ void service_ssh(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
switch (run) {
case 1: /* connect and service init function */
next_run = start_ssh(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
ssh_disconnect(session);
Expand Down
3 changes: 3 additions & 0 deletions hydra-sshkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void dummy_sshkey() { printf("\n"); }
#if LIBSSH_VERSION_MAJOR >= 0 && LIBSSH_VERSION_MINOR >= 4

extern ssh_session session;
extern hydra_option hydra_options;
extern char *HYDRA_EXIT;
extern int32_t new_session;

Expand Down Expand Up @@ -117,6 +118,8 @@ void service_sshkey(char *ip, int32_t sp, unsigned char options, char *miscptr,
switch (run) {
case 1: /* connect and service init function */
next_run = start_sshkey(sock, ip, port, options, miscptr, fp);
if (next_run == 1 && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 2:
ssh_disconnect(session);
Expand Down
3 changes: 3 additions & 0 deletions hydra-svn.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void dummy_svn() { printf("\n"); }

extern int32_t hydra_data_ready_timed(int32_t socket, long sec, long usec);

extern hydra_option hydra_options;
extern char *HYDRA_EXIT;

#define DEFAULT_BRANCH "trunk"
Expand Down Expand Up @@ -197,6 +198,8 @@ void service_svn(char *ip, int32_t sp, unsigned char options, char *miscptr, FIL
break;
case 2:
next_run = start_svn(sock, ip, port, options, miscptr, fp);
if ((next_run == 1 || next_run == 2) && hydra_options.conwait)
sleep(hydra_options.conwait);
break;
case 3:
if (sock >= 0)
Expand Down

0 comments on commit 16b424a

Please sign in to comment.