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

CommandDescriptionExample
LOGINAuthenticate userA1 LOGIN user@example.com password
SELECTSelect mailboxA2 SELECT INBOX
LISTList available mailboxesA3 LIST "" "*"
FETCHRetrieve an emailA4 FETCH 1 BODY[]
LOGOUTLogout and close sessionA5 LOGOUT

POP3

CommandDescription
Example
USERProvide usernameUSER user@example.com
PASSProvide passwordPASS password
LISTList available emailsLIST
RETRRetrieve an emailRETR 1
DELEDelete an emailDELE 1
QUITLogout and close sessionQUIT

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:

CommandDescription
AUTH PLAINAUTH is a service extension used to authenticate the client.
HELO/EHLOThe client logs in with its computer name and thus starts the session.
MAIL FROMThe client names the email sender.
RCPT TOThe client names the email recipient.
DATAThe client initiates the transmission of the email.
RSETThe client aborts the initiated transmission but keeps the connection between client and server.
VRFYThe client checks if a mailbox is available for message transfer.
EXPNThe client also checks if a mailbox is available for messaging with this command.
NOOPThe client requests a response from the server to prevent disconnection due to time-out.
QUITThe 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.