> For the complete documentation index, see [llms.txt](https://venator17.gitbook.io/bibliotheque/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://venator17.gitbook.io/bibliotheque/pentesting/protocols/imap-pop3.md).

# IMAP / POP3

## <mark style="color:yellow;">ABOUT</mark>

<mark style="color:red;">**IMAP (Internet Message Access Protocol)**</mark> and <mark style="color:red;">**POP3 (Post Office Protocol version 3)**</mark> are two <mark style="color:purple;">**email retrieval protocols**</mark> that allow users to **access their emails from a mail server.**

## <mark style="color:yellow;">IMAP VS POP3</mark>

#### <mark style="color:purple;">IMAP:</mark>

* <mark style="color:yellow;">**Two-way sync:**</mark> Messages are stored on the mail server, and changes (read/unread, deleted, folders) are synced across devices.
* <mark style="color:yellow;">**Multiple device access:**</mark> Emails remain on the server, allowing access from multiple devices (e.g., phone, desktop).
* <mark style="color:yellow;">**More resource-heavy:**</mark> Requires more storage and bandwidth since messages remain on the server.

#### <mark style="color:purple;">POP3:</mark>

* <mark style="color:yellow;">**One-way download:**</mark> Emails are downloaded from the server to a single device and typically deleted from the server.
* <mark style="color:yellow;">**Limited device access:**</mark> Emails are only stored on the device they were downloaded to, not synced across devices.
* <mark style="color:yellow;">**Lighter on resources:**</mark> Efficient for local storage but lacks the flexibility of syncing changes across devices.

**Summary:**

* <mark style="color:red;">**IMAP**</mark> is ideal for <mark style="color:yellow;">**multi-device email access**</mark> with real-time synchronization.
* <mark style="color:red;">**POP3**</mark> is better for <mark style="color:yellow;">**single-device**</mark> use with local storage.

## <mark style="color:yellow;">IMAP Commands</mark>

| Command                                                             | Description                                                       |
| ------------------------------------------------------------------- | ----------------------------------------------------------------- |
| <mark style="color:green;">**`LOGIN username password`**</mark>     | User's login                                                      |
| <mark style="color:green;">**`LIST "" *`**</mark>                   | Lists all directories                                             |
| <mark style="color:green;">**`CREATE "INBOX"`**</mark>              | Creates a mailbox with a specified name                           |
| <mark style="color:green;">**`DELETE "INBOX"`**</mark>              | Deletes a mailbox                                                 |
| <mark style="color:green;">**`RENAME "ToRead" "Important"`**</mark> | Renames a mailbox                                                 |
| <mark style="color:green;">**`SELECT INBOX`**</mark>                | Selects a mailbox so that messages in the mailbox can be accessed |
| <mark style="color:green;">**`UNSELECT INBOX`**</mark>              | Exits the selected mailbox                                        |
| <mark style="color:green;">**`FETCH <ID> all`**</mark>              | Retrieves data associated with a message in the mailbox           |
| <mark style="color:green;">**`CLOSE`**</mark>                       | Removes all messages with the Deleted flag set                    |
| <mark style="color:green;">**`LOGOUT`**</mark>                      | Closes the connection with the IMAP server                        |

## <mark style="color:yellow;">POP3 Commands</mark>

| Command                                               | Description                                                |
| ----------------------------------------------------- | ---------------------------------------------------------- |
| <mark style="color:green;">**`USER username`**</mark> | Identifies the user                                        |
| <mark style="color:green;">**`PASS password`**</mark> | Authentication of the user using its password              |
| <mark style="color:green;">**`STAT`**</mark>          | Requests the number of saved emails from the server        |
| <mark style="color:green;">**`LIST`**</mark>          | Requests from the server the number and size of all emails |
| <mark style="color:green;">**`RETR id`**</mark>       | Requests the server to deliver the requested email by ID   |
| <mark style="color:green;">**`DELE id`**</mark>       | Requests the server to delete the requested email by ID    |
| <mark style="color:green;">**`CAPA`**</mark>          | Requests the server to display the server capabilities     |
| <mark style="color:green;">**`RSET`**</mark>          | Requests the server to reset the transmitted information   |
| <mark style="color:green;">**`QUIT`**</mark>          | Closes the connection with the POP3 server                 |

## <mark style="color:yellow;">Dangerous Settings</mark>

* <mark style="color:green;">**`auth_debug`**</mark> - Enables all authentication debug logging.
* <mark style="color:green;">**`auth_debug_passwords`**</mark> - This setting adjusts log verbosity, the submitted passwords, and the scheme gets logged.
* <mark style="color:green;">**`auth_verbose`**</mark> - Logs unsuccessful authentication attempts and their reasons.
* <mark style="color:green;">**`auth_verbose_passwords`**</mark> - Passwords used for authentication are logged and can also be truncated.
* <mark style="color:green;">**`auth_anonymous_username`**</mark> - This specifies the username to be used when logging in with the ANONYMOUS SASL mechanism.

## <mark style="color:yellow;">Tips2Hack</mark>

1. By default, ports <mark style="color:yellow;">**110**</mark>, <mark style="color:yellow;">**143**</mark>, <mark style="color:yellow;">**993**</mark>, and <mark style="color:yellow;">**995**</mark> are used for **IMAP** and **POP3**
2. <mark style="color:green;">**Nmap**</mark>**&#x20;-** basic footprinting

```bash
sudo nmap 13.13.13.13 -sV -p110,143,993,995 -sC
```

3. <mark style="color:green;">**IMAP**</mark> - Curl List mailboxes

```bash
curl -k 'imaps://13.13.13.13' --user user:p4ssw0rd
```

4. <mark style="color:green;">**OpenSSL**</mark> - TLS Encypted Interaction POP3

```bash
openssl s_client -connect 13.13.13.13:pop3s
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://venator17.gitbook.io/bibliotheque/pentesting/protocols/imap-pop3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
