Email Services (IMAP/POP3)
Overview
IMAP and POP3 are email retrieval protocols that allow clients to access email messages stored on mail servers. During enumeration, these services can reveal valuable information about the organization, system configuration, and potentially provide access to email data.
Key Characteristics:
POP3: Port 110 (plain), 995 (SSL/TLS)
IMAP: Port 143 (plain), 993 (SSL/TLS)
Protocol: Text-based commands
Authentication: Username/password based
Encryption: STARTTLS or SSL/TLS
IMAP vs POP3 Differences
Email Storage
Server-side (emails remain on server)
Client-side (downloads to local)
Multi-device Access
Yes (synchronization across devices)
Limited (downloads remove from server)
Folder Management
Yes (hierarchical mailboxes)
No (single inbox only)
Offline Access
Limited (requires sync)
Full (emails downloaded locally)
Server Storage
Higher (emails stored on server)
Lower (emails removed after download)
Functionality
Advanced (search, flags, folders)
Basic (list, retrieve, delete)
Typical Usage
Modern email clients, webmail
Legacy systems, simple clients
Port Overview
POP3
110
Post Office Protocol v3 (plain text)
POP3S
995
POP3 over SSL/TLS
IMAP
143
Internet Message Access Protocol (plain text)
IMAPS
993
IMAP over SSL/TLS
Protocol Commands
IMAP Commands
1 LOGIN username password
User's login
1 LIST "" *
Lists all directories
1 CREATE "INBOX"
Creates a mailbox with specified name
1 DELETE "INBOX"
Deletes a mailbox
1 RENAME "ToRead" "Important"
Renames a mailbox
1 LSUB "" *
Returns subset of names from active/subscribed mailboxes
1 SELECT INBOX
Selects a mailbox for message access
1 UNSELECT INBOX
Exits the selected mailbox
1 FETCH <ID> all
Retrieves data associated with a message
1 CLOSE
Removes all messages with Deleted flag set
1 LOGOUT
Closes connection with IMAP server
POP3 Commands
USER username
Identifies the user
PASS password
Authentication of the user using password
STAT
Requests number of saved emails from server
LIST
Requests number and size of all emails
RETR id
Requests server to deliver requested email by ID
DELE id
Requests server to delete requested email by ID
CAPA
Requests server to display server capabilities
RSET
Requests server to reset transmitted information
QUIT
Closes connection with POP3 server
Dangerous Settings
IMAP/POP3 servers like Dovecot can be misconfigured, potentially exposing sensitive information:
auth_debug
Enables all authentication debug logging
High
auth_debug_passwords
Logs submitted passwords and schemes
Critical
auth_verbose
Logs unsuccessful authentication attempts and reasons
Medium
auth_verbose_passwords
Passwords used for authentication are logged
Critical
auth_anonymous_username
Username for ANONYMOUS SASL mechanism
Medium
Enumeration Techniques
1. Service Detection
2. Banner Grabbing
3. SSL Certificate Analysis
4. Service Capabilities
Advanced Enumeration
Using OpenSSL for Encrypted Connections
Using cURL for IMAP/POP3 Testing
Example cURL Verbose Output Analysis:
SSL Certificate Information Extraction
Authentication Testing
IMAP Enumeration
Basic IMAP Commands
IMAP Enumeration Session
POP3 Enumeration
Basic POP3 Commands
POP3 Enumeration Session
Information Gathering
SSL Certificate Analysis
Email Header Analysis
Practical Examples
HTB Academy Style Enumeration
HTB Academy Lab Questions Examples
Custom Version Detection
Certificate Information Extraction
Security Assessment
Common Vulnerabilities
Weak Authentication: Default or weak passwords
Plaintext Transmission: Unencrypted connections
Information Disclosure: Verbose error messages
Certificate Issues: Self-signed or invalid certificates
Authentication Testing
Enumeration Checklist
Initial Discovery
Information Gathering
Authentication Testing
Content Analysis
Tools and Techniques
Essential Tools
Custom Scripts
Defensive Measures
Secure Configuration
Best Practices
Enforce SSL/TLS: Disable plaintext protocols
Strong Authentication: Implement strong password policies
Rate Limiting: Prevent brute force attacks
Monitoring: Log authentication attempts
Certificate Management: Use valid certificates
Detection and Monitoring
Common Attack Vectors
1. Credential Brute Force
2. Information Disclosure
Server version information
Internal network details
Email addresses and contacts
Organizational structure
3. Man-in-the-Middle
Intercept plaintext connections
Certificate validation bypass
Credential harvesting
Last updated