Implementing SMTP-AUTH in Hydra

Every protocol Hydra supports needs to define the following variables and include files:

#include "hydra-mod.h"

extern char *HYDRA_EXIT;

char *buf;

The hydra-mod.h include file defines the functions the module accesses while running. The HYDRA_EXIT string is a value returned by some Hydra functions. The buf pointer is used in hydra-smtpauth.c as a temporary buffer for data received.

service_smtpauth(unsigned long int ip, int sp, unsigned char options,
        char *miscptr, FILE * fp, int port)
  int run = 1, next_run, sock = -1;
  int myport = PORT_SMTPAUTH, mysslport = PORT_SMTPAUTH_SSL;
  char *buffer = "EHLO hydra\r\n";

The run and next_run variables are used to control the state of the testing session. service_smtpauth follows a convention similar to many of the other text-based protocols supported in Hydra, whereby it is possible to connect and try multiple sets of credentials. The run values are specified in Table 3-3.

Table 3-3. run values

run values



Connect or reconnect to the service port.


Run the password-testing function on the established connection. You can run this multiple times for one connection for this protocol.


Close the connection and exit gracefully.

The sock variable is used to track the status of the connection to the service. The PORT_SMTPAUTH and PORT_SMTPAUTH_SSL values have been added to the hydra.h file, and they are the ports SMTP runs on normally and when run over SSL (ports 25 and 465, respectively). ...

Get Network Security Tools now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.