Internet Message Access Protocol (IMAP) imeundwa kwa lengo la kuwapa watumiaji ufikiaji wa ujumbe wao wa barua pepe kutoka mahali popote, hasa kupitia muunganisho wa Intaneti. Kwa msingi, barua pepe zinahifadhiwa kwenye seva badala ya kupakuliwa na kuhifadhiwa kwenye kifaa binafsi cha mtu. Hii inamaanisha kwamba wakati barua pepe inafikiwa au kusomwa, inafanywa moja kwa moja kutoka kwenye seva. Uwezo huu unaruhusu urahisi wa kuangalia barua pepe kutoka kwa vifaa vingi, kuhakikisha kwamba hakuna ujumbe unakosa bila kujali kifaa kinachotumika.
Kwa kawaida, itifaki ya IMAP inafanya kazi kwenye port mbili:
Port 143 - hii ni port ya IMAP isiyo na usimbuaji
Port 993 - hii ni port unayohitaji kutumia ikiwa unataka kuungana kwa usalama kwa kutumia IMAP
PORT STATE SERVICE REASON
143/tcp open imap syn-ack
Kupata bendera
nc-nv<IP>143openssls_client-connect<IP>:993-quiet
NTLM Auth - Ufichuzi wa taarifa
Ikiwa seva inasaidia uthibitishaji wa NTLM (Windows) unaweza kupata taarifa nyeti (matoleo):
root@kali: telnet example.com 143
* OK The Microsoft Exchange IMAP4 service is ready.
>> a1 AUTHENTICATE NTLM
+
>> TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=
+ TlRMTVNTUAACAAAACgAKADgAAAAFgooCBqqVKFrKPCMAAAAAAAAAAEgASABCAAAABgOAJQAAAA9JAEkAUwAwADEAAgAKAEkASQBTADAAMQABAAoASQBJAFMAMAAxAAQACgBJAEkAUwAwADEAAwAKAEkASQBTADAAMQAHAAgAHwMI0VPy1QEAAAAA
Au automate hii kwa kutumia nmap plugin imap-ntlm-info.nse
Login
A1 LOGIN username password
Values can be quoted to enclose spaces and special characters. A " must then be escape with a \
A1 LOGIN "username" "password"
List Folders/Mailboxes
A1 LIST "" *
A1 LIST INBOX *
A1 LIST "Archive" *
Create new Folder/Mailbox
A1 CREATE INBOX.Archive.2012
A1 CREATE "To Read"
Delete Folder/Mailbox
A1 DELETE INBOX.Archive.2012
A1 DELETE "To Read"
Rename Folder/Mailbox
A1 RENAME "INBOX.One" "INBOX.Two"
List Subscribed Mailboxes
A1 LSUB "" *
Status of Mailbox (There are more flags than the ones listed)
A1 STATUS INBOX (MESSAGES UNSEEN RECENT)
Select a mailbox
A1 SELECT INBOX
List messages
A1 FETCH 1:* (FLAGS)
A1 UID FETCH 1:* (FLAGS)
Retrieve Message Content
A1 FETCH 2 body[text]
A1 FETCH 2 all
A1 UID FETCH 102 (UID RFC822.SIZE BODY.PEEK[])
Close Mailbox
A1 CLOSE
Logout
A1 LOGOUT
Mageuzi
apt install evolution
CURL
Mara nyingi unaweza kuvinjari kwa kutumia CURL, lakini nyaraka zina maelezo machache hivyo inashauriwa kuangalia chanzo kwa maelezo sahihi.
Kuorodhesha masanduku ya barua (imap command LIST "" "*")
curl-k'imaps://1.2.3.4/'--useruser:pass
Kuorodhesha ujumbe katika sanduku la barua (imap amri SELECT INBOX na kisha SEARCH ALL)
curl-k'imaps://1.2.3.4/INBOX?ALL'--useruser:pass
Matokeo ya utafutaji huu ni orodha ya viashiria vya ujumbe.
Pia inawezekana kutoa masharti ya utafutaji magumu zaidi. mfano, kutafuta rasimu zenye nenosiri katika mwili wa barua:
The mail index will be the same index returned from the search operation.
Inapatikana pia kutumia UID (kitambulisho cha kipekee) kufikia ujumbe, hata hivyo ni vigumu kidogo kwani amri ya kutafuta inahitaji kuandikwa kwa mikono. E.g.
Ingawa, labda ni safi zaidi kuandika kidogo tu kwa ajili ya mzunguko:
for m in {1..5}; doecho $mcurl"imap://1.2.3.4/INBOX;MAILINDEX=$m;SECTION=HEADER.FIELDS%20(SUBJECT%20FROM)"--useruser:passdone
Shodan
port:143 CAPABILITY
port:993 CAPABILITY
HackTricks Amri za Otomatiki
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
Entry_1:
Name: Notes
Description: Notes for WHOIS
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.
https://book.hacktricks.xyz/pentesting/pentesting-imap
Entry_2:
Name: Banner Grab
Description: Banner Grab 143
Command: nc -nv {IP} 143
Entry_3:
Name: Secure Banner Grab
Description: Banner Grab 993
Command: openssl s_client -connect {IP}:993 -quiet
Entry_4:
Name: consolesless mfs enumeration
Description: IMAP enumeration without the need to run msfconsole
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'