Protocol 63 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
imapInternet Message Access Protocol IMAP4rev1

Tagged Mailbox Commands (mail_app <-> srv imap TCP 143)

Default Port / Protocol
TCP 143
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
imap
Standards & Specs
RFC 3501, RFC 9051
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 143IMAP4

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.

imap_quickstart.frasm11 lines
Open in 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 appends to every IMAP command or response line.
  • Formats <tag> <cmd> <arg> on client requests and <tag> <status> <response> when status or response is provided.
  • Keeps TCP sequence numbers synchronized across multi-command sessions.
Multi-Frame Lab · Ready to Compile

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.

imap_login_audit.frasm17 lines
Open in Playground
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"
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 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.frasm

All 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 / OptionAccepted ValueDefaultEffect 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") + argumentscmd "CAPABILITY"Writes the client command and optional argument string.
status "<text>" [response "<text>"]Quoted completion status ("OK", "NO", "BAD") + textOmitted on client commandsEmits 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
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances 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)OmittedAppends 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 MACHost MAC / RFC multicast MACOverrides 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..1UntaggedWraps 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..4095Untagged (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..255Unlabeled (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..3ttl 64, dscp 0, ecn 0Sets 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..8191ipid 1, flags 0, fragoffset 0Sets 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)0Sets 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..65535srcport 49152 (remembered), TCP 143Overrides source or destination port and remembers the port pair automatically on <- replies.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumOverrides 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

Avoid
mail_app <- imap_srv imap tag "A01" status 200
Valid v3.1.2 Syntax
mail_app <- imap_srv imap tag "A01" status "OK" response "Done"

Unlike HTTP (status 200), RFC 3501 IMAP uses text completion tokens ("OK", "NO", "BAD").

Field Guide 03
Poke Stateful Firewalls, Suricata, Zeek & OT Conduits