hacktricks/network-services-pentesting/pentesting-imap.md

208 lines
8.7 KiB
Markdown
Raw Normal View History

2022-05-01 13:25:53 +00:00
# 143,993 - Pentesting IMAP
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Jifunze kuhack AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
* Ikiwa unataka kuona **kampuni yako ikitangazwa kwenye HackTricks** au **kupakua HackTricks kwa PDF** Angalia [**MIPANGO YA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**Familia ya PEASS**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa [**NFTs**](https://opensea.io/collection/the-peass-family) ya kipekee
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au kikundi cha [**telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **Shiriki mbinu zako za kuhack kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
**Kikundi cha Usalama cha Kujitahidi**
<figure><img src="../.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt=""><figcaption></figcaption></figure>
{% embed url="https://discord.gg/tryhardsecurity" %}
***
2023-09-02 23:48:41 +00:00
## Itifaki ya Kufikia Ujumbe wa Mtandao
**Itifaki ya Kufikia Ujumbe wa Mtandao (IMAP)** imeundwa kwa lengo la kuruhusu watumiaji **kufikia ujumbe wao wa barua pepe kutoka mahali popote**, hasa kupitia muunganisho wa Mtandao. Kimsingi, barua pepe zinabaki kwenye **server** badala ya kupakuliwa na kuhifadhiwa kwenye kifaa cha mtu binafsi. Hii inamaanisha kwamba wakati barua pepe inapofikiwa au kusomwa, inafanywa **moja kwa moja kutoka kwenye server**. Uwezo huu unaruhusu urahisi wa kuangalia barua pepe kutoka kwa **vifaa vingi**, kuhakikisha kwamba hakuna ujumbe unaopotea bila kujali kifaa kinachotumiwa.
2023-09-02 23:48:41 +00:00
Kwa chaguo-msingi, itifaki ya IMAP hufanya kazi kwenye bandari mbili:
2023-09-02 23:48:41 +00:00
* **Bandari 143** - hii ni bandari isiyojumuishwa ya IMAP ya chaguo-msingi
* **Bandari 993** - hii ndio bandari unayohitaji kutumia ikiwa unataka kuunganisha kwa kutumia IMAP kwa usalama
```
PORT STATE SERVICE REASON
143/tcp open imap syn-ack
```
## Kunasa bendera
```bash
nc -nv <IP> 143
openssl s_client -connect <IP>:993 -quiet
```
2024-02-11 02:13:58 +00:00
### NTLM Auth - Kufichua Taarifa
Ikiwa server inaunga mkono NTLM auth (Windows) unaweza kupata taarifa nyeti (toleo):
```
2024-02-11 02:13:58 +00:00
root@kali: telnet example.com 143
* OK The Microsoft Exchange IMAP4 service is ready.
>> a1 AUTHENTICATE NTLM
+
>> TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=
+ TlRMTVNTUAACAAAACgAKADgAAAAFgooCBqqVKFrKPCMAAAAAAAAAAEgASABCAAAABgOAJQAAAA9JAEkAUwAwADEAAgAKAEkASQBTADAAMQABAAoASQBJAFMAMAAxAAQACgBJAEkAUwAwADEAAwAKAEkASQBTADAAMQAHAAgAHwMI0VPy1QEAAAAA
```
Au **automatize** hii na **nmap** programu-jalizi `imap-ntlm-info.nse`
### [IMAP Kuvunja Nenosiri](../generic-methodologies-and-resources/brute-force.md#imap)
## Muundo
Mifano ya Amri za IMAP kutoka [hapa](https://donsutherland.org/crib/imap):
```
Login
2024-02-11 02:13:58 +00:00
A1 LOGIN username password
Values can be quoted to enclose spaces and special characters. A " must then be escape with a \
2024-02-11 02:13:58 +00:00
A1 LOGIN "username" "password"
List Folders/Mailboxes
2024-02-11 02:13:58 +00:00
A1 LIST "" *
A1 LIST INBOX *
A1 LIST "Archive" *
Create new Folder/Mailbox
2024-02-11 02:13:58 +00:00
A1 CREATE INBOX.Archive.2012
A1 CREATE "To Read"
Delete Folder/Mailbox
2024-02-11 02:13:58 +00:00
A1 DELETE INBOX.Archive.2012
A1 DELETE "To Read"
Rename Folder/Mailbox
2024-02-11 02:13:58 +00:00
A1 RENAME "INBOX.One" "INBOX.Two"
List Subscribed Mailboxes
2024-02-11 02:13:58 +00:00
A1 LSUB "" *
Status of Mailbox (There are more flags than the ones listed)
2024-02-11 02:13:58 +00:00
A1 STATUS INBOX (MESSAGES UNSEEN RECENT)
Select a mailbox
2024-02-11 02:13:58 +00:00
A1 SELECT INBOX
List messages
2024-02-11 02:13:58 +00:00
A1 FETCH 1:* (FLAGS)
A1 UID FETCH 1:* (FLAGS)
Retrieve Message Content
2024-02-11 02:13:58 +00:00
A1 FETCH 2 body[text]
A1 FETCH 2 all
A1 UID FETCH 102 (UID RFC822.SIZE BODY.PEEK[])
Close Mailbox
2024-02-11 02:13:58 +00:00
A1 CLOSE
Logout
2024-02-11 02:13:58 +00:00
A1 LOGOUT
```
2024-02-11 02:13:58 +00:00
### Mabadiliko
```
apt install evolution
```
![](<../.gitbook/assets/image (528).png>)
2022-05-01 13:25:53 +00:00
### CURL
2020-12-21 13:41:29 +00:00
Urambazaji wa msingi unawezekana na [CURL](https://ec.haxx.se/usingcurl/usingcurl-reademail#imap), lakini nyaraka zina maelezo machache hivyo ni vyema kuangalia [chanzo](https://github.com/curl/curl/blob/master/lib/imap.c) kwa maelezo sahihi.
1. Orodha ya sanduku la barua (amri ya imap `LIST "" "*")
2024-02-08 21:36:15 +00:00
```bash
curl -k 'imaps://1.2.3.4/' --user user:pass
```
2. Kupanga ujumbe kwenye sanduku la barua (amri ya imap `SELECT INBOX` na kisha `SEARCH ALL`)
2024-02-11 02:13:58 +00:00
```bash
2024-02-08 21:36:15 +00:00
curl -k 'imaps://1.2.3.4/INBOX?ALL' --user user:pass
```
Matokeo ya utafutaji huu ni orodha ya viashiria vya ujumbe.
Pia niwezekano wa kutoa vigezo vya utafutaji vya kina zaidi. mfano kutafuta rasimu zenye nenosiri kwenye mwili wa barua:
2024-02-08 21:36:15 +00:00
```bash
curl -k 'imaps://1.2.3.4/Drafts?TEXT password' --user user:pass
```
Aina nzuri ya maelezo ya maneno ya kutafuta inapatikana [hapa](https://www.atmail.com/blog/imap-commands/).
3. Kupakua ujumbe (amri ya imap `SELECT Drafts` kisha `FETCH 1 BODY[]`)
2024-02-08 21:36:15 +00:00
```bash
curl -k 'imaps://1.2.3.4/Drafts;MAILINDEX=1' --user user:pass
```
Mail index itakuwa index ile ile itakayorudishwa kutoka kwa operesheni ya utafutaji.
Pia niwezekano kutumia `UID` (kitambulisho cha kipekee) kufikia ujumbe, hata hivyo ni chaguo lisilo la urahisi kwa sababu amri ya utafutaji inahitaji kuandaliwa kwa mkono. K.m.
```bash
2024-02-08 21:36:15 +00:00
curl -k 'imaps://1.2.3.4/INBOX' -X 'UID SEARCH ALL' --user user:pass
curl -k 'imaps://1.2.3.4/INBOX;UID=1' --user user:pass
2020-12-21 13:41:29 +00:00
```
Pia, inawezekana kupakua sehemu tu ya ujumbe, kwa mfano mada na mtumaji wa ujumbe wa kwanza 5 ( `-v` inahitajika kuona mada na mtumaji):
```bash
2020-12-21 13:41:29 +00:00
$ curl -k 'imaps://1.2.3.4/INBOX' -X 'FETCH 1:5 BODY[HEADER.FIELDS (SUBJECT FROM)]' --user user:pass -v 2>&1 | grep '^<'
```
Ingawa, ni safi zaidi kuandika kitanzi kidogo:
2024-02-08 21:36:15 +00:00
```bash
2020-12-21 13:41:29 +00:00
for m in {1..5}; do
2024-02-11 02:13:58 +00:00
echo $m
curl "imap://1.2.3.4/INBOX;MAILINDEX=$m;SECTION=HEADER.FIELDS%20(SUBJECT%20FROM)" --user user:pass
2020-12-21 13:41:29 +00:00
done
```
2022-05-01 13:25:53 +00:00
## Shodan
2020-10-05 13:04:03 +00:00
* `port:143 UWEZO`
* `port:993 UWEZO`
2021-08-12 13:02:06 +00:00
**Kikundi cha Usalama cha Kujaribu Kwa Bidii**
<figure><img src="../.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt=""><figcaption></figcaption></figure>
{% embed url="https://discord.gg/tryhardsecurity" %}
## Amri za Kiotomatiki za HackTricks
```
2021-08-12 13:02:06 +00:00
Protocol_Name: IMAP #Protocol Abbreviation if there is one.
Port_Number: 143,993 #Comma separated if there is more than one.
Protocol_Description: Internet Message Access Protocol #Protocol Abbreviation Spelled out
2021-08-15 17:49:05 +00:00
Entry_1:
Name: Notes
Description: Notes for WHOIS
2024-02-11 02:13:58 +00:00
Note: |
The Internet Message Access Protocol (IMAP) is designed for the purpose of enabling users to access their email messages from any location, primarily through an Internet connection. In essence, emails are retained on a server rather than being downloaded and stored on an individual's personal device. This means that when an email is accessed or read, it is done directly from the server. This capability allows for the convenience of checking emails from multiple devices, ensuring that no messages are missed regardless of the device used.
2021-08-15 17:49:05 +00:00
2024-02-11 02:13:58 +00:00
https://book.hacktricks.xyz/pentesting/pentesting-imap
2021-08-15 17:49:05 +00:00
Entry_2:
Name: Banner Grab
Description: Banner Grab 143
2024-02-11 02:13:58 +00:00
Command: nc -nv {IP} 143
2021-08-15 17:49:05 +00:00
Entry_3:
Name: Secure Banner Grab
Description: Banner Grab 993
2024-02-11 02:13:58 +00:00
Command: openssl s_client -connect {IP}:993 -quiet
Entry_4:
Name: consolesless mfs enumeration
Description: IMAP enumeration without the need to run msfconsole
2024-02-11 02:13:58 +00:00
Note: sourced from https://github.com/carlospolop/legion
Command: msfconsole -q -x 'use auxiliary/scanner/imap/imap_version; set RHOSTS {IP}; set RPORT 143; run; exit'
2021-08-12 13:02:06 +00:00
```
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Jifunze kuhusu kuvamia AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
* Ikiwa unataka kuona **kampuni yako ikitangazwa kwenye HackTricks** au **kupakua HackTricks kwa PDF** Angalia [**MIPANGO YA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**bidhaa rasmi za PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**Familia ya PEASS**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa kipekee wa [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au kikundi cha [**telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **Shiriki mbinu zako za kuvamia kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>