mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-19 13:01:00 -07:00
option -c test
This commit is contained in:
parent
5bcc39c6a4
commit
d917d1aeba
1 changed files with 156 additions and 135 deletions
31
hydra.c
31
hydra.c
|
@ -2298,11 +2298,12 @@ int main(int argc, char *argv[]) {
|
||||||
FILE *lfp = NULL, *pfp = NULL, *cfp = NULL, *ifp = NULL, *rfp = NULL, *proxyfp;
|
FILE *lfp = NULL, *pfp = NULL, *cfp = NULL, *ifp = NULL, *rfp = NULL, *proxyfp;
|
||||||
size_t countinfile = 1, sizeinfile = 0;
|
size_t countinfile = 1, sizeinfile = 0;
|
||||||
unsigned long int math2;
|
unsigned long int math2;
|
||||||
int i = 0, j = 0, k, error = 0, modusage = 0, ignore_restore = 0;
|
int i = 0, j = 0, k, error = 0, modusage = 0, ignore_restore = 0, do_switch;
|
||||||
int head_no = 0, target_no = 0, exit_condition = 0, readres;
|
int head_no = 0, target_no = 0, exit_condition = 0, readres, time_next_attempt = 0;
|
||||||
time_t starttime, elapsed_status, elapsed_restore, status_print = 59, tmp_time;
|
time_t starttime, elapsed_status, elapsed_restore, status_print = 59, tmp_time;
|
||||||
char *tmpptr, *tmpptr2;
|
char *tmpptr, *tmpptr2;
|
||||||
char rc, buf[MAXBUF];
|
char rc, buf[MAXBUF];
|
||||||
|
time_t last_attempt = 0;
|
||||||
fd_set fdreadheads;
|
fd_set fdreadheads;
|
||||||
int max_fd;
|
int max_fd;
|
||||||
struct addrinfo hints, *res, *p;
|
struct addrinfo hints, *res, *p;
|
||||||
|
@ -2421,7 +2422,7 @@ int main(int argc, char *argv[]) {
|
||||||
help(1);
|
help(1);
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
help(0);
|
help(0);
|
||||||
while ((i = getopt(argc, argv, "hIq64Rde:vVl:fFg:L:p:OP:o:b:M:C:t:T:m:w:W:s:SUux:y")) >= 0) {
|
while ((i = getopt(argc, argv, "hIq64Rde:vVl:fFg:L:p:OP:o:b:M:C:t:T:m:w:W:s:SUux:yc:")) >= 0) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'h':
|
case 'h':
|
||||||
help(1);
|
help(1);
|
||||||
|
@ -2542,6 +2543,13 @@ int main(int argc, char *argv[]) {
|
||||||
case 's':
|
case 's':
|
||||||
hydra_options.port = port = atoi(optarg);
|
hydra_options.port = port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
#ifdef MSG_PEEK
|
||||||
|
time_next_attempt = atoi(optarg);
|
||||||
|
#else
|
||||||
|
fprintf(stderr, "[WARNING] -c option can not be used as your operating system is missing the MSG_PEEK feature\n");
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
#ifndef LIBOPENSSL
|
#ifndef LIBOPENSSL
|
||||||
fprintf(stderr, "[WARNING] hydra was compiled without SSL support. Install openssl and recompile! Option ignored...\n");
|
fprintf(stderr, "[WARNING] hydra was compiled without SSL support. Install openssl and recompile! Option ignored...\n");
|
||||||
|
@ -2611,6 +2619,8 @@ int main(int argc, char *argv[]) {
|
||||||
printf("%s ", argv[i]);
|
printf("%s ", argv[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
if (hydra_options.tasks > 0 && time_next_attempt)
|
||||||
|
fprintf(stderr, "[WARNING] when using the -c option, you should also set the task per target to one (-t 1)\n");
|
||||||
if (hydra_options.login != NULL && hydra_options.loginfile != NULL)
|
if (hydra_options.login != NULL && hydra_options.loginfile != NULL)
|
||||||
bail("You can only use -L OR -l, not both\n");
|
bail("You can only use -L OR -l, not both\n");
|
||||||
if (hydra_options.pass != NULL && hydra_options.passfile != NULL)
|
if (hydra_options.pass != NULL && hydra_options.passfile != NULL)
|
||||||
|
@ -3864,6 +3874,7 @@ int main(int argc, char *argv[]) {
|
||||||
for (head_no = 0; head_no < hydra_options.max_use; head_no++) {
|
for (head_no = 0; head_no < hydra_options.max_use; head_no++) {
|
||||||
if (debug > 1 && hydra_heads[head_no]->active != -1)
|
if (debug > 1 && hydra_heads[head_no]->active != -1)
|
||||||
printf("[DEBUG] head_no[%d] to target_no %d active %d\n", head_no, hydra_heads[head_no]->target_no, hydra_heads[head_no]->active);
|
printf("[DEBUG] head_no[%d] to target_no %d active %d\n", head_no, hydra_heads[head_no]->target_no, hydra_heads[head_no]->active);
|
||||||
|
|
||||||
switch (hydra_heads[head_no]->active) {
|
switch (hydra_heads[head_no]->active) {
|
||||||
case -1:
|
case -1:
|
||||||
// disabled head, ignored
|
// disabled head, ignored
|
||||||
|
@ -3888,6 +3899,15 @@ int main(int argc, char *argv[]) {
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (FD_ISSET(hydra_heads[head_no]->sp[0], &fdreadheads)) {
|
if (FD_ISSET(hydra_heads[head_no]->sp[0], &fdreadheads)) {
|
||||||
|
do_switch = 1;
|
||||||
|
if (time_next_attempt > 0) {
|
||||||
|
if (last_attempt + time_next_attempt >= time(NULL)) {
|
||||||
|
if (recv(hydra_heads[head_no]->sp[0], &rc, 1, MSG_PEEK) == 1 && (rc == 'N' || rc == 'n'))
|
||||||
|
do_switch = 0;
|
||||||
|
} else
|
||||||
|
last_attempt = time(NULL);
|
||||||
|
}
|
||||||
|
if (do_switch) {
|
||||||
readres = read_safe(hydra_heads[head_no]->sp[0], &rc, 1);
|
readres = read_safe(hydra_heads[head_no]->sp[0], &rc, 1);
|
||||||
if (readres > 0) {
|
if (readres > 0) {
|
||||||
FD_CLR(hydra_heads[head_no]->sp[0], &fdreadheads);
|
FD_CLR(hydra_heads[head_no]->sp[0], &fdreadheads);
|
||||||
|
@ -4028,13 +4048,14 @@ int main(int argc, char *argv[]) {
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "[ERROR] child %d sent nonsense data, killing and restarting it!\n", head_no);
|
fprintf(stderr, "[ERROR] child %d sent nonsense data, killing and restarting it!\n", head_no);
|
||||||
hydra_increase_fail_count(hydra_heads[head_no]->target_no, head_no);
|
hydra_increase_fail_count(hydra_heads[head_no]->target_no, head_no);
|
||||||
}
|
} // end switch
|
||||||
}
|
} // readres
|
||||||
if (readres == -1) {
|
if (readres == -1) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "[WARNING] child %d seems to have died, restarting (this only happens if a module is bad) ... \n", head_no);
|
fprintf(stderr, "[WARNING] child %d seems to have died, restarting (this only happens if a module is bad) ... \n", head_no);
|
||||||
hydra_increase_fail_count(hydra_heads[head_no]->target_no, head_no);
|
hydra_increase_fail_count(hydra_heads[head_no]->target_no, head_no);
|
||||||
}
|
}
|
||||||
|
} // end do_switch
|
||||||
} else {
|
} else {
|
||||||
if (hydra_heads[head_no]->last_seen + hydra_options.waittime > tmp_time) {
|
if (hydra_heads[head_no]->last_seen + hydra_options.waittime > tmp_time) {
|
||||||
// check if recover of timed-out head is necessary
|
// check if recover of timed-out head is necessary
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue