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;
|
||||
size_t countinfile = 1, sizeinfile = 0;
|
||||
unsigned long int math2;
|
||||
int i = 0, j = 0, k, error = 0, modusage = 0, ignore_restore = 0;
|
||||
int head_no = 0, target_no = 0, exit_condition = 0, readres;
|
||||
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, time_next_attempt = 0;
|
||||
time_t starttime, elapsed_status, elapsed_restore, status_print = 59, tmp_time;
|
||||
char *tmpptr, *tmpptr2;
|
||||
char rc, buf[MAXBUF];
|
||||
time_t last_attempt = 0;
|
||||
fd_set fdreadheads;
|
||||
int max_fd;
|
||||
struct addrinfo hints, *res, *p;
|
||||
|
@ -2421,7 +2422,7 @@ int main(int argc, char *argv[]) {
|
|||
help(1);
|
||||
if (argc < 2)
|
||||
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) {
|
||||
case 'h':
|
||||
help(1);
|
||||
|
@ -2542,6 +2543,13 @@ int main(int argc, char *argv[]) {
|
|||
case 's':
|
||||
hydra_options.port = port = atoi(optarg);
|
||||
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':
|
||||
#ifndef LIBOPENSSL
|
||||
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("\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)
|
||||
bail("You can only use -L OR -l, not both\n");
|
||||
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++) {
|
||||
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);
|
||||
|
||||
switch (hydra_heads[head_no]->active) {
|
||||
case -1:
|
||||
// disabled head, ignored
|
||||
|
@ -3888,6 +3899,15 @@ int main(int argc, char *argv[]) {
|
|||
break;
|
||||
case 1:
|
||||
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);
|
||||
if (readres > 0) {
|
||||
FD_CLR(hydra_heads[head_no]->sp[0], &fdreadheads);
|
||||
|
@ -4028,13 +4048,14 @@ int main(int argc, char *argv[]) {
|
|||
default:
|
||||
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);
|
||||
}
|
||||
}
|
||||
} // end switch
|
||||
} // readres
|
||||
if (readres == -1) {
|
||||
if (verbose)
|
||||
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);
|
||||
}
|
||||
} // end do_switch
|
||||
} else {
|
||||
if (hydra_heads[head_no]->last_seen + hydra_options.waittime > tmp_time) {
|
||||
// check if recover of timed-out head is necessary
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue