SMTP/s - Port 25,465,587
Last updated
Was this helpful?
Last updated
Was this helpful?
SMTP (Simple Mail Transfer Protocol) is a core component of the internet's email infrastructure, responsible for sending and receiving emails. It's a protocol within the TCP/IP suite, frequently working alongside POP3 or IMAP to store emails on servers and allow users to access them. Despite its widespread use, SMTP has certain vulnerabilities that make it a popular target for penetration testers and hackers.
HELO Itโs the first SMTP command: is starts the conversation identifying the sender server and is generally followed by its domain name.
EHLO An alternative command to start the conversation, underlying that the server is using the Extended SMTP protocol.
MAIL FROM With this SMTP command the operations begin: the sender states the source email address in the โFromโ field and actually starts the email transfer.
RCPT TO It identifies the recipient of the email; if there are more than one, the command is simply repeated address by address.
SIZE This SMTP command informs the remote server about the estimated size (in terms of bytes) of the attached email. It can also be used to report the maximum size of a message to be accepted by the server.
DATA With the DATA command the email content begins to be transferred; itโs generally followed by a 354 reply code given by the server, giving the permission to start the actual transmission.
VRFY The server is asked to verify whether a particular email address or username actually exists.
TURN This command is used to invert roles between the client and the server, without the need to run a new connaction.
AUTH With the AUTH command, the client authenticates itself to the server, giving its username and password. Itโs another layer of security to guarantee a proper transmission.
RSET It communicates the server that the ongoing email transmission is going to be terminated, though the SMTP conversation wonโt be closed (like in the case of QUIT).
EXPN This SMTP command asks for a confirmation about the identification of a mailing list.
HELP Itโs a clientโs request for some information that can be useful for the a successful transfer of the email.
QUIT It terminates the SMTP conversation.
Subdomain Enumeration & DNS Misconfigurations: Before jumping into SMTP directly, expand the reconnaissance section to include subdomain enumeration for deeper target discovery. Tools like amass
or sublist3r
could be used here to identify potential SMTP servers:
Subdomains could potentially host misconfigured or less secure SMTP servers.
Start by using tools like Nmap to identify open ports, typically 25 (SMTP), 465 (SMTPS), and 587 (Submission over TLS):
Using Metasploit:
Discover Mail Exchanger (MX) records for the target organization:
This will return the mail servers responsible for receiving emails for the domain.
Banner grabbing helps identify the SMTP server version, which could contain known vulnerabilities. Use Netcat or OpenSSL to connect and grab the banner:
For secure connections:
Using Metasploit:
Look for:
Server versions
Mail server type (Microsoft ESMTP, Postfix, Exim, etc.)
Any other information leaks (internal hostnames)
Use Nmap's smtp-commands
script to enumerate supported SMTP commands. This may give insights into how to interact with the server, and whether certain attack vectors (like relay attacks) are possible.
An open SMTP relay can be abused to send spam or phishing emails without authentication. Use the smtp-open-relay Nmap script to test for this vulnerability:
Using Telent:
If the server is vulnerable, you will be able to send emails without being an authenticated user.
SMTP servers can sometimes allow username verification using RCPT TO and VRFY commands, revealing valid email accounts on the system.
If you get a 250 OK response, the email address is valid.
You can automate this using tools like smtp-user-enum:
Some SMTP servers may leak internal server names in the response to commands like MAIL FROM:
. For example:
Response:
This internal information could be used in later attacks.
If the SMTP server supports NTLM authentication, you can extract sensitive information by interacting with the authentication process.
Using Metasploit:
SMTP running on port 25 (non-SSL) may allow you to capture email credentials via network sniffing using Wireshark or tcpdump. Look for cleartext AUTH LOGIN
or AUTH PLAIN
credentials.
Wireshark filter:
If authentication is required but weak credentials are suspected, use brute-forcing tools such as Hydra:
Once access is gained to the SMTP server or an open relay is found, it is possible to send phishing emails, malware, or perform further reconnaissance.
Or use Swaks to send phishing emails:
Test antivirus defenses by sending an EICAR test file to see if the server scans attachments for malware. This helps identify email gateway filtering systems: