mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-05 20:41:39 -07:00
feat: added paths for brute force and additional settings for all targets from the file
This commit is contained in:
parent
4fad67d307
commit
79f7d52ba2
1 changed files with 18 additions and 7 deletions
25
hydra.c
25
hydra.c
|
@ -267,6 +267,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *target;
|
char *target;
|
||||||
|
char *miscptr;
|
||||||
char ip[36];
|
char ip[36];
|
||||||
char *login_ptr;
|
char *login_ptr;
|
||||||
char *pass_ptr;
|
char *pass_ptr;
|
||||||
|
@ -1174,13 +1175,12 @@ void hydra_service_init(int32_t target_no) {
|
||||||
int32_t x = 99;
|
int32_t x = 99;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
hydra_target *t = hydra_targets[target_no];
|
hydra_target *t = hydra_targets[target_no];
|
||||||
char *miscptr = hydra_options.miscptr;
|
|
||||||
FILE *ofp = hydra_brains.ofp;
|
FILE *ofp = hydra_brains.ofp;
|
||||||
|
|
||||||
for (i = 0; x == 99 && i < sizeof(services) / sizeof(services[0]); i++) {
|
for (i = 0; x == 99 && i < sizeof(services) / sizeof(services[0]); i++) {
|
||||||
if (strcmp(hydra_options.service, services[i].name) == 0) {
|
if (strcmp(hydra_options.service, services[i].name) == 0) {
|
||||||
if (services[i].init) {
|
if (services[i].init) {
|
||||||
x = services[i].init(t->ip, -1, options, miscptr, ofp, t->port, t->target);
|
x = services[i].init(t->ip, -1, options, t->miscptr, ofp, t->port, t->target);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1264,13 +1264,13 @@ int32_t hydra_spawn_head(int32_t head_no, int32_t target_no) {
|
||||||
|
|
||||||
hydra_target *t = hydra_targets[target_no];
|
hydra_target *t = hydra_targets[target_no];
|
||||||
int32_t sp = hydra_heads[head_no]->sp[1];
|
int32_t sp = hydra_heads[head_no]->sp[1];
|
||||||
char *miscptr = hydra_options.miscptr;
|
// char *miscptr = hydra_options.miscptr;
|
||||||
FILE *ofp = hydra_brains.ofp;
|
FILE *ofp = hydra_brains.ofp;
|
||||||
hydra_target *head_target = hydra_targets[hydra_heads[head_no]->target_no];
|
hydra_target *head_target = hydra_targets[hydra_heads[head_no]->target_no];
|
||||||
for (i = 0; i < sizeof(services) / sizeof(services[0]); i++) {
|
for (i = 0; i < sizeof(services) / sizeof(services[0]); i++) {
|
||||||
if (strcmp(hydra_options.service, services[i].name) == 0) {
|
if (strcmp(hydra_options.service, services[i].name) == 0) {
|
||||||
if (services[i].exec) {
|
if (services[i].exec) {
|
||||||
services[i].exec(t->ip, sp, options, miscptr, ofp, t->port, head_target->target);
|
services[i].exec(t->ip, sp, options, t->miscptr, ofp, t->port, head_target->target);
|
||||||
// just in case a module returns (which it shouldnt) we let it exit
|
// just in case a module returns (which it shouldnt) we let it exit
|
||||||
// here
|
// here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -2177,7 +2177,7 @@ int main(int argc, char *argv[]) {
|
||||||
int32_t i = 0, j = 0, k, error = 0, modusage = 0, ignore_restore = 0, do_switch;
|
int32_t i = 0, j = 0, k, error = 0, modusage = 0, ignore_restore = 0, do_switch;
|
||||||
int32_t head_no = 0, target_no = 0, exit_condition = 0, readres;
|
int32_t head_no = 0, target_no = 0, exit_condition = 0, readres;
|
||||||
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, *tmpptr3;
|
||||||
char rc, buf[MAXBUF];
|
char rc, buf[MAXBUF];
|
||||||
time_t last_attempt = 0;
|
time_t last_attempt = 0;
|
||||||
fd_set fdreadheads;
|
fd_set fdreadheads;
|
||||||
|
@ -3543,7 +3543,7 @@ int main(int argc, char *argv[]) {
|
||||||
fclose(rfp);
|
fclose(rfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hydra_options.infile_ptr != NULL) {
|
if (hydra_options.infile_ptr != NULL) {
|
||||||
if ((ifp = fopen(hydra_options.infile_ptr, "r")) == NULL) {
|
if ((ifp = fopen(hydra_options.infile_ptr, "r")) == NULL) {
|
||||||
fprintf(stderr, "[ERROR] File for targets not found: %s\n", hydra_options.infile_ptr);
|
fprintf(stderr, "[ERROR] File for targets not found: %s\n", hydra_options.infile_ptr);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -3591,6 +3591,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
hydra_targets[i]->target = tmpptr;
|
hydra_targets[i]->target = tmpptr;
|
||||||
|
|
||||||
if ((tmpptr2 = strchr(tmpptr, ':')) != NULL) {
|
if ((tmpptr2 = strchr(tmpptr, ':')) != NULL) {
|
||||||
*tmpptr2++ = 0;
|
*tmpptr2++ = 0;
|
||||||
tmpptr = tmpptr2;
|
tmpptr = tmpptr2;
|
||||||
|
@ -3600,6 +3601,13 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
if (hydra_targets[i]->port == 0)
|
if (hydra_targets[i]->port == 0)
|
||||||
hydra_targets[i]->port = hydra_options.port;
|
hydra_targets[i]->port = hydra_options.port;
|
||||||
|
|
||||||
|
if ((tmpptr3 = strchr(tmpptr, '/')) != NULL) {
|
||||||
|
hydra_targets[i]->miscptr = tmpptr3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hydra_targets[i]->miscptr = "/";
|
||||||
|
|
||||||
while (*tmpptr != 0)
|
while (*tmpptr != 0)
|
||||||
tmpptr++;
|
tmpptr++;
|
||||||
tmpptr++;
|
tmpptr++;
|
||||||
|
@ -3622,6 +3630,7 @@ int main(int argc, char *argv[]) {
|
||||||
memset(hydra_targets[0], 0, sizeof(hydra_target));
|
memset(hydra_targets[0], 0, sizeof(hydra_target));
|
||||||
hydra_targets[0]->target = servers_ptr = hydra_options.server;
|
hydra_targets[0]->target = servers_ptr = hydra_options.server;
|
||||||
hydra_targets[0]->port = hydra_options.port;
|
hydra_targets[0]->port = hydra_options.port;
|
||||||
|
hydra_targets[0]->miscptr = hydra_options.miscptr;
|
||||||
sizeservers = strlen(hydra_options.server) + 1;
|
sizeservers = strlen(hydra_options.server) + 1;
|
||||||
} else {
|
} else {
|
||||||
/* CIDR notation on command line, e.g. 192.168.0.0/24 */
|
/* CIDR notation on command line, e.g. 192.168.0.0/24 */
|
||||||
|
@ -3666,6 +3675,7 @@ int main(int argc, char *argv[]) {
|
||||||
memcpy(&target.sin_addr.s_addr, (char *)&addr_cur2, 4);
|
memcpy(&target.sin_addr.s_addr, (char *)&addr_cur2, 4);
|
||||||
hydra_targets[i]->target = strdup(inet_ntoa((struct in_addr)target.sin_addr));
|
hydra_targets[i]->target = strdup(inet_ntoa((struct in_addr)target.sin_addr));
|
||||||
hydra_targets[i]->port = hydra_options.port;
|
hydra_targets[i]->port = hydra_options.port;
|
||||||
|
hydra_targets[i]->miscptr = hydra_options.miscptr;
|
||||||
addr_cur++;
|
addr_cur++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -3681,6 +3691,7 @@ int main(int argc, char *argv[]) {
|
||||||
memset(hydra_targets[0], 0, sizeof(hydra_target));
|
memset(hydra_targets[0], 0, sizeof(hydra_target));
|
||||||
hydra_targets[0]->target = servers_ptr = hydra_options.server;
|
hydra_targets[0]->target = servers_ptr = hydra_options.server;
|
||||||
hydra_targets[0]->port = hydra_options.port;
|
hydra_targets[0]->port = hydra_options.port;
|
||||||
|
hydra_targets[0]->miscptr = hydra_options.miscptr;
|
||||||
sizeservers = strlen(hydra_options.server) + 1;
|
sizeservers = strlen(hydra_options.server) + 1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < hydra_brains.targets; i++) {
|
for (i = 0; i < hydra_brains.targets; i++) {
|
||||||
|
@ -4113,7 +4124,7 @@ int main(int argc, char *argv[]) {
|
||||||
} else if (hydra_heads[head_no]->current_pass_ptr == NULL || strlen(hydra_heads[head_no]->current_pass_ptr) == 0) {
|
} else if (hydra_heads[head_no]->current_pass_ptr == NULL || strlen(hydra_heads[head_no]->current_pass_ptr) == 0) {
|
||||||
printf("[%d][%s] host: %s login: %s\n", hydra_targets[hydra_heads[head_no]->target_no]->port, hydra_options.service, hydra_targets[hydra_heads[head_no]->target_no]->target, hydra_heads[head_no]->current_login_ptr);
|
printf("[%d][%s] host: %s login: %s\n", hydra_targets[hydra_heads[head_no]->target_no]->port, hydra_options.service, hydra_targets[hydra_heads[head_no]->target_no]->target, hydra_heads[head_no]->current_login_ptr);
|
||||||
} else
|
} else
|
||||||
printf("[%d][%s] host: %s login: %s password: %s\n", hydra_targets[hydra_heads[head_no]->target_no]->port, hydra_options.service, hydra_targets[hydra_heads[head_no]->target_no]->target, hydra_heads[head_no]->current_login_ptr, hydra_heads[head_no]->current_pass_ptr);
|
printf("[%d][%s] host: %s misc: %s login: %s password: %s\n", hydra_targets[hydra_heads[head_no]->target_no]->port, hydra_options.service, hydra_targets[hydra_heads[head_no]->target_no]->target, hydra_targets[hydra_heads[head_no]->target_no]->miscptr, hydra_heads[head_no]->current_login_ptr, hydra_heads[head_no]->current_pass_ptr);
|
||||||
}
|
}
|
||||||
if (hydra_options.outfile_format == FORMAT_JSONV1 && hydra_options.outfile_ptr != NULL && hydra_brains.ofp != NULL) {
|
if (hydra_options.outfile_format == FORMAT_JSONV1 && hydra_options.outfile_ptr != NULL && hydra_brains.ofp != NULL) {
|
||||||
fprintf(hydra_brains.ofp,
|
fprintf(hydra_brains.ofp,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue