# pop3 — TCP 110 +OK / -ERR Logins & Password-Spray Traces (`pop3`)

> **FrameAssembly v3.2.2** · Protocol 64 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/pop3

- **Full Protocol Name:** Post Office Protocol Version 3
- **Keyword:** `pop3`
- **OSI Layer & Transport:** Layer 7 · TCP 110
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 1939
- **Wireshark Display Filter:** `pop`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> TCP 110 -> POP3`

## Overview

Thirty lines of `-ERR Authentication failed` on TCP `110`? Classic password-spray territory — `pop3` pairs `cmd "USER"` and `cmd "PASS"` with `ok` (`+OK`) and `err` (`-ERR`) responses.

Post Office Protocol v3 (`pop3`, RFC 1939) downloads messages from legacy mail servers over **TCP port `110`**. POP3 uses a concise line protocol: clients send 4-letter commands (`USER`, `PASS`, `STAT`, `LIST`, `RETR`, `QUIT`) and servers reply with either `+OK <response>` (`ok`) or `-ERR <response>` (`err`).

Because legacy POP3 exposes usernames and passwords in plain text on port `110`, security teams use `pop3` `.pcap` fixtures to test cleartext-credential alerts and legacy protocol deprecation rules.

## Minimal Quickstart (`pop3_quickstart.frasm`)

```frameassembly
host client   { ip 10.20.16.25 }
host pop3_srv { ip 10.20.16.110 }

compile {
    client -> pop3_srv tcp syn srcport 51110 dstport 110 wait 1ms
    client <- pop3_srv tcp syn ack wait 1ms
    client -> pop3_srv tcp ack wait 1ms
    client <- pop3_srv pop3 ok response "POP3 server ready" wait 2ms
    client -> pop3_srv pop3 cmd "STAT" wait 2ms
    client <- pop3_srv pop3 ok response "2 320"
}
```

### Automatic Wire Calculations

- Defaults to TCP destination port `110` (`psh ack`) and appends `
` per RFC 1939.
- Formats `+OK <response>
` on `ok` and `-ERR <response>
` on `err`.
- Tracks TCP sequence and acknowledgment numbers automatically across client/server turns.

## Practical Lab Example: POP3 Failed Login (`-ERR`) + Successful Mailbox `STAT` & `QUIT` (`pop3_session_audit.frasm`)

Establishes a TCP 110 session, captures a rejected password attempt (`err`), then completes `USER` -> `PASS` -> `STAT` -> `QUIT`.

```frameassembly
host workstation { ip 172.16.16.40 }
host legacy_mail { ip 172.16.16.110 }

compile {
    workstation -> legacy_mail tcp syn srcport 52110 dstport 110 win 65535 mss 1460 wait 1ms
    workstation <- legacy_mail tcp syn ack win 65535 mss 1460 wait 1ms
    workstation -> legacy_mail tcp ack wait 1ms
    workstation <- legacy_mail pop3 ok response "Dovecot POP3 ready." wait 2ms
    workstation -> legacy_mail pop3 cmd "USER" arg "ops_scanner" wait 1ms
    workstation <- legacy_mail pop3 ok response "Pass required" wait 1ms
    workstation -> legacy_mail pop3 cmd "PASS" arg "BadPass1" wait 4ms
    workstation <- legacy_mail pop3 err response "[AUTH] Authentication failed." wait 5ms
    workstation -> legacy_mail pop3 cmd "USER" arg "ops_scanner" wait 1ms
    workstation <- legacy_mail pop3 ok wait 1ms
    workstation -> legacy_mail pop3 cmd "PASS" arg "LabPass99" wait 2ms
    workstation <- legacy_mail pop3 ok response "Logged in." wait 1ms
    workstation -> legacy_mail pop3 cmd "STAT" wait 1ms
    workstation <- legacy_mail pop3 ok response "3 4096" wait 1ms
    workstation -> legacy_mail pop3 cmd "QUIT" wait 1ms
    workstation <- legacy_mail pop3 ok response "Logging out."
}
```

```bash
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show pop3_session_audit.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly pop3_session_audit.frasm pop3_session_audit.pcap
frameassembly pop3_session_audit.frasm pop3_session_audit.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse pop3_session_audit.pcap pop3_session_audit_edited.frasm

# 4. Verify dissected protocol fields in tshark
tshark -r pop3_session_audit.pcap
```

## All `pop3` Keywords & Header Options

Packet line pattern: `src_host -> dst_host pop3 [cmd "<text>"] [arg "<text>"] [ok | err] [response "<text>"]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `cmd "<text>" [arg "<text>"]` | POP3 client command (`"USER"`, `"PASS"`, `"STAT"`, `"LIST"`, `"RETR"`, `"QUIT"`) + argument | `cmd "STAT"` | Writes `<cmd> <arg>\r\n` from the client. |
| `ok \| err` | POP3 server status indicator | `Omitted on client commands` | Emits `+OK` (`ok`) or `-ERR` (`err`) at the start of a server reply. |
| `response "<text>"` | Quoted server status text | `Empty` | Appends human-readable status details after `+OK` or `-ERR`. |

## Cross-Layer Options Valid with `pop3`

| Option | Range / Format | Default | Effect |
| --- | --- | --- | --- |
| `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> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType 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> [label <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 110` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `seq <number> \| acknum <number> \| win\|window <0..65535> \| urgent <0..65535> \| syn \| ack \| psh \| fin \| rst \| urg \| ece \| cwr` | 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`). |

## Common Mistakes & Quick Fixes

### Do Not Include + or - in ok / err Keywords

- **Avoid:** `client <- pop3_srv pop3 +ok response "Ready"`
- **Valid v3.2.2 Syntax:** `client <- pop3_srv pop3 ok response "Ready"`

Write `ok` or `err` without `+` or `-`; FrameAssembly writes `+OK` and `-ERR` on the wire automatically.
