Skip to content

Commit

Permalink
Switched usleep to nanosleep for posix complience
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Reacher committed Feb 6, 2016
1 parent 62be0a4 commit 554d66c
Show file tree
Hide file tree
Showing 35 changed files with 70 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SRC = hydra-vnc.c hydra-pcnfs.c hydra-rexec.c hydra-nntp.c hydra-socks5.c \
hydra-oracle.c hydra-vmauthd.c hydra-asterisk.c hydra-firebird.c hydra-afp.c hydra-ncp.c \
hydra-oracle-sid.c hydra-http-proxy.c hydra-http-form.c hydra-irc.c \
hydra-rdp.c hydra-s7-300.c hydra-redis.c \
crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c hydra-rtsp.c
crc32.c d3des.c bfg.c ntlm.c sasl.c hmacmd5.c hydra-mod.c hydra-rtsp.c hydra-time.c
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-pop3.o hydra-smb.o hydra-icq.o hydra-cisco-enable.o hydra-ldap.o \
Expand All @@ -30,7 +30,7 @@ OBJ = hydra-vnc.o hydra-pcnfs.o hydra-rexec.o hydra-nntp.o hydra-socks5.o \
hydra-oracle-sid.o hydra-oracle.o hydra-vmauthd.o hydra-asterisk.o hydra-firebird.o hydra-afp.o hydra-ncp.o \
hydra-http-proxy.o hydra-http-form.o hydra-irc.o hydra-redis.o \
hydra-rdp.o hydra-s7-300.c \
crc32.o d3des.o bfg.o ntlm.o sasl.o hmacmd5.o hydra-mod.o hydra-rtsp.o
crc32.o d3des.o bfg.o ntlm.o sasl.o hmacmd5.o hydra-mod.o hydra-rtsp.o hydra-time.o
BINS = hydra pw-inspector

EXTRA_DIST = README README.arm README.palm CHANGES TODO INSTALL LICENSE \
Expand Down
2 changes: 1 addition & 1 deletion hydra-asterisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void service_asterisk(char *ip, int sp, unsigned char options, char *miscptr, FI
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-cisco-enable.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void service_cisco_enable(char *ip, int sp, unsigned char options, char *miscptr
{
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-cisco.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void service_cisco(char *ip, int sp, unsigned char options, char *miscptr, FILE

if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-cvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void service_cvs(char *ip, int sp, unsigned char options, char *miscptr, FILE *
if (sock >= 0)
sock = hydra_disconnect(sock);

// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
4 changes: 2 additions & 2 deletions hydra-ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void service_ftp_core(char *ip, int sp, unsigned char options, char *miscptr, FI
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand All @@ -101,7 +101,7 @@ void service_ftp_core(char *ip, int sp, unsigned char options, char *miscptr, FI
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int) getpid());
hydra_child_exit(1);
}
usleep(250);
usleepn(250);
buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '2') { /* check the first line */
if (verbose || debug)
Expand Down
2 changes: 1 addition & 1 deletion hydra-http-proxy-urlenum.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void service_http_proxy_urlenum(char *ip, int sp, unsigned char options, char *m
{
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-http-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void service_http_proxy(char *ip, int sp, unsigned char options, char *miscptr,
free(http_proxy_buf);
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
4 changes: 2 additions & 2 deletions hydra-imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ char *imap_read_server_capacity(int sock) {
if (buf != NULL) {
if (strstr(buf, "CAPABILITY") != NULL && buf[0] == '*') {
resp = 1;
usleep(300000);
sleepn(300);
/* we got the capability info then get the completed warning info from server */
while (hydra_data_ready(sock)) {
free(buf);
Expand Down Expand Up @@ -362,7 +362,7 @@ void service_imap(char *ip, int sp, unsigned char options, char *miscptr, FILE *
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-irc.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int send_nick(int s, char *ip, char *pass) {
int irc_server_connect(char *ip, int sock, int port, unsigned char options) {
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void service_ldap(char *ip, int sp, unsigned char options, char *miscptr, FILE *
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
6 changes: 3 additions & 3 deletions hydra-mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void hydra_child_exit(int code) {
__fck = write(intern_socket, "E", 1);
}
do {
usleep(10000);
sleepn(10);
} while (read(intern_socket, buf, 1) <= 0);
// sleep(2); // be sure that mommy receives our message
exit(0); // might be killed before reaching this
Expand Down Expand Up @@ -920,7 +920,7 @@ char *hydra_receive_line(int socket) {
if (buff[k] == 0)
buff[k] = 32;
buff[got] = 0;
usleep(100);
usleepn(100);
}
}

Expand All @@ -940,7 +940,7 @@ char *hydra_receive_line(int socket) {
got += j;
buff[got] = 0;
}
usleep(100);
usleepn(100);
}

if (debug) {
Expand Down
2 changes: 1 addition & 1 deletion hydra-mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void service_mysql(char *ip, int sp, unsigned char options, char *miscptr, FILE
hydra_mysql_send_com_quit(sock);
sock = hydra_disconnect(sock);
}
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
6 changes: 3 additions & 3 deletions hydra-nntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void service_nntp(char *ip, int sp, unsigned char options, char *miscptr, FILE *
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand All @@ -289,7 +289,7 @@ void service_nntp(char *ip, int sp, unsigned char options, char *miscptr, FILE *
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int) getpid());
hydra_child_exit(1);
}
// usleep(300000);
// sleepn(300);
buf = hydra_receive_line(sock);
if (buf == NULL || buf[0] != '2') { /* check the first line */
if (verbose || debug)
Expand Down Expand Up @@ -445,7 +445,7 @@ SASL PLAIN DIGEST-MD5 LOGIN NTLM CRAM-MD5
break;
}
}
usleep(25000);
sleepn(25);
free(buf);
next_run = 2;
break;
Expand Down
2 changes: 1 addition & 1 deletion hydra-oracle-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void service_oracle_listener(char *ip, int sp, unsigned char options, char *misc
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-oracle-sid.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void service_oracle_sid(char *ip, int sp, unsigned char options, char *miscptr,
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-pcanywhere.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void service_pcanywhere(char *ip, int sp, unsigned char options, char *miscptr,
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
usleep(275000);
sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-pcnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void service_pcnfs(char *ip, int sp, unsigned char options, char *miscptr, FILE
{
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((sock = hydra_connect_udp(ip, port)) < 0) {
if (quiet != 1) fprintf(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int) getpid());
hydra_child_exit(1);
Expand Down
4 changes: 2 additions & 2 deletions hydra-pop3.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void service_pop3(char *ip, int sp, unsigned char options, char *miscptr, FILE *

if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
sock = hydra_connect_tcp(ip, port);
} else {
Expand Down Expand Up @@ -519,7 +519,7 @@ int service_pop3_init(char *ip, int sp, unsigned char options, char *miscptr, FI

if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void service_postgres(char *ip, int sp, unsigned char options, char *miscptr, FI
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void service_redis_core(char *ip, int sp, unsigned char options, char *miscptr,
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int) getpid());
hydra_child_exit(1);
}
usleep(250);
usleepn(250);
next_run = 2;
break;
case 2: /* run the cracking function */
Expand Down
2 changes: 1 addition & 1 deletion hydra-rexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void service_rexec(char *ip, int sp, unsigned char options, char *miscptr, FILE
{
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-rlogin.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void service_rlogin(char *ip, int sp, unsigned char options, char *miscptr, FILE
hydra_set_srcport(1023);
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-rsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void service_rsh(char *ip, int sp, unsigned char options, char *miscptr, FILE *
hydra_set_srcport(1023);
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(275000);
// sleepn(275);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ void service_smb(char *ip, int sp, unsigned char options, char *miscptr, FILE *
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);

if (port != 0) {
sock = hydra_connect_tcp(ip, port);
Expand Down
2 changes: 1 addition & 1 deletion hydra-socks5.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void service_socks5(char *ip, int sp, unsigned char options, char *miscptr, FILE
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-svn.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void service_svn(char *ip, int sp, unsigned char options, char *miscptr, FILE *
if (sock >= 0)
sock = hydra_disconnect(sock);

// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-teamspeak.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void service_teamspeak(char *ip, int sp, unsigned char options, char *miscptr, F
case 1: /* connect and service init function */
// if (sock >= 0)
// sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if (sock < 0) {
if (port != 0)
myport = port;
Expand Down
6 changes: 3 additions & 3 deletions hydra-telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int start_telnet(int s, char *ip, int port, unsigned char options, char *miscptr
} else {
send(s, &buffer[i], 1, 0);
}
usleep(20000);
sleepn(20);
}
} else {
if (hydra_send(s, buffer, strlen(buffer) + 1, 0) < 0) {
Expand Down Expand Up @@ -66,7 +66,7 @@ int start_telnet(int s, char *ip, int port, unsigned char options, char *miscptr
} else {
send(s, &buffer[i], 1, 0);
}
usleep(20000);
sleepn(20);
}
} else {
if (hydra_send(s, buffer, strlen(buffer) + 1, 0) < 0) {
Expand Down Expand Up @@ -112,7 +112,7 @@ void service_telnet(char *ip, int sp, unsigned char options, char *miscptr, FILE
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
no_line_mode = 0;
first = 0;
if ((options & OPTION_SSL) == 0) {
Expand Down
19 changes: 19 additions & 0 deletions hydra-time.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#include <time.h>

#include "hydra.h"

int sleepn(time_t seconds)
{
struct timespec ts;
ts.tv_sec = seconds;
ts.tv_nsec = 0;
return nanosleep(&ts, NULL);
}

int usleepn(long int milisec) {
struct timespec ts;
ts.tv_sec = milisec / 1000;
ts.tv_nsec = (milisec % 1000) * 1000000L;
return nanosleep(&ts, NULL);
}
2 changes: 1 addition & 1 deletion hydra-vmauthd.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void service_vmauthd(char *ip, int sp, unsigned char options, char *miscptr, FIL
case 1: /* connect and service init function */
if (sock >= 0)
sock = hydra_disconnect(sock);
// usleep(300000);
// sleepn(300);
if ((options & OPTION_SSL) == 0) {
if (port != 0)
myport = port;
Expand Down
2 changes: 1 addition & 1 deletion hydra-vnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void service_vnc(char *ip, int sp, unsigned char options, char *miscptr, FILE *
hydra_report(stderr, "[ERROR] Child with pid %d terminating, can not connect\n", (int) getpid());
hydra_child_exit(1);
}
usleep(300000);
sleepn(300);
buf = hydra_receive_line(sock);

if (buf == NULL || (strncmp(buf, "RFB", 3) != 0)) { /* check the first line */
Expand Down
Loading

0 comments on commit 554d66c

Please sign in to comment.