File size: 5,851 Bytes
d086025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Packrat — Usage Documentation (cleanroom extract)

Packrat is a terminal-native network analysis tool: deep packet inspection,
deterministic security finding correlation, evidence retention, and
policy-gated response. It is keyboard-first and works on local consoles or
remote shells. It has no AI/LLM analysis mode; all findings come from
inspectable protocol logic, deterministic windows, IOC/YARA matches, or
operator-authored rules.

## Quick start

Simulation mode is explicit and needs no packet-capture library:

```bash
cargo build --release
./target/release/packrat --simulation
```

Live capture is the default runtime mode and requires the `real-capture`
build feature plus libpcap (Linux/macOS) or Npcap (Windows):

```bash
cargo build --release --features real-capture
sudo ./target/release/packrat
```

On startup Packrat opens the interface selector; navigate with `j`/`k` and
confirm with `Enter`.

For a narrower privilege boundary on Linux, grant capture capability to the
dedicated helper and keep the TUI unprivileged:

```bash
sudo setcap cap_net_raw=eip target/release/packrat-capture-helper
./target/release/packrat \
  --capture-helper ./target/release/packrat-capture-helper
```

Run `packrat --help` for the authoritative startup option list of the
installed version.

## Build features

| Cargo feature | Default | Purpose |
|---|---:|---|
| `real-capture` | No | Enable libpcap/Npcap capture and the capture helper |
| `ebpf-sockets` | No | Build the Linux Aya eBPF socket collector (optional short-lived socket ownership attribution) |

Build-time checks:

```bash
cargo test --locked
cargo check --locked --features real-capture
cargo check --locked --features ebpf-sockets --bin packrat-socket-collector
```

Platform-specific build instructions (Linux, macOS, Windows/Npcap,
cross-compilation, eBPF socket attribution, troubleshooting) are in
BUILD.md.

## Operator workflow: five workspaces

| Key | Workspace | Primary views |
|---|---|---|
| `1` | **Traffic** | Packets, flows, hosts, encrypted sessions |
| `2` | **Inspect** | Investigation tray, analysis, strings, workbench, objects, diff |
| `3` | **Defense** | Alert Center, specialist detectors, rules, operator graph |
| `4` | **Actions** | Scanner, traceroute, packet craft |
| `5` | **Case** | Notebook and event history |

## Core keyboard controls

| Key | Action |
|---|---|
| `Tab` / `F2` | Open the current workspace's view drawer |
| `Esc` | Close a window or return to the workspace home |
| `Alt+Left` | Return to the previous screen |
| `Ctrl+P` / `?` | Search packets, hosts, and findings |
| `m` / `M` | Pin selected evidence or current context to the investigation tray |
| `,` | Open persistent Preferences |
| `h` | Open the scrollable keyboard reference |
| `X` | Export the current case bundle |
| `!` | Revoke active Guard blocks and force monitor mode |

## Capabilities by stage

| Stage | Capability |
|---|---|
| **Capture** | Real interfaces, explicit simulation, PCAP import/replay, privileged capture helper |
| **Inspect** | Header tree, byte interpretation, packet comparison, VLAN/QinQ inspection, object carving |
| **Reconstruct** | Out-of-order TCP streams, IPv4/IPv6 fragment integrity, searchable bidirectional payloads |
| **Understand encryption** | TLS/DTLS/QUIC metadata, JA3/JA3S/JA4/RatQ context, key-log and authenticated helper hooks |
| **Detect** | Stateful IDS, scans, spoofing, DHCP/DNS abuse, HTTP smuggling, industrial-policy violations, credential exposure |
| **Correlate** | Unified Alert Center, IOC/YARA/rule findings, host and service graph, explainable risk scoring |
| **Preserve** | Retained attacker traffic, notebook, project state, PCAP/JSON/NDJSON evidence, case export |
| **Respond** | Monitor, preview, approved manual, or policy-gated automatic Linux nftables containment |

## Inputs and outputs

- **Inputs:** live interface capture (with `real-capture`), explicit
  simulation (`--simulation`), PCAP files for import/replay.
- **Outputs/evidence:** PCAP, JSON, and NDJSON evidence files; case bundle
  export (`X` key); OpenMetrics health and telemetry endpoint.
- **Rule inputs:** local packet rules from `~/.config/packrat/rules/`, IOC
  feeds, YARA rules over carved/reconstructed objects, hot-reloaded Lua
  dissectors, TOML protocol layouts.

## Deterministic defense behavior

- The Alert Center correlates recurring detector output into findings rather
  than one row per packet. Findings retain occurrence count, first/last packet
  evidence, severity, source, recommendation, and an analyst state: New,
  Reviewing, Confirmed, Benign, Contained, or Closed (plus optional review
  recommendation).
- Watch and Triage modes can pin urgent findings and add fixed,
  source-specific review guidance; they never modify firewall policy.
- TrafficLatch containment starts in `monitor` mode.
- Automatic containment requires a critical rule explicitly marked for
  automatic response OR two independent critical detectors for the same
  attacker and target.
- Blocks have short expirations; protected addresses are rejected; active
  actions are bounded; all decisions are audited.
- The global kill switch (`!`) attempts immediate revocation of active Guard
  blocks and records any failed revocation until expiry.

## Safety model

Packrat observes by default. Simulation requires `--simulation`; live capture
requires an explicitly built capture feature and operating-system permission;
containment remains monitor-only unless the operator selects another mode.
Use preview mode, protected management addresses, short expirations, and a
privilege-separated helper before enabling response on production networks.

## Licensing notes

- Code is MIT-licensed.
- Branding guidance (emoji rendering) and Matrix-effect license boundaries are
  described in docs/BRANDING_AND_LICENSES.md.