Hacking Notes
  • What is this?
  • Reconnaissance 🗣
    • Information Gathering 🗣
  • Enumeration 🎯
    • Host Discovery 🛎
    • DNS Enumeration
    • OS Discovery 🖥
    • Port Scanning 📟
    • WAF Evasion
  • Web 📱
    • Unrestricted File Upload
    • Templates Injections ✖️
    • File Inclusion
    • Login Panes
    • SQL Injection
    • NoSQL Injection
    • OAuth 2.0 Bypass
  • Privilege Escalation
    • Linux Privesc
    • Windows Privesc
    • Run Commands AS
  • Post Explotation 💀
    • Port Forwarding and Tunneling
    • Transfering Files 📤
    • Reverse Shell 🔙
    • Crypto 101 👁
    • AV Evasion
    • Bypass UAC
    • Get Credentials
  • Services
    • PORT 21/tcp - FTP
    • PORT 25/tcp - SMTP
    • PORT 53/tcp/udp - DNS
    • Port 80,443/tcp - HTTP
    • Port 111/tcp - RPCBind
    • PORT 143,993/tcp - IMAP
    • PORT 139,445/tcp - SMB
    • PORT 161/udp - SNMP
    • PORT 1100/tcp - Java RMI
    • PORT 1433/tcp - Microsoft SQL Server
    • PORT 2049/tcp - NFS
    • PORT 3306/tcp MySQL
    • PORT 3389/tcp RDP
    • PyPI Server
  • Software
    • Tomcat
    • Jenkins
    • Drupal
    • Wordpress
  • Client-Side Attacks
    • Evil PDF
    • Microsoft Office Macros
  • Other
    • Hacking WiFI
      • WPA/WPA2 PSK
      • WPA/WPA2 PEAP (Enterprise)
      • WEP
    • Hacking with Powershell
    • Hacking AWS
  • Exploiting
    • Buffer Overflow
  • Active Directory
    • 🖥️AD Attacks
Powered by GitBook
On this page
  1. Services

PORT 143,993/tcp - IMAP

PreviousPort 111/tcp - RPCBindNextPORT 139,445/tcp - SMB

Last updated 3 years ago

Was this helpful?

CtrlK
  • Internet Message Access Protocol (IMAP)
  • Connection to IMAP server
  • Login
  • List Mailboxes
  • Select a Mailbox
  • Mailbox status
  • Fetch headers of all messages
  • Fetch message body
  • Logout
  • References:

Was this helpful?

Internet Message Access Protocol (IMAP)

In computing, the Internet Message Access Protocol (IMAP) is an Internet standard protocol used by email clients to retrieve email messages from a mail server over a TCP/IP connection. IMAP is defined by RFC 3501.

By default, the IMAP protocol works on two ports:

  • Port 143 - this is the default IMAP non-encrypted port

  • Port 993 - this is the port you need to use if you want to connect using IMAP securely

Connection to IMAP server

We can established our connection to both ports, non-encrypted or encypted.

# Non-encrypted connection
telnet imap.server.local 143

# Encrypted connection
openssl s_client -crlf -connect imap.server.local:993

Login

To take a look to victims mailboxes, we obviously need their creds.

A1 LOGIN user@server.local password
tag LOGIN user@server.local password

Note: Sometimes the user does not contains the domain.

List Mailboxes

To list mailboxes run the following command.

A1 LIST "" *
tag LIST "" * 

Select a Mailbox

After getting the existant mailboxes we need to choose one.

A1 SELECT "[INBOX]"
tag SELECT "[INBOX]"

Mailbox status

With status command, we can see the total of non-read messages, sent messages and more over.

A1 STATUS "[INBOX]" (MESSAGES)
tag STATUS "[INBOX]" (MESSAGES)

Fetch headers of all messages

Fetch command gives us the ability to read the messages.

A1 FETCH 1:* (BODY[HEADER])
tag FETCH 1:* (BODY[HEADER])

Fetch message body

To see the body of the message we need to set up the flag BODY as argument.

#Non-multipart messages
A1 FETCH [Message] (BODY)
tag FETCH [Message] (BODY)

#Multipart messages (Normaly plain text -> n=1)
A1 FETCH [Message] (BODY[n])
tag FETCH [Message] (BODY[n])

Logout

Finally, when we finish out job we need to logout to close the connection.

A1 LOGOUT
tag LOGOUT

References:

  • https://tewarid.github.io/2011/05/10/access-imap-server-from-the-command-line-using-openssl.html

  • https://book.hacktricks.xyz/pentesting/pentesting-imap