# whois — Port 43 Domain & ASN Registry Query Sessions (`whois`)

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

- **Full Protocol Name:** WHOIS Domain & IP Directory Query Protocol
- **Keyword:** `whois`
- **OSI Layer & Transport:** Layer 7 · TCP 43
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 3912
- **Wireshark Display Filter:** `whois`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> TCP 43 -> WHOIS`

## Overview

One of the simplest protocols in IETF history (`domain\r\n` out -> multi-line registry text back over TCP `43`), handy for testing threat-enrichment egress rules.

WHOIS (`whois`, RFC 3912) queries domain registrars and Regional Internet Registries (ARIN, RIPE, APNIC) over **TCP port `43`**. A client opens a TCP connection, sends a `
`-terminated domain or prefix query (`query`), and the server returns structured `Domain Name:` / `Registrar:` text lines (`response`) before closing the connection.

FrameAssembly supports both `whois query` and `whois response` frames while cleanly distinguishing standalone `whois` (TCP `43`) from `bacnet whois` (ASHRAE 135 building-automation discovery on UDP `47808`).

## Minimal Quickstart (`whois_quickstart.frasm`)

```frameassembly
host soar_runner { ip 10.30.10.15 }
host whois_srv   { ip 199.7.51.74 }

compile {
    soar_runner -> whois_srv tcp syn srcport 53043 dstport 43 wait 1ms
    soar_runner <- whois_srv tcp syn ack wait 1ms
    soar_runner -> whois_srv tcp ack wait 1ms
    soar_runner -> whois_srv whois query domain "example.org" wait 3ms
    soar_runner <- whois_srv whois response domain "example.org" registrar "RESERVED-Internet Assigned Numbers Authority"
}
```

### Automatic Wire Calculations

- Defaults to TCP destination port `43` (`psh ack`) and appends `
` to `domain` on `query` frames.
- Formats standard multi-line `Domain Name: <domain>
Registrar: <registrar>
` directory output on `response` frames.
- Tracks TCP sequence and acknowledgment numbers automatically across the query/response exchange.

## Practical Lab Example: Full TCP 43 WHOIS Lookup & Clean FIN Teardown (`whois_soc_enrichment.frasm`)

Opens TCP port 43 from a SOC automation host, queries `suspicious-login.example`, receives registrar metadata, and closes the TCP session cleanly per RFC 3912.

```frameassembly
host soc_bot  { ip 172.16.80.12 }
host rir_node { ip 198.51.100.43 }

compile {
    soc_bot -> rir_node tcp syn srcport 54043 dstport 43 win 65535 mss 1460 wait 1ms
    soc_bot <- rir_node tcp syn ack win 65535 mss 1460 wait 1ms
    soc_bot -> rir_node tcp ack wait 1ms
    soc_bot -> rir_node whois query domain "suspicious-login.example" wait 4ms
    soc_bot <- rir_node whois response domain "suspicious-login.example" registrar "Example Registrar LLC" wait 1ms
    soc_bot <- rir_node tcp fin ack wait 1ms
    soc_bot -> rir_node tcp fin ack wait 1ms
    soc_bot <- rir_node tcp ack
}
```

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

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

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

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

## All `whois` Keywords & Header Options

Packet line pattern: `src_host -> dst_host whois [query | response] [domain "<text>"] [registrar "<text>"]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `query \| response` | Message direction keyword | `query` | Selects a `\r\n`-terminated lookup string (`query`) or formatted WHOIS record (`response`). |
| `domain "<text>"` | Quoted domain name or IP query | `"example.com"` | Sets the queried domain name or the `Domain Name:` line in responses. |
| `registrar "<text>"` | Quoted registrar organization name | `"IANA" on response` | Populates the `Registrar:` record line inside `whois response` frames. |

## Cross-Layer Options Valid with `whois`

| 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 43` | 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

### Standalone whois (TCP 43) vs bacnet whois (UDP 47808)

- **Valid v3.2.2 Syntax:** `a -> b whois query domain "example.com"   // vs: a -> b bacnet whois`

Placing `whois` right after the endpoints (`a -> b whois ...`) selects RFC 3912 WHOIS on TCP `43`; placing it after `bacnet` (`a -> b bacnet whois`) selects BACnet Who-Is device discovery on UDP `47808`.
