Mail Retrieval
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
TL;DR
IMAP and POP3 are the retrieval side of mail: they read what SMTP delivered.
- IMAP (Internet Message Access Protocol): mail stays on the server, with folders and multi-client sync. TCP 143 (plaintext or STARTTLS), 993 (implicit TLS).
- POP3 (Post Office Protocol v3): download-and-delete, no folders and no server-side management. TCP 110 (plaintext or STARTTLS), 995 (implicit TLS).
Both are cleartext without TLS, so credentials and mail are sniffable.
First checks: the banner and certificate (hostname, org, admin email), plaintext auth, and whether found credentials log in.
How mail moves is in The Mail Pipeline.
Commands
IMAP tags each command with an identifier such as a. POP3 does not.
| IMAP | Does |
|---|---|
a LOGIN user pass |
Authenticate. |
a LIST "" * |
List every folder. |
a LSUB "" * |
List subscribed folders. |
a SELECT INBOX |
Open a mailbox. |
a FETCH <id> all |
Read a message. |
a LOGOUT |
Close the session. |
| POP3 | Does |
|---|---|
USER <name> |
Name the user. |
PASS <pass> |
Authenticate. |
STAT |
Count the messages. |
LIST |
List messages and sizes. |
RETR <id> |
Read a message. |
DELE <id> |
Delete a message. |
QUIT |
Close the session. |
Enumeration
Sweep.
sudo nmap -p110,143,993,995 -sV -sC -oA scans/mail-retrieval $TARGET # version, capabilities, and certificate-sC runs imap-capabilities or pop3-capabilities and ssl-cert. The certificate leaks the
hostname, organization, and an admin email.
Interact. curl speaks both protocols and sends the right line endings, so it is the quickest
read with found credentials:
curl "pop3://$TARGET/" -u '<user>:<pass>' # POP3: list message numberscurl "pop3://$TARGET/1" -u '<user>:<pass>' # POP3: read message 1curl "imap://$TARGET/" -u '<user>:<pass>' # IMAP: list folderscurl "imap://$TARGET/INBOX;MAILINDEX=1" -u '<user>:<pass>' # IMAP: read message 1On the TLS ports (993, 995) swap in imaps:// and pop3s:// and add -k.
For a hands-on session, send CRLF. Plain nc sends only LF, so a minimal server never answers:
ncat -C $TARGET 110 # plaintext, 110 or 143 (-C sends CRLF)openssl s_client -crlf -connect $TARGET:pop3s # TLS, pop3s or imapsLog in with the full email address here too.
Enumerate POP3 users. Where the server checks the name at USER, its answer leaks whether the
name exists:
ncat -C $TARGET 110 # -C sends CRLF so the server answers (plain nc sends LF)USER <name> # +OK means the user exists, -ERR means it does notMany servers accept any USER and check only at PASS, so test one known name first.
Common misconfigurations
- Plaintext auth without STARTTLS, so credentials are sniffable.
- Anonymous login.
- Verbose auth logging that records passwords.
- Reused credentials from another service.
Attack playbook
Retrieval is for reading mail. The win is credentials in, mail out.
- Log in with found credentials. Credentials from SMTP enumeration, a config, or reuse often work here. Mail holds credentials, password resets, and internal detail.
- Spray credentials. With a user list, spray one password across the users:
hydra -L users.txt -p 'Company01!' -f $TARGET pop3 # swap pop3 for imap to hit the other port
-Lis the user list.-pis the single password.-fstops at the first valid pair. The login is the full email address, sousers.txtholdsmarlin@$DOMAIN, notmarlin. - Read every folder. The useful mail is often outside the inbox. IMAP folder names are
case-sensitive:
POP3 has one flat mailbox:a LIST "" * # list every foldera SELECT <folder> # open a foldera FETCH <id> all # read a messageSTAT # count the messagesLIST # list messages and sizesRETR <id> # read a message
- Sniff plaintext. On port 110 or 143 without TLS, credentials and mail cross the wire in clear.
Practice boxes
| Box | Difficulty | Retrieval’s role |
|---|---|---|
| Mailing | Easy | A cracked hMailServer admin password logs into the mailbox over IMAP to read mail. |
| SolidState | Easy | Apache James admin resets a mailbox password, then read it over POP3 for credentials. |
| SneakyMailer | Medium | Phished credentials open the IMAP mailbox, which holds the developer’s password. |
IMAP and POP3 rarely fall on their own. The win is logging in with found or reused credentials and reading the mail.