smtp-enum: skip host on unsupported command

This commit is contained in:
vanhauser-thc 2021-08-01 11:06:15 +02:00
parent b375bbc332
commit cf20153655
3 changed files with 27 additions and 4 deletions

View file

@ -637,9 +637,11 @@ void hydra_child_exit(int32_t code) {
__fck = write(intern_socket, "C", 1); __fck = write(intern_socket, "C", 1);
else if (code == 2) /* application protocol error or service shutdown */ else if (code == 2) /* application protocol error or service shutdown */
__fck = write(intern_socket, "E", 1); __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 // know
else if (code == -1 || code > 3) { else if (code == -1 || code > 4) {
fprintf(stderr, "[TOTAL FUCKUP] a module should not use " fprintf(stderr, "[TOTAL FUCKUP] a module should not use "
"hydra_child_exit(-1) ! Fix it in the source please ...\n"); "hydra_child_exit(-1) ! Fix it in the source please ...\n");
__fck = write(intern_socket, "E", 1); __fck = write(intern_socket, "E", 1);

View file

@ -128,13 +128,13 @@ int32_t start_smtp_enum(int32_t s, char *ip, int32_t port, unsigned char options
//#endif //#endif
// hydra_report(stderr, "Server %s", err); // 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, hydra_report(stderr,
"[ERROR] command is disabled on the server (choose " "[ERROR] command is disabled on the server (choose "
"different method): %s", "different method): %s",
buf); buf);
free(buf); free(buf);
return 3; return 4;
} }
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
// 503 5.5.1 Error: nested MAIL command // 503 5.5.1 Error: nested MAIL command
@ -245,6 +245,12 @@ void service_smtp_enum(char *ip, int32_t sp, unsigned char options, char *miscpt
} }
hydra_child_exit(0); hydra_child_exit(0);
return; return;
case 4: /* unsupported exit */
if (sock >= 0) {
sock = hydra_disconnect(sock);
}
hydra_child_exit(3);
return;
default: default:
hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n"); hydra_report(stderr, "[ERROR] Caught unknown return code, exiting!\n");
hydra_child_exit(0); hydra_child_exit(0);

15
hydra.c
View file

@ -4156,6 +4156,21 @@ int main(int argc, char *argv[]) {
fck = write(hydra_heads[head_no]->sp[1], "n", 1); // small hack fck = write(hydra_heads[head_no]->sp[1], "n", 1); // small hack
break; 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 // we do not make a difference between 'C' and 'E' results - yet
case 'E': // head reports protocol error case 'E': // head reports protocol error
case 'C': // head reports connect error case 'C': // head reports connect error