**인터넷 메시지 액세스 프로토콜 (IMAP)**은 사용자가 어디서나 이메일 메시지에 액세스할 수 있도록 설계되었습니다. 주로 인터넷 연결을 통해 이루어집니다. 본질적으로, 이메일은 서버에 보관되어 개인 장치에 다운로드되거나 저장되지 않습니다. 이는 이메일이 액세스되거나 읽힐 때 서버에서 직접 이루어진다는 것을 의미합니다. 이 기능을 통해 여러 장치에서 이메일을 확인할 수 있어 어떤 장치를 사용하더라도 메시지를 놓치지 않을 수 있습니다.
기본적으로 IMAP 프로토콜은 두 개의 포트에서 작동합니다:
포트 143 - 이것은 기본 IMAP 비암호화 포트입니다.
포트 993 - 이것은 IMAP을 안전하게 사용하려면 연결해야 하는 포트입니다.
PORT STATE SERVICE REASON
143/tcp open imap syn-ack
배너 그랩핑
nc-nv<IP>143openssls_client-connect<IP>:993-quiet
NTLM 인증 - 정보 누출
서버가 NTLM 인증(Windows)을 지원하는 경우 민감한 정보(버전)를 얻을 수 있습니다:
root@kali: telnet example.com 143
* OK The Microsoft Exchange IMAP4 service is ready.
>> a1 AUTHENTICATE NTLM
+
>> TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=
+ TlRMTVNTUAACAAAACgAKADgAAAAFgooCBqqVKFrKPCMAAAAAAAAAAEgASABCAAAABgOAJQAAAA9JAEkAUwAwADEAAgAKAEkASQBTADAAMQABAAoASQBJAFMAMAAxAAQACgBJAEkAUwAwADEAAwAKAEkASQBTADAAMQAHAAgAHwMI0VPy1QEAAAAA
또는 nmap 플러그인 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
진화
apt install evolution
CURL
CURL을 사용하면 기본적인 탐색이 가능하지만 문서는 자세한 내용을 다루지 않으므로 정확한 세부 정보를 확인하려면 소스를 확인하는 것이 좋습니다.
메일함 나열 (imap 명령어 LIST "" "*")
curl-k'imaps://1.2.3.4/'--useruser:pass
메일함에서 메시지 목록 나열하기 (imap 명령 SELECT INBOX 그리고 그 다음 SEARCH ALL)
curl-k'imaps://1.2.3.4/INBOX?ALL'--useruser:pass
다음 검색 결과는 메시지 인덱스 목록입니다.
더 복잡한 검색어를 제공하는 것도 가능합니다. 예를 들어, 메일 본문에서 비밀번호가 포함된 드래프트를 검색할 수 있습니다:
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'