Table of Contents
IMAP & POP3
With the help of the Internet Message Access Protocol (IMAP), access to emails from a mail server is possible. Unlike the Post Office Protocol (POP3), IMAP allows online management of emails directly on the server and supports folder structures. Thus, it is a network protocol for the online management of emails on a remote server. The protocol is client-server-based and allows synchronization of a local email client with the mailbox on the server, providing a kind of network file system for emails, allowing problem-free synchronization across several independent clients. POP3, on the other hand, does not have the same functionality as IMAP, and it only provides listing, retrieving, and deleting emails as functions at the email server. Therefore, protocols such as IMAP must be used for additional functionalities such as hierarchical mailboxes directly at the mail server, access to multiple mailboxes during a session, and preselection of emails.
You can login to IMAP (POP3 I think too) using curl.
curl -k 'imaps://10.129.14.128' --user cry0l1t3:1234 -v
To interact with the IMAP or POP3 server over SSL, we can use openssl, as well as ncat. The commands for this would look like this:
openssl s_client -connect 10.129.14.128:pop3s
openssl s_client -connect 10.129.14.128:imaps
Here are some basic commands for both but I recommend checking the links in references as well.
IMAP
| Command | Description | Example |
|---|---|---|
LOGIN | Authenticate user | A1 LOGIN user@example.com password |
SELECT | Select mailbox | A2 SELECT INBOX |
LIST | List available mailboxes | A3 LIST "" "*" |
FETCH | Retrieve an email | A4 FETCH 1 BODY[] |
LOGOUT | Logout and close session | A5 LOGOUT |
POP3
| Command | Description | Example |
|---|---|---|
USER | Provide username | USER user@example.com |
PASS | Provide password | PASS password |
LIST | List available emails | LIST |
RETR | Retrieve an email | RETR 1 |
DELE | Delete an email | DELE 1 |
QUIT | Logout and close session | QUIT |
SMTP
The Simple Mail Transfer Protocol (SMTP) is a protocol for sending emails in 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.
To connect to SMTP simply use telnet and specify a port like: telnet <FQDN/IP> 25
The commands are:
| Command | Description |
|---|---|
AUTH PLAIN | AUTH is a service extension used to authenticate the client. |
HELO/EHLO | The client logs in with its computer name and thus starts the session. |
MAIL FROM | The client names the email sender. |
RCPT TO | The client names the email recipient. |
DATA | The client initiates the transmission of the email. |
RSET | The client aborts the initiated transmission but keeps the connection between client and server. |
VRFY | The client checks if a mailbox is available for message transfer. |
EXPN | The client also checks if a mailbox is available for messaging with this command. |
NOOP | The client requests a response from the server to prevent disconnection due to time-out. |
QUIT | The client terminates the session. |
References
IMAP & POP3
https://everything.curl.dev/usingcurl/reademail.html - Useful commands
https://donsutherland.org/crib/imap - More commands for IMAP
SMTP
https://mailtrap.io/blog/smtp-relay/ - Great article explaining how emails travel looks like between the sender and the recipient
To make sure you check a lot of usernames/hostnames it’s good ot use smtp-user-enum and some long wordlists.