# kerberos — Port 88 ASN.1 DER Tickets & RC4 Kerberoast Checks (`kerberos`)

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

- **Full Protocol Name:** Kerberos Network Authentication Service v5 (Active Directory)
- **Keyword:** `kerberos`
- **OSI Layer & Transport:** Layer 7 · UDP 88 (or TCP 88 via transport tcp)
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 4120, RFC 3962, RFC 4757
- **Wireshark Display Filter:** `kerberos`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> UDP 88 (or TCP 88 via transport tcp) (transport tcp|udp) -> Kerberos v5`

## Overview

Trigger SOC Kerberoasting rules (`tgsreq` + `sname "MSSQLSvc/..."` + `etype 23`) without firing offensive tools at a real Domain Controller — add `transport tcp` and the compiler prepends the 4-byte RFC 4120 TCP record length automatically.

Kerberos v5 (`kerberos`, RFC 4120) is the core ticket-granting authentication protocol in Microsoft Active Directory and enterprise Linux realms on **port `88`**. `kerberos` defaults to **UDP port `88`**, and adding `transport tcp` switches to **TCP port `88`**—automatically prepending the mandatory 4-byte RFC 4120 big-endian record-length header used by Windows Domain Controllers when tickets carry large PAC group memberships.

FrameAssembly encodes full ASN.1 DER Kerberos v5 (`pvno 5`) messages for `asreq`, `asrep`, `tgsreq`, `tgsrep`, and `krberror` with customizable `realm`, client principal (`cname`), service SPN (`sname`), and encryption type (`etype`, such as `18` for AES256 or `23` for RC4-HMAC).

## Minimal Quickstart (`kerberos_quickstart.frasm`)

```frameassembly
host domain_pc { ip 10.10.20.45 }
host ad_dc01   { ip 10.10.0.10 }

compile {
    domain_pc -> ad_dc01 kerberos asreq realm "CORP.INTERNAL" cname "jdoe" sname "krbtgt/CORP.INTERNAL" etype 18 wait 2ms
    domain_pc <- ad_dc01 kerberos asrep realm "CORP.INTERNAL" cname "jdoe" etype 18
}
```

### Automatic Wire Calculations

- Encodes valid ASN.1 DER RFC 4120 `APPLICATION` tags (`10` AS-REQ, `11` AS-REP, `12` TGS-REQ, `13` TGS-REP, `30` KRB-ERROR) with `pvno = 5`.
- Splits slash-separated SPNs like `"MSSQLSvc/db01.corp.internal:1433"` into multi-component `PrincipalName` ASN.1 sequences automatically.
- Prepends the 4-byte RFC 4120 §7.2.2 TCP record-mark length automatically whenever `transport tcp` is specified.

## Practical Lab Example: AES256 TGT Login Over TCP 88 + RC4 (`etype 23`) Kerberoasting Detection Lab (`kerberos_ad_detection_lab.frasm`)

Models a normal Windows workstation obtaining an AES256 TGT over TCP port 88, followed by an RC4 (`etype 23`) `tgsreq`/`tgsrep` SPN ticket request to trigger SOC Kerberoasting signatures.

```frameassembly
host wkstn_14 { ip 172.16.20.14 }
host dc01_ad  { ip 172.16.1.10 }

compile {
    // 1. Normal Active Directory TGT exchange over TCP port 88 (etype 18 = AES256)
    wkstn_14 -> dc01_ad tcp syn srcport 53088 dstport 88 win 65535 mss 1460 wait 1ms
    wkstn_14 <- dc01_ad tcp syn ack win 65535 mss 1460 wait 1ms
    wkstn_14 -> dc01_ad tcp ack wait 1ms
    wkstn_14 -> dc01_ad kerberos asreq realm "CORP.INTERNAL" cname "alice" sname "krbtgt/CORP.INTERNAL" etype 18 transport tcp wait 2ms
    wkstn_14 <- dc01_ad kerberos asrep realm "CORP.INTERNAL" cname "alice" etype 18 transport tcp wait 5ms
    // 2. Suspicious RC4-HMAC (etype 23) Service Ticket Request for SQL SPN (Kerberoasting test)
    wkstn_14 -> dc01_ad kerberos tgsreq realm "CORP.INTERNAL" cname "alice" sname "MSSQLSvc/db-prod.corp.internal:1433" etype 23 transport tcp wait 2ms
    wkstn_14 <- dc01_ad kerberos tgsrep realm "CORP.INTERNAL" cname "alice" sname "MSSQLSvc/db-prod.corp.internal:1433" etype 23 transport tcp
}
```

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

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

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

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

## All `kerberos` Keywords & Header Options

Packet line pattern: `src_host -> dst_host kerberos [asreq | asrep | tgsreq | tgsrep | krberror] [realm "<text>"] [cname "<text>"] [sname "<text>"] [etype <number>] [transport <udp|tcp>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `asreq \| asrep \| tgsreq \| tgsrep \| krberror` | Kerberos v5 message type | `asreq (msg-type 10)` | Selects Authentication Service Request/Reply (`10`/`11`), Ticket-Granting Service Request/Reply (`12`/`13`), or Error (`30`). |
| `realm "<text>"` | Quoted uppercase Kerberos realm (e.g. "CORP.INTERNAL") | `"EXAMPLE.COM"` | Encodes the `Realm` `GeneralString` inside the ASN.1 DER body. |
| `cname "<text>" \| sname "<text>"` | Quoted Client Principal Name or Service Principal Name (SPN) | `cname "alice", sname "krbtgt/EXAMPLE.COM"` | Encodes `PrincipalName` components in `KDC-REQ-BODY` / `KDC-REP`. |
| `etype <number>` | RFC 3961 encryption ID (`18` AES256, `17` AES128, `23` RC4-HMAC; negative vendor IDs allowed) | `18 (aes256-cts-hmac-sha1-96)` | Sets the requested or encrypted-part `etype` integer. |
| `transport <udp\|tcp>` | `udp` or `tcp` | `udp` | Switches between UDP `88` and TCP `88` (with 4-byte RFC 4120 TCP length prefix). |

## Cross-Layer Options Valid with `kerberos`

| 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), UDP 88 (or TCP 88 via transport tcp)` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `transport <tcp\|udp>` | `tcp` or `udp` (supported on 9 dual-L4 protocols) | `transport udp` | Switches Layer 4 transport between TCP (`psh ack` + length framing where required) and UDP. |
| `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` | When using TCP (`transport tcp` or default TCP): overrides automatic TCP sequence tracking, flags, or `mss`/`wscale`/`sackperm`/`tsval`/`tsecr`. |

## Common Mistakes & Quick Fixes

### No Hyphens in asreq, asrep, tgsreq, tgsrep, or krberror

- **Avoid:** `domain_pc -> ad_dc01 kerberos tgs-req etype 23`
- **Valid v3.2.2 Syntax:** `domain_pc -> ad_dc01 kerberos tgsreq etype 23`

Write Kerberos message types as single lowercase words without hyphens.
