đ¨SMTP
(TCP 587, 25, 465)
âšī¸ Introduction
used for submission (send) or relay. mostly widely-used SMTP on linux is sendmail service, on windows, its Microsoft Exchange. both can be setup to support POP3.
submission:
For Explicit SSL/TLS uses port TCP 587 or 2525
For Implicit SSL/TLS uses port TCP 465
Relay:
port TCP 25
âī¸ Checklist
Enumeration
Find Mail Server
Connect
User Enumeration
There are 3 methods (SMTP commands) to test for existance of a user in SMTP service:
VRFY
RCPT
EXPN
Telnet
RCPT TP
VRFY
EXPN
python script for verifying users
change the "method" variable to test for different methods of user enumeration.
Login Brute Force
Delivery Status Notification Disclosure
If you send an email to an organisation to an invalid address, the organisation will notify that the address was invalided sending a mail back to you. Headers of the returned email will contain possible sensitive information (like IP address of the mail services that interacted with the reports or anti-virus software info).
example:
If a SMTP server has accepted the task of relaying a message and later finds that the recipient is incorrect, or that the mail cannot be delivered for whatever reason, then it must construct a NDN message and send it to the originator of the undeliverable mail.
SMTP - NTLM Auth
( Internal Information disclosure )
In Windows environment (MS Exchange) with SMTP - NTLM Auth available, if an attacker sends a null NTLM Auth request, the server to respond with a NTLMSSP message and disclose some information about the target host such as NetBIOS, DNS, OS and version.
nmap
Manual
the same issue exists for IMAP service as well.
Internal Server Name - Information Disclosure
Some SMTP servers auto-complete a sender's address when command "MAIL FROM" is issued without a full address, disclosing its internal name:
Open Relay Attack
An SMTP server that works as an open relay, is a email server that does not verify if the user is authorized to send email from the specified email address. Therefore, users would be able to send email originating from any third-party email address that they want.
Manual
Automated
Mail Spoofing
HackTricks has a good explanation for mail spoofing attacks.
Check for Mail Spoofing Via SPF and DMARC Records
Validating SPF and DMARC DNS Records
Sending Fake Email
SMTP Commands
HELO
(Hello) The client sends this command to the SMTP server to identify itself and initiate the SMTP conversation. The domain name or IP address of the SMTP client is usually sent as an argument together with the command (e.g. âHELO client.example.comâ). If a domain name is used as an argument with the HELO command, it must be a fully qualified domain name (also called FQDN)
MAIL FROM
Specifies the e-mail address of the sender. This command also tells the SMTP server that a new mail transaction is starting and makes the server to reset all its state tables and buffers etc. This command is usually sent as the first command after the identifying and login process. If the senders e-mail address is accepted the server will reply with a 250 OK reply code. Example:
RCPT TO
(Recipient To) Specifies the e-mail address of the recipient. This command can be repeated multiple times for a give n e-mail message in order to deliver a single e-mail message to ultiple recipients. The example below shows how this command can be used to send same e-mail message to two recipients:
DATA
The DATA command starts the transfer of th e message contents (body text, attachments etc). After that the DATA command has been sent to the server from the client, the server will respond with a 354 reply code. After that, the message contents can be transferred to the server. When al l message contents have been sent, a single dot (â.â) must be sent in a li ne by itself. If the message is accepted for delivery, the SMTP server wil l response with a 250 reply code. Example (the message contents is set to italic in the example below):
RSET
(Reset) If the RSET command is sent to the e-mail se rver the current mail transaction will be aborted. The connection wi ll not be closed (this is reserved for the QUIT command, see below) but a ll information about the sender, recipients and e-mail data will be remo ved and buffers and state tables will be cleared.
VRFY
(Verify) This command asks the server to confirm that a specified user name or mailbo x is valid (exists). If the user name is asked, the full name of the u ser and the fully specified mailbox are returned. In some e-mail servers the VRFY command is ignored because it can be a security hole. The command c an be used to probe for login names on servers. Servers that ignore the VRF Y command will usually send some kind of reply, but they will not send the i nformation that the client asked for
NOOP
(No operation) The NOOP command does nothing else than makes the receiver to send a n OK reply. The main purpose is to check that the server is still connec ted and is able to communicate with the client.
QUIT
Asks the server to close the connection. If the connection can be closed the servers replies with a 221 numerical code and then is the session closed.
wrapping up
sending an email from linux:
Last updated