Skip to content

Commit

Permalink
smtp-enum: skip host on unsupported command
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Aug 1, 2021
1 parent b375bbc commit cf20153
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 4 additions & 2 deletions hydra-mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,11 @@ void hydra_child_exit(int32_t code) {
__fck = write(intern_socket, "C", 1);
else if (code == 2) /* application protocol error or service shutdown */
__fck = write(intern_socket, "E", 1);
// code 3 means exit without telling mommy about it - a bad idea. mommy should
else if (code == 3) /* application protocol error or service shutdown */
__fck = write(intern_socket, "D", 1);
// code 4 means exit without telling mommy about it - a bad idea. mommy should
// know
else if (code == -1 || code > 3) {
else if (code == -1 || code > 4) {
fprintf(stderr, "[TOTAL FUCKUP] a module should not use "
"hydra_child_exit(-1) ! Fix it in the source please ...\n");
__fck = write(intern_socket, "E", 1);
Expand Down
10 changes: 8 additions & 2 deletions hydra-smtp-enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
//#endif
// hydra_report(stderr, "Server %s", err);
// }
if (strncmp(buf, "500 ", 4) == 0) {
if (strncmp(buf, "500 ", 4) == 0 || strncmp(buf, "502 ", 4) == 0) {
hydra_report(stderr,
"[ERROR] command is disabled on the server (choose "
"different method): %s",
buf);
free(buf);
return 3;
return 4;
}
memset(buffer, 0, sizeof(buffer));
// 503 5.5.1 Error: nested MAIL command
Expand Down Expand Up @@ -245,6 +245,12 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
}
hydra_child_exit(0);
return;
case 4: /* unsupported exit */
if (sock >= 0) {
sock = hydra_disconnect(sock);
}
hydra_child_exit(3);
return;
default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0);
Expand Down
15 changes: 15 additions & 0 deletions hydra.c
Original file line number Diff line number Diff line change
Expand Up @@ -4156,6 +4156,21 @@ int main(int argc, char *argv[]) {
fck = write(hydra_heads[head_no]->sp[1], "n", 1); // small hack
break;

case 'D': // disable target, unknown protocol or feature
for (j = 0; j < hydra_brains.targets; j++)
if (hydra_targets[j]->done == TARGET_ACTIVE) {
hydra_targets[j]->done = TARGET_FINISHED;
hydra_brains.finished++;
}
for (j = 0; j < hydra_options.max_use; j++)
if (hydra_heads[j]->active >= 0 && hydra_heads[j]->target_no == target_no) {
if (hydra_brains.targets > hydra_brains.finished)
hydra_kill_head(j, 1, 0); // kill all heads working on the target
else
hydra_kill_head(j, 1, 2); // kill all heads working on the target
}
break;

// we do not make a difference between 'C' and 'E' results - yet
case 'E': // head reports protocol error
case 'C': // head reports connect error
Expand Down

0 comments on commit cf20153

Please sign in to comment.