SMTP (25,587)

The Simple Mail Transfer Protocol (SMTP) is a protocol for sending emails over an IP network. It can be used between an email client and an outgoing mail server or between two SMTP servers. SMTP is often combined with the IMAP or POP3 protocols, which can retrieve emails and send emails
  • Command: Description
  • AUTH PLAIN: AUTH is a service extension used to authenticate the client.
  • HELO: The client logs in with its computer name, thereby starting the session.
  • MAIL FROM: The client specifies the email sender.
  • RCPT TO: The client specifies the email recipient.
  • DATA: The client initiates the email transmission.
  • RSET: The client aborts the initiated transmission but maintains the connection between the client and the server.
  • VRFY: Verify users (enumerate them)
  • EXPN: The client also uses this command to check whether a mailbox is available for sending messages.
  • NOOP: The client requests a response from the server to avoid disconnection due to a timeout.
  • QUIT: The client ends the session.
To interact with the SMTP server, we can use telnet

Commands

HELO/EHLO

They are the same and are used to initiate the connection with the server
txt
HELO mail1.inlanefreight.htb

250 mail1.inlanefreight.htb

EHLO mail1

250-mail1.inlanefreight.htb
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING

VRFY

It is used to enumerate existing users on the system. However, this does not always work
txt
VRFY root

252 2.0.0 root

VRFY cry0l1t3

252 2.0.0 cry0l1t3

VRFY testuser

252 2.0.0 testuser

VRFY aaaaaaaaaaaaaaaaaaaaaaaaaaaa

252 2.0.0 aaaaaaaaaaaaaaaaaaaaaaaaaaaa

Service Footprinting

Nmap's default scripts include smtp-commands, which uses the EHLO command to enumerate all possible commands that can be executed on the target SMTP server
txt
sudo nmap 10.129.14.128 -sC -sV -p25

PORT   STATE SERVICE VERSION
25/tcp open  smtp    Postfix smtpd
|_smtp-commands: mail1.inlanefreight.htb, PIPELINING, SIZE 10240000, VRFY, ETRN, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING,

Open-Relay

To identify the target SMTP server as an open relay using 16 different tests
txt
PORT   STATE SERVICE
25/tcp open  smtp
| smtp-open-relay: Server is an open relay (16/16 tests)
|  MAIL FROM:<> -> RCPT TO:<relaytest@nmap.scanme.org>
|  MAIL FROM:<antispam@nmap.scanme.org> -> RCPT TO:<relaytest@nmap.scanme.org>
|  MAIL FROM:<antispam@ESMTP> -> RCPT TO:<relaytest@nmap.scanme.org>
|  MAIL FROM:<antispam@[10.129.14.128]> -> RCPT TO:<relaytest@nmap.scanme.org>
|  MAIL FROM:<antispam@[10.129.14.128]> -> RCPT TO:<relaytest%nmap.scanme.org@[10.129.14.128]>
|_ MAIL FROM:<antispam@[10.129.14.128]> -> RCPT TO:<nmap.scanme.org!relaytest@ESMTP>

Brute-Force User Enumeration

The Metasploit smtp enum module can be used