25 - SMTP
Introduction
Port: 25 (TCP)
The Simple Mail Transfer Protocol (SMTP) is a standard protocol is a network protocol used for the exchange of e-mail messages between computers. However, SNMP stands between POP3 and IMAP protocols because it is the only protocol capable of sending emails.
Enumeration
As a starting point, you can use the SMTP scripts in order to gather further information like:
Basic user enumeration
Supported SMTP commands (You can also use the
HELP
command)NetBios, DNS and OS version.
Checks for some vulnerabilities
sudo nmap -p25 --script="smtp* and not brute" <TARGET>
Alternatively, you can use Metasploit to gather the SMTP version with the following payload.
use auxiliary/scanner/smtp/smtp_version
User enumeration
There are at least three commands that can be used for user enumeration:
VRFY: Used to verify if a certain user is known to the SMTP-server
EXPN: Used to reveal the actual email address(es) of an alias
RCPT TO: A needed command to specify to whom the email should be sent
The main difference between VRFY and EXPN, and "RCPT TO" is that with the formers, you enter the command alongside the account, name, alias or email address you want to check, obtaining a 25X response if the account exists else a 550. In contrast, the latter requires you to write a whole email to work.
[nc -nC <TARGET> <PORT>] | [telnet <TARGET> <PORT>] | [openssl s_client -starttls smtp -connect <TARGET>:587]
EHLO localhost
VRFY root
252 2.0.0 root
VRFY idontexist
550 5.1.1 <idontexist>: Recipient address rejected: User unknown in local recipient table
Finally, as an alternative, you can use the SMTP Metasploit module to enumerate users.
auxiliary/scanner/smtp/smtp_enum
Writing emails
If you have access to a company's SMTP email server, you can try to send emails to its employees in order to perform phishing or spoofing attacks.
mail from: <[email protected]>
rcpt to: <[email protected]>, <[email protected]>
data
Subject: Not a phishing email
Hello,
Please access this website with your work credentials...
The IT department
.
If you want to avoid writing all those lines, you can write a simple command, thanks to the SWAKS tool.
swaks --to <EMAIL_1>,<EMAIL_2> --from <EMAIL_3> --server <SMTP_IP> [--auth LOGIN --auth-user "<USER>" --auth-password "<PASSWORD>"] [--add-header "MIME-Version: 1.0" --add-header "Content-Type: text/html"] --header "Subject: <Subject>" --body "<a href='https://evil.com'>Microsoft</a>" [ --attach <FILE_PATH>]
sendemail -t <EMAIL_1> -f <EMAIL_2> -s <SMTP_IP> -u "<subject>" -m "<Message>" [-a <FILE_PATH>]
References
Last updated