Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Aug 23, 2021
1 parent 09453c7 commit 67ef4c7
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Changelog for hydra
-------------------

Release 9.3-dev
* New module: cobaltstrike by ultimaiiii, thank you!
* fix for ssh to support -M or ip/range
* for vnc/cisco/... protocols that only check for a password, skip host
after the password is found
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ APPDIR = /share/applications
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-pop3.c hydra-smb.c hydra-icq.c hydra-cisco-enable.c hydra-ldap.c \
hydra-memcached.c hydra-mongodb.c hydra-mysql.c hydra-mssql.c hydra-cobaltstrike.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-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-svn.c hydra-pcanywhere.c hydra-sip.c hydra-oracle.c hydra-vmauthd.c \
hydra-asterisk.c hydra-firebird.c hydra-afp.c hydra-ncp.c hydra-rdp.c \
hydra-oracle-sid.c hydra-http-proxy.c hydra-http-form.c hydra-irc.c \
hydra-s7-300.c hydra-redis.c hydra-adam6500.c hydra-rtsp.c \
hydra-rpcap.c hydra-radmin2.c \
hydra-rpcap.c hydra-radmin2.c hydra-cobaltstrike.c \
hydra-time.c crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c \
hydra-smb2.c
OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
Expand Down
8 changes: 4 additions & 4 deletions hydra-cobaltstrike.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ int32_t start_cobaltstrike(int32_t s, char *ip, int32_t port, unsigned char opti
if (hydra_send(s, buffer, sizeof(buffer), 0) < 0)
return 1;

reply_byte_0 = 0x00;
reply_byte_0 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_0, 1);
if (ret <= 0)
return 3;

reply_byte_1 = 0x00;
reply_byte_1 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_1, 1);
if (ret <= 0)
return 3;

reply_byte_2 = 0x00;
reply_byte_2 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_2, 1);
if (ret <= 0)
return 3;

reply_byte_3 = 0x00;
reply_byte_3 = 0x00;
ret = hydra_recv_nb(s, &reply_byte_3, 1);
if (ret <= 0)
return 3;
Expand Down
2 changes: 1 addition & 1 deletion hydra-mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ char *cmdlinetarget;
typedef int32_t BOOL;
#else /* __APPLE__ */
/* ensure compatibility with objc libraries */
#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
typedef bool BOOL;
#else
typedef signed char BOOL;
Expand Down
12 changes: 4 additions & 8 deletions hydra-sip.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
}

int32_t has_sip_cred = 0;
int32_t try
= 0;
int32_t try = 0;

/* We have to check many times because server may begin to send "100 Trying"
* before "401 Unauthorized" */
while (try < 2 && !has_sip_cred) {
try
++;
try++;
if (hydra_data_ready_timed(s, 3, 0) > 0) {
i = hydra_recv(s, (char *)buf, sizeof(buf) - 1);
if (i > 0)
Expand Down Expand Up @@ -160,14 +158,12 @@ int32_t start_sip(int32_t s, char *ip, char *lip, int32_t port, int32_t lport, u
if (hydra_send(s, buffer, strlen(buffer), 0) < 0) {
return 3;
}
try
= 0;
try = 0;
int32_t has_resp = 0;
int32_t sip_code = 0;

while (try < 2 && !has_resp) {
try
++;
try++;
if (hydra_data_ready_timed(s, 5, 0) > 0) {
memset(buf, 0, sizeof(buf));
if ((i = hydra_recv(s, (char *)buf, sizeof(buf) - 1)) >= 0)
Expand Down
2 changes: 1 addition & 1 deletion hydra-ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int32_t start_ssh(int32_t s, char *ip, int32_t port, unsigned char options, char
if (new_session) {
if (session) {
ssh_disconnect(session);
//ssh_finalize();
// ssh_finalize();
ssh_free(session);
} else {
ssh_init();
Expand Down
20 changes: 4 additions & 16 deletions hydra-telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,16 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c

/*win7 answering with do terminal type = 0xfd 0x18 */
while ((buf = hydra_receive_line(s)) != NULL && make_to_lower(buf) && (strstr(buf, "password:") == NULL || strstr(buf, "login:") == NULL || strstr(buf, "last login:") != NULL) && strstr(buf, "sername:") == NULL) {
if ((miscptr != NULL && strstr(buf, miscptr) != NULL)
|| (miscptr == NULL
&& strstr(buf, "invalid") == NULL
&& strstr(buf, "incorrect") == NULL
&& strstr(buf, "bad ") == NULL
&& (strchr(buf, '/') != NULL
|| strchr(buf, '>') != NULL
|| strchr(buf, '$') != NULL
|| strchr(buf, '#') != NULL
|| strchr(buf, '%') != NULL
|| ((buf[1] == '\xfd')
&& (buf[2] == '\x18')))
)) {
if ((miscptr != NULL && strstr(buf, miscptr) != NULL) || (miscptr == NULL && strstr(buf, "invalid") == NULL && strstr(buf, "incorrect") == NULL && strstr(buf, "bad ") == NULL && (strchr(buf, '/') != NULL || strchr(buf, '>') != NULL || strchr(buf, '$') != NULL || strchr(buf, '#') != NULL || strchr(buf, '%') != NULL || ((buf[1] == '\xfd') && (buf[2] == '\x18'))))) {
hydra_report_found_host(port, ip, "telnet", fp);
hydra_completed_pair_found();
free(buf);
if (memcmp(hydra_get_next_pair(), &HYDRA_EXIT, sizeof(HYDRA_EXIT)) == 0)
return 3;
return 1;
} else if (buf && strstr(buf, "assword:") ) {
} else if (buf && strstr(buf, "assword:")) {
hydra_completed_pair();
//printf("password prompt\n");
// printf("password prompt\n");
free(buf);
if (strlen(pass = hydra_get_next_password()) == 0)
pass = empty;
Expand All @@ -116,7 +104,7 @@ int32_t start_telnet(int32_t s, char *ip, int32_t port, unsigned char options, c
return 1;
}
}
} else if (buf && strstr(buf, "login:") ) {
} else if (buf && strstr(buf, "login:")) {
free(buf);
hydra_completed_pair();
return 2;
Expand Down
7 changes: 5 additions & 2 deletions hydra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,11 @@ int32_t hydra_send_next_pair(int32_t target_no, int32_t head_no) {
// the above line
}
if (debug || hydra_options.showAttempt) {
printf("[%sATTEMPT] target %s - login \"%s\" - pass \"%s\" - %" hPRIu64 " of %" hPRIu64 " [child %d] (%d/%d)\n", hydra_targets[target_no]->redo_state ? "REDO-" : snp_is_redo ? "RE-" : "", hydra_targets[target_no]->target, hydra_heads[head_no]->current_login_ptr, hydra_heads[head_no]->current_pass_ptr, hydra_targets[target_no]->sent, hydra_brains.todo + hydra_targets[target_no]->redo, head_no, hydra_targets[target_no]->redo_state ? hydra_targets[target_no]->redo_state - 1 : 0,
hydra_targets[target_no]->redo);
printf("[%sATTEMPT] target %s - login \"%s\" - pass \"%s\" - %" hPRIu64 " of %" hPRIu64 " [child %d] (%d/%d)\n",
hydra_targets[target_no]->redo_state ? "REDO-"
: snp_is_redo ? "RE-"
: "",
hydra_targets[target_no]->target, hydra_heads[head_no]->current_login_ptr, hydra_heads[head_no]->current_pass_ptr, hydra_targets[target_no]->sent, hydra_brains.todo + hydra_targets[target_no]->redo, head_no, hydra_targets[target_no]->redo_state ? hydra_targets[target_no]->redo_state - 1 : 0, hydra_targets[target_no]->redo);
}
loop_cnt = 0;
return 0;
Expand Down

0 comments on commit 67ef4c7

Please sign in to comment.