IMAP - Port 143, 993
Last updated
Was this helpful?
Last updated
Was this helpful?
Become VeryLazyTech ! π
Follow us on:
β Twitter .
πΎ Github .
π Medium .
πΊ YouTube .
π© Telegram .
π΅οΈββοΈ My Site .
Visit our for e-books and courses. π
The Internet Message Access Protocol (IMAP) is a standard protocol for accessing and managing email on remote servers. Widely used in enterprise environments, it facilitates seamless email synchronization across devices. IMAP primarily operates over ports 143 (unencrypted) and 993 (encrypted). As a penetration tester, understanding IMAP's vulnerabilities is crucial, as improperly configured servers or weak authentication mechanisms can expose sensitive information or allow unauthorized access.
This guide provides an in-depth, technical approach to pentesting IMAP, covering reconnaissance, exploitation techniques, and practical tools for ethical hackers.
IMAP is designed to allow email clients to interact with email servers without downloading emails locally. Its primary features include:
Port 143: Used for unencrypted communication, exposing data to potential interception.
Port 993: Used for encrypted IMAP traffic via SSL/TLS, offering better security.
However, even encrypted IMAP traffic can be vulnerable to misconfigurations, weak authentication mechanisms, or software vulnerabilities.
Banner grabbing is the first step to gathering information about the IMAP server. It involves connecting to the server and extracting banners that reveal server software, version, and potential vulnerabilities.
Tools and Commands:
Netcat:
OpenSSL for encrypted connections:
Analysis:
The banner can reveal the IMAP server software (e.g., Dovecot, Cyrus), its version, and supported features like STARTTLS
or AUTH=PLAIN
, which can be leveraged during exploitation.
IMAP servers often support NTLM authentication, which can inadvertently leak sensitive information during communication. Attackers can exploit this to capture NTLM hashes and perform offline cracking.
Using Responder: Configure Responder to intercept NTLM authentication attempts:
Initiate an NTLM Challenge-Response: Exploit IMAPβs NTLM authentication mechanism to capture hashes.
Extract and Crack Hashes: Use John the Ripper or Hashcat to crack captured hashes.
Brute forcing is a common technique to test the strength of IMAP credentials.
Hydra:
Medusa:
Nmap NSE Script:
Understanding IMAPβs syntax allows you to interact with the server manually and probe for weaknesses.
LOGIN: Authenticate a user.
LIST: Retrieve available mailboxes.
SELECT: Access a specific mailbox.
SEARCH: Search emails based on criteria.
FETCH: Retrieve email content.
Using openssl s_client
to issue commands over an encrypted session:
Then input IMAP commands manually:
Listing mailboxes (imap command LIST "" "*"
)
Listing messages in a mailbox (imap command SELECT INBOX
and then SEARCH ALL
)
The result of this search is a list of message indicies.
Its also possible to provide more complex search terms. e.g. searching for drafts with password in mail body:
Downloading a message (imap command SELECT Drafts
and then FETCH 1 BODY[]
)
The mail index will be the same index returned from the search operation.
It is also possible to use UID
(unique id) to access messages, however it is less conveniant as the search command needs to be manually formatted. E.g.
Also, possible to download just parts of a message, e.g. subject and sender of first 5 messages (the -v
is required to see the subject and sender):
Although, its probably cleaner to just write a little for loop:
Shodan:
Search for exposed IMAP servers:
CVE-2019-3560: Dovecot NTLM authentication buffer overflow.
Exploitable via malformed NTLM packets.
CVE-2020-12675: Improper IMAP command handling in Cyrus IMAP.
Allows remote attackers to crash the server.
CVE-2022-23008: IMAP STARTTLS downgrade vulnerability.
Allows interception of plaintext credentials.
Legacy IMAP Servers:
Exploit STARTTLS Downgrade: Capture plaintext credentials:
Buffer Overflow in NTLM Authentication: Trigger using a crafted payload with Metasploit.
Basic navigation is possible with , but the documentation is light on details so checking the is recommended for precise details.
A nice overview of the search terms possible is located .
Learn & practice
Become VeryLazyTech ! π
β Twitter .
πΎ Github .
π Medium .
πΊ YouTube .
π© Telegram .
π΅οΈββοΈ My Site .
Visit our for e-books and courses. π