imapInternet Message Access Protocol IMAP4rev1Tagged Mailbox Commands (mail_app <-> srv imap TCP 143)
What It Does on the Wire
Every IMAP command wears a client correlation tag (A001 LOGIN, A002 SELECT INBOX) on TCP 143, making it easy to test cleartext credential alerts and legacy mail-protocol blocks.
Internet Message Access Protocol (imap, RFC 3501) lets email clients synchronize folders and messages on TCP port 143 (cleartext / STARTTLS) or 993 (IMAPS). Every IMAP client command starts with a short alphanumeric tag (such as A001, A002) so the server can match tagged completion replies (A001 OK LOGIN completed, A001 NO Authentication failed) alongside untagged * OK greetings.
FrameAssembly formats both tagged client commands (tag, cmd, arg) and server responses (status "OK" / "NO" / "BAD" + response) cleanly over TCP port 143.
Detect Legacy Cleartext IMAP Password Submissions (Port 143)
Test IDS and NDR rules that alert when mail clients send cleartext LOGIN commands over unencrypted TCP 143 instead of IMAPS 993.
Validate Password-Spraying & NO Failure SIEM Alerts
Generate repeated cmd "LOGIN" requests paired with status "NO" response "[AUTHENTICATIONFAILED]" replies to test SOC brute-force rules.
Mail Server Health Check & Load Balancer Probe Captures
Model CAPABILITY -> SELECT INBOX -> LOGOUT health probes across mail proxies.
Minimal Quickstart (imap_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host mail_app { ip 10.20.15.30 }host imap_srv { ip 10.20.15.143 }compile { mail_app -> imap_srv tcp syn srcport 51143 dstport 143 wait 1ms mail_app <- imap_srv tcp syn ack wait 1ms mail_app -> imap_srv tcp ack wait 1ms mail_app <- imap_srv imap tag "*" status "OK" response "Dovecot ready." wait 2ms mail_app -> imap_srv imap tag "A01" cmd "CAPABILITY" wait 2ms mail_app <- imap_srv imap tag "A01" status "OK" response "CAPABILITY completed"}What the Compiler Calculates So You Don't Have To
- Defaults to TCP destination port
143(psh ack) and appendsto every IMAP command or response line. - Formats
<tag> <cmd> <arg>on client requests and<tag> <status> <response>whenstatusorresponseis provided. - Keeps TCP sequence numbers synchronized across multi-command sessions.
Cleartext IMAP Login Failure Followed by Authorized Inbox Selection
Captures an untagged server greeting, a failed A01 LOGIN returning NO, and an authorized A02 LOGIN + A03 SELECT INBOX.
host laptop { ip 172.16.25.44 }host mail_box { ip 172.16.25.10 }compile { laptop -> mail_box tcp syn srcport 52143 dstport 143 win 65535 mss 1460 wait 1ms laptop <- mail_box tcp syn ack win 65535 mss 1460 wait 1ms laptop -> mail_box tcp ack wait 1ms laptop <- mail_box imap tag "*" status "OK" response "IMAP4rev1 Service Ready" wait 2ms // 1. Failed login -> tagged NO laptop -> mail_box imap tag "A01" cmd "LOGIN" arg "jdoe WrongPass1" wait 3ms laptop <- mail_box imap tag "A01" status "NO" response "LOGIN failed." wait 5ms // 2. Valid login + SELECT INBOX laptop -> mail_box imap tag "A02" cmd "LOGIN" arg "jdoe LabPass2026" wait 2ms laptop <- mail_box imap tag "A02" status "OK" response "LOGIN completed" wait 2ms laptop -> mail_box imap tag "A03" cmd "SELECT" arg "INBOX" wait 2ms laptop <- mail_box imap tag "A03" status "OK" response "[READ-WRITE] SELECT completed"}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show imap_login_audit.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly imap_login_audit.frasm imap_login_audit.pcap
frameassembly imap_login_audit.frasm imap_login_audit.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse imap_login_audit.pcap imap_login_audit_edited.frasmAll imap Keywords & Header Options
Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after imap:
src_host -> dst_host imap [tag "<text>"] [cmd "<text>"] [arg "<text>"] [status "<text>"] [response "<text>"]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| tag "<text>" | Quoted command tag ("A01", "a1", or "*" untagged) | "A001" (or "*" on untagged server greeting) | Writes the leading IMAP tag token. |
| cmd "<text>" [arg "<text>"] | IMAP command verb ("CAPABILITY", "LOGIN", "SELECT", "FETCH", "LOGOUT") + arguments | cmd "CAPABILITY" | Writes the client command and optional argument string. |
| status "<text>" [response "<text>"] | Quoted completion status ("OK", "NO", "BAD") + text | Omitted on client commands | Emits an IMAP server status response line. |
Cross-Layer Wrappers Valid with imap
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
11 options
Cross-Layer Wrappers Valid with imap
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums. |
| srcmac <mac> | dstmac <mac> | Colon, hyphen, or Cisco dot MAC | Host MAC / RFC multicast MAC | Overrides the 14-byte Ethernet II source or destination MAC address for this single packet. |
| vlan <0..4095> [pcp <0..7>] [dei <0|1>] | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | Untagged | Wraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority. |
| qinq <0..4095> [innervlan <0..4095>] | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | Untagged (innervlan 1 when qinq is set) | Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100). |
| mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (at most 1 mpls tag per packet) | Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header. |
| ttl <0..255> [dscp <0..63>] [ecn <0..3>] | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | ttl 64, dscp 0, ecn 0 | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| ipid <0..65535> [df] [mf] [fragoffset <0..8191>] | IPv4 ID, DF/MF flags, fragment offset 0..8191 | ipid 1, flags 0, fragoffset 0 | Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6). |
| flowlabel <0..1048575> | 20-bit IPv6 Flow Label (0..1048575) | 0 | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| srcport <0..65535> | dstport <0..65535> | Port number 0..65535 | srcport 49152 (remembered), TCP 143 | Overrides source or destination port and remembers the port pair automatically on <- replies. |
| seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rst | TCP sequence/ack numbers, window size, flags & RFC 7323 options | psh ack, win 65535, automatic TCP seq/acknum | Overrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr). |
Gotchas & Quick Fixes
IMAP status Takes a Quoted String ("OK", "NO", "BAD"), Not a Number
mail_app <- imap_srv imap tag "A01" status 200mail_app <- imap_srv imap tag "A01" status "OK" response "Done"Unlike HTTP (status 200), RFC 3501 IMAP uses text completion tokens ("OK", "NO", "BAD").