githubEdit

Simple Mail Transfer Protocol (SMTP) Penetration Testing

Port: 25

Enumeration

1) Check for information about the server version, etc

Telnet

telnet IP 25

Netcat (nc)

nc IP 25

Nmap

nmap -sV -p 25 IP

2) User enumeration

SMTP commands

VRFY (250 OK means the user is valid)

VRFY admin@domain.com

EXPN (Reveal the members of a mailing list)

EXPN staff@domain.com

RCPT TO

Tools:

Metasploit

Nmap

SMTP User Enum

3) Timing-based enumeration

The attacker sends an email using RCPT TO commands for different users and measures the time taken for the server to respond. A slower response for invalid users can indicate successful user enumeration.

Example:

Response time: 150ms

Response time: 100ms

4) SMTP Response Code Analysis

Even when VRFY and EXPN are disabled, variations in the SMTP server’s response codes can indicate whether a user exists. For example:

5) Email Headers

Analyzing email headers can sometimes reveal internal information about the mail server, including valid email addresses or internal forwarding addresses.

SMTP Relay Attacks

An SMTP relay attack occurs when an attacker takes advantage of an improperly configured SMTP server that allows unauthorized third parties to send emails through it (known as an open relay). These attacks often result in the server being used to send spam or malicious emails.

Attack process

  1. The attacker identifies an SMTP server with open relay functionality.

  2. They craft an email with a spoofed sender address and send it via the open relay server.

  3. The SMTP server forwards the email to the recipient as though it came from the spoofed address, potentially bypassing spam filters.

Tools to detect it:

Nmap

Open Relay Test Tools

Several online tools are available to test whether an SMTP server is configured as an open relay.

Brute force attack

Hydra

Medusa

Metasploit

Last updated