@modular-intelligence/wireshark 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +725 -0
- package/dist/index.js +45127 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
# Wireshark/Tshark MCP Server
|
|
2
|
+
|
|
3
|
+
A comprehensive network protocol analysis service that integrates tshark (Wireshark's command-line tool) through the Model Context Protocol. This MCP server enables Claude to perform deep packet inspection, protocol analysis, stream reconstruction, and forensic analysis of network capture (PCAP) files.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This server provides powerful offline network traffic analysis capabilities through tshark:
|
|
8
|
+
|
|
9
|
+
- **Packet Analysis** - Deep inspection of network packets with protocol dissection
|
|
10
|
+
- **Statistics Generation** - I/O stats, conversations, endpoints, protocol hierarchies
|
|
11
|
+
- **Field Extraction** - Custom extraction of specific protocol fields
|
|
12
|
+
- **Stream Following** - Reconstruct TCP/UDP/TLS/HTTP conversations
|
|
13
|
+
- **Expert Analysis** - Automated detection of protocol anomalies and issues
|
|
14
|
+
- **DNS Analysis** - Extract and analyze DNS queries and responses
|
|
15
|
+
|
|
16
|
+
Perfect for network forensics, security incident response, protocol debugging, traffic analysis, and network troubleshooting.
|
|
17
|
+
|
|
18
|
+
**IMPORTANT**: This server performs **offline analysis only**. Live network capture is explicitly blocked for security reasons.
|
|
19
|
+
|
|
20
|
+
## Tools
|
|
21
|
+
|
|
22
|
+
| Tool | Description |
|
|
23
|
+
|------|-------------|
|
|
24
|
+
| `tshark_analyze` | Analyze PCAP file and extract packet details in JSON format |
|
|
25
|
+
| `tshark_statistics` | Generate various statistics (I/O, conversations, endpoints, protocols, HTTP, DNS, expert info) |
|
|
26
|
+
| `tshark_extract_fields` | Extract specific protocol fields in tab-separated format |
|
|
27
|
+
| `tshark_follow_stream` | Follow and reconstruct TCP/UDP/TLS/HTTP streams |
|
|
28
|
+
| `tshark_expert_info` | Extract expert information and protocol anomalies |
|
|
29
|
+
| `tshark_file_info` | Get detailed PCAP file information and metadata |
|
|
30
|
+
| `tshark_dns_extract` | Extract DNS queries and responses with type filtering |
|
|
31
|
+
|
|
32
|
+
### Tshark Analyze
|
|
33
|
+
|
|
34
|
+
Analyze PCAP files and extract detailed packet information in structured JSON format.
|
|
35
|
+
|
|
36
|
+
**Input Parameters:**
|
|
37
|
+
```typescript
|
|
38
|
+
{
|
|
39
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
40
|
+
display_filter: string // Wireshark display filter (optional)
|
|
41
|
+
max_packets: number // Maximum packets to process (1-100000, default: 10000)
|
|
42
|
+
decode_as: string // Protocol decode override (optional, e.g., "tcp.port==8080,http")
|
|
43
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Example Request:**
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
51
|
+
"display_filter": "tcp.port == 443",
|
|
52
|
+
"max_packets": 1000,
|
|
53
|
+
"timeout": 120
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Example Output:**
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"file": "/tmp/capture.pcap",
|
|
61
|
+
"packets_analyzed": 156,
|
|
62
|
+
"results": [
|
|
63
|
+
{
|
|
64
|
+
"frame_number": 1,
|
|
65
|
+
"timestamp": "2024-01-15 10:30:45.123456",
|
|
66
|
+
"source": "192.168.1.100",
|
|
67
|
+
"destination": "93.184.216.34",
|
|
68
|
+
"protocol": "tls",
|
|
69
|
+
"length": 74,
|
|
70
|
+
"info": ""
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"frame_number": 2,
|
|
74
|
+
"timestamp": "2024-01-15 10:30:45.234567",
|
|
75
|
+
"source": "93.184.216.34",
|
|
76
|
+
"destination": "192.168.1.100",
|
|
77
|
+
"protocol": "tls",
|
|
78
|
+
"length": 1434,
|
|
79
|
+
"info": ""
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"summary": "Analyzed 156 packets from /tmp/capture.pcap with filter: tcp.port == 443"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Common Display Filters:**
|
|
87
|
+
- `tcp.port == 80` - HTTP traffic
|
|
88
|
+
- `dns` - All DNS traffic
|
|
89
|
+
- `http.request` - HTTP requests only
|
|
90
|
+
- `ip.addr == 192.168.1.1` - Traffic to/from specific IP
|
|
91
|
+
- `tcp.flags.syn == 1` - TCP SYN packets
|
|
92
|
+
- `!(arp or icmp)` - Exclude ARP and ICMP
|
|
93
|
+
|
|
94
|
+
### Tshark Statistics
|
|
95
|
+
|
|
96
|
+
Generate various types of statistics from PCAP files.
|
|
97
|
+
|
|
98
|
+
**Input Parameters:**
|
|
99
|
+
```typescript
|
|
100
|
+
{
|
|
101
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
102
|
+
stat_type: string // "io", "conv", "endpoints", "protocols", "http", "dns", or "expert"
|
|
103
|
+
display_filter: string // Wireshark display filter (optional)
|
|
104
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Statistic Types:**
|
|
109
|
+
- `io` - I/O statistics (packets/bytes over time)
|
|
110
|
+
- `conv` - TCP conversations between endpoints
|
|
111
|
+
- `endpoints` - IP endpoint statistics
|
|
112
|
+
- `protocols` - Protocol hierarchy
|
|
113
|
+
- `http` - HTTP-specific statistics
|
|
114
|
+
- `dns` - DNS-specific statistics
|
|
115
|
+
- `expert` - Expert information summary
|
|
116
|
+
|
|
117
|
+
**Example Request:**
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
121
|
+
"stat_type": "conv",
|
|
122
|
+
"timeout": 120
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Example Output:**
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"stat_type": "conv",
|
|
130
|
+
"data": {
|
|
131
|
+
"conversations": [
|
|
132
|
+
{
|
|
133
|
+
"line": "192.168.1.100:54321 <-> 93.184.216.34:443 1234 packets 987654 bytes"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"total": 1
|
|
137
|
+
},
|
|
138
|
+
"summary": "TCP conversations found: 1"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Tshark Extract Fields
|
|
143
|
+
|
|
144
|
+
Extract specific protocol fields from packets for custom analysis.
|
|
145
|
+
|
|
146
|
+
**Input Parameters:**
|
|
147
|
+
```typescript
|
|
148
|
+
{
|
|
149
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
150
|
+
fields: string[] // Protocol fields to extract (1-20 fields)
|
|
151
|
+
display_filter: string // Wireshark display filter (optional)
|
|
152
|
+
max_packets: number // Maximum packets to process (1-100000, default: 10000)
|
|
153
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Common Fields:**
|
|
158
|
+
- `ip.src`, `ip.dst` - Source and destination IP addresses
|
|
159
|
+
- `tcp.srcport`, `tcp.dstport` - TCP ports
|
|
160
|
+
- `http.host`, `http.request.uri` - HTTP host and URI
|
|
161
|
+
- `dns.qry.name`, `dns.resp.name` - DNS query/response names
|
|
162
|
+
- `frame.time`, `frame.len` - Frame timestamp and length
|
|
163
|
+
- `tcp.flags`, `tcp.seq` - TCP flags and sequence numbers
|
|
164
|
+
|
|
165
|
+
**Example Request:**
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
169
|
+
"fields": ["ip.src", "ip.dst", "tcp.srcport", "tcp.dstport"],
|
|
170
|
+
"display_filter": "tcp",
|
|
171
|
+
"max_packets": 5000
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Example Output:**
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"fields": ["ip.src", "ip.dst", "tcp.srcport", "tcp.dstport"],
|
|
179
|
+
"rows": [
|
|
180
|
+
["192.168.1.100", "93.184.216.34", "54321", "443"],
|
|
181
|
+
["93.184.216.34", "192.168.1.100", "443", "54321"],
|
|
182
|
+
["192.168.1.100", "1.1.1.1", "54322", "53"]
|
|
183
|
+
],
|
|
184
|
+
"total_rows": 3
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Tshark Follow Stream
|
|
189
|
+
|
|
190
|
+
Follow and reconstruct complete network streams (TCP/UDP/TLS/HTTP).
|
|
191
|
+
|
|
192
|
+
**Input Parameters:**
|
|
193
|
+
```typescript
|
|
194
|
+
{
|
|
195
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
196
|
+
protocol: string // "tcp", "udp", "tls", or "http"
|
|
197
|
+
stream_index: number // Stream index (0-based)
|
|
198
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Example Request:**
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
206
|
+
"protocol": "tcp",
|
|
207
|
+
"stream_index": 0
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Example Output:**
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"protocol": "tcp",
|
|
215
|
+
"stream_index": 0,
|
|
216
|
+
"content": "GET / HTTP/1.1\r\nHost: example.com\r\n\r\nHTTP/1.1 200 OK\r\n...",
|
|
217
|
+
"client_bytes": 145,
|
|
218
|
+
"server_bytes": 2048
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Tshark Expert Info
|
|
223
|
+
|
|
224
|
+
Extract expert information and protocol anomalies detected by Wireshark's analysis engine.
|
|
225
|
+
|
|
226
|
+
**Input Parameters:**
|
|
227
|
+
```typescript
|
|
228
|
+
{
|
|
229
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
230
|
+
severity: string // "chat", "note", "warn", or "error" (optional, minimum level)
|
|
231
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Severity Levels:**
|
|
236
|
+
- `chat` - Informational messages
|
|
237
|
+
- `note` - Notable events
|
|
238
|
+
- `warn` - Warnings (potential issues)
|
|
239
|
+
- `error` - Errors (definite problems)
|
|
240
|
+
|
|
241
|
+
**Example Request:**
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
245
|
+
"severity": "warn"
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Example Output:**
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"findings": [
|
|
253
|
+
{
|
|
254
|
+
"severity": "warn",
|
|
255
|
+
"group": "sequence",
|
|
256
|
+
"protocol": "tcp",
|
|
257
|
+
"summary": "TCP Retransmission detected",
|
|
258
|
+
"count": 1
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"severity": "error",
|
|
262
|
+
"group": "checksum",
|
|
263
|
+
"protocol": "ip",
|
|
264
|
+
"summary": "IP checksum error",
|
|
265
|
+
"count": 1
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
"total_by_severity": {
|
|
269
|
+
"error": 1,
|
|
270
|
+
"warn": 1,
|
|
271
|
+
"note": 0,
|
|
272
|
+
"chat": 0
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Tshark File Info
|
|
278
|
+
|
|
279
|
+
Get comprehensive information about PCAP file metadata and contents.
|
|
280
|
+
|
|
281
|
+
**Input Parameters:**
|
|
282
|
+
```typescript
|
|
283
|
+
{
|
|
284
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Example Request:**
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"pcap_path": "/tmp/capture.pcap"
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Example Output:**
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"file_path": "/tmp/capture.pcap",
|
|
299
|
+
"file_size": 12345678,
|
|
300
|
+
"capture_duration": "123.456789 seconds",
|
|
301
|
+
"total_packets": 5432,
|
|
302
|
+
"data_bytes": 12000000,
|
|
303
|
+
"avg_packet_size": 2209,
|
|
304
|
+
"first_packet_time": "2024-01-15 10:30:00.000000",
|
|
305
|
+
"last_packet_time": "2024-01-15 10:32:03.456789",
|
|
306
|
+
"protocols_found": ["eth", "ip", "tcp", "http", "tls", "dns"],
|
|
307
|
+
"encapsulation": "Ethernet"
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Tshark DNS Extract
|
|
312
|
+
|
|
313
|
+
Extract and analyze DNS queries and responses from network traffic.
|
|
314
|
+
|
|
315
|
+
**Input Parameters:**
|
|
316
|
+
```typescript
|
|
317
|
+
{
|
|
318
|
+
pcap_path: string // Absolute path to PCAP/PCAPNG file
|
|
319
|
+
query_type: string // "A", "AAAA", "MX", "NS", "TXT", "CNAME", "SOA", "PTR", "SRV", "ANY", "all"
|
|
320
|
+
timeout: number // Analysis timeout in seconds (10-600, default: 120)
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Query Types:**
|
|
325
|
+
- `A` - IPv4 address records
|
|
326
|
+
- `AAAA` - IPv6 address records
|
|
327
|
+
- `MX` - Mail exchange records
|
|
328
|
+
- `NS` - Nameserver records
|
|
329
|
+
- `TXT` - Text records
|
|
330
|
+
- `CNAME` - Canonical name records
|
|
331
|
+
- `SOA` - Start of authority records
|
|
332
|
+
- `PTR` - Pointer records (reverse DNS)
|
|
333
|
+
- `SRV` - Service records
|
|
334
|
+
- `ANY` - Any record type
|
|
335
|
+
- `all` - All DNS queries (default)
|
|
336
|
+
|
|
337
|
+
**Example Request:**
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
341
|
+
"query_type": "A"
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Example Output:**
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"queries": [
|
|
349
|
+
{
|
|
350
|
+
"name": "example.com",
|
|
351
|
+
"type": "A",
|
|
352
|
+
"responses": ["A: 93.184.216.34"]
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "www.example.com",
|
|
356
|
+
"type": "A",
|
|
357
|
+
"responses": ["CNAME: example.com", "A: 93.184.216.34"]
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
"unique_domains": ["example.com", "www.example.com"],
|
|
361
|
+
"total_queries": 2
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Configuration
|
|
366
|
+
|
|
367
|
+
### Prerequisites
|
|
368
|
+
|
|
369
|
+
This server requires tshark (Wireshark command-line tool) to be installed:
|
|
370
|
+
|
|
371
|
+
**macOS:**
|
|
372
|
+
```bash
|
|
373
|
+
brew install wireshark
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Linux (Debian/Ubuntu):**
|
|
377
|
+
```bash
|
|
378
|
+
sudo apt-get install tshark
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Linux (RHEL/CentOS):**
|
|
382
|
+
```bash
|
|
383
|
+
sudo yum install wireshark
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
**Verify Installation:**
|
|
387
|
+
```bash
|
|
388
|
+
which tshark
|
|
389
|
+
tshark --version
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Binary Location
|
|
393
|
+
|
|
394
|
+
The server expects tshark at `/opt/homebrew/bin/tshark` (macOS Homebrew default). For other systems, modify `TSHARK_PATH` in `src/cli-executor.ts`:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
const TSHARK_PATH = "/usr/bin/tshark"; // Linux
|
|
398
|
+
// or
|
|
399
|
+
const TSHARK_PATH = "/opt/homebrew/bin/tshark"; // macOS Homebrew
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Installation
|
|
403
|
+
|
|
404
|
+
### Prerequisites
|
|
405
|
+
|
|
406
|
+
- Bun runtime (version 1.x or later) or Node.js 18+
|
|
407
|
+
- tshark/Wireshark installed and accessible
|
|
408
|
+
- PCAP files for analysis (this server does NOT perform live capture)
|
|
409
|
+
|
|
410
|
+
### Steps
|
|
411
|
+
|
|
412
|
+
1. Clone or download this repository:
|
|
413
|
+
```bash
|
|
414
|
+
cd /path/to/mi-mcp-servers/packages/wireshark
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
2. Install dependencies:
|
|
418
|
+
```bash
|
|
419
|
+
bun install
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
3. Build the project:
|
|
423
|
+
```bash
|
|
424
|
+
bun run build
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
4. Verify tshark is installed:
|
|
428
|
+
```bash
|
|
429
|
+
which tshark
|
|
430
|
+
tshark --version
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
5. Run the server:
|
|
434
|
+
```bash
|
|
435
|
+
bun run start
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
## Usage
|
|
439
|
+
|
|
440
|
+
### Running the Server
|
|
441
|
+
|
|
442
|
+
Start the server with Bun:
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
bun run src/index.ts
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
The server implements the Model Context Protocol (MCP) and communicates via stdio transport.
|
|
449
|
+
|
|
450
|
+
### Claude Desktop Configuration
|
|
451
|
+
|
|
452
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
453
|
+
|
|
454
|
+
```json
|
|
455
|
+
{
|
|
456
|
+
"mcpServers": {
|
|
457
|
+
"wireshark": {
|
|
458
|
+
"command": "bun",
|
|
459
|
+
"args": [
|
|
460
|
+
"run",
|
|
461
|
+
"/path/to/mi-mcp-servers/packages/wireshark/src/index.ts"
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Claude Code MCP Settings
|
|
469
|
+
|
|
470
|
+
Configure in `.mcp.json` or settings UI:
|
|
471
|
+
|
|
472
|
+
```json
|
|
473
|
+
{
|
|
474
|
+
"servers": {
|
|
475
|
+
"wireshark": {
|
|
476
|
+
"transport": "stdio",
|
|
477
|
+
"command": "bun",
|
|
478
|
+
"args": [
|
|
479
|
+
"run",
|
|
480
|
+
"/path/to/mi-mcp-servers/packages/wireshark/src/index.ts"
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Example Usage in Claude
|
|
488
|
+
|
|
489
|
+
**Request:**
|
|
490
|
+
"Analyze the first 1000 packets from /tmp/capture.pcap and show me HTTP traffic only"
|
|
491
|
+
|
|
492
|
+
**Claude will call:**
|
|
493
|
+
```json
|
|
494
|
+
{
|
|
495
|
+
"tool": "tshark_analyze",
|
|
496
|
+
"input": {
|
|
497
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
498
|
+
"display_filter": "http",
|
|
499
|
+
"max_packets": 1000
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**Request:**
|
|
505
|
+
"Extract all DNS queries from /tmp/dns-traffic.pcap"
|
|
506
|
+
|
|
507
|
+
**Claude will call:**
|
|
508
|
+
```json
|
|
509
|
+
{
|
|
510
|
+
"tool": "tshark_dns_extract",
|
|
511
|
+
"input": {
|
|
512
|
+
"pcap_path": "/tmp/dns-traffic.pcap",
|
|
513
|
+
"query_type": "all"
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**Request:**
|
|
519
|
+
"Show me protocol statistics for /tmp/network.pcap"
|
|
520
|
+
|
|
521
|
+
**Claude will call:**
|
|
522
|
+
```json
|
|
523
|
+
{
|
|
524
|
+
"tool": "tshark_statistics",
|
|
525
|
+
"input": {
|
|
526
|
+
"pcap_path": "/tmp/network.pcap",
|
|
527
|
+
"stat_type": "protocols"
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**Request:**
|
|
533
|
+
"Follow the first TCP stream in /tmp/capture.pcap"
|
|
534
|
+
|
|
535
|
+
**Claude will call:**
|
|
536
|
+
```json
|
|
537
|
+
{
|
|
538
|
+
"tool": "tshark_follow_stream",
|
|
539
|
+
"input": {
|
|
540
|
+
"pcap_path": "/tmp/capture.pcap",
|
|
541
|
+
"protocol": "tcp",
|
|
542
|
+
"stream_index": 0
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
## Security
|
|
548
|
+
|
|
549
|
+
This server implements comprehensive security measures to ensure safe offline analysis:
|
|
550
|
+
|
|
551
|
+
### Input Validation
|
|
552
|
+
|
|
553
|
+
**PCAP Path Validation**
|
|
554
|
+
- Must be absolute path (starts with `/`)
|
|
555
|
+
- No path traversal (`..`, `./`)
|
|
556
|
+
- No null bytes
|
|
557
|
+
- Must have valid extension: `.pcap`, `.pcapng`, `.cap`
|
|
558
|
+
- File must exist and be a regular file (not directory)
|
|
559
|
+
- File size must be under 2GB
|
|
560
|
+
- File cannot be empty
|
|
561
|
+
|
|
562
|
+
**Display Filter Validation**
|
|
563
|
+
- Maximum length: 512 characters
|
|
564
|
+
- Valid characters: alphanumeric, `.`, `_`, `-`, `!`, `=`, `<`, `>`, `&`, `|`, `(`, `)`, `[`, `]`, `"`, `'`, `,`, `:`, `/`, spaces
|
|
565
|
+
- Blocks dangerous patterns: `exec(`, `system(`, `shell(`, backticks, `$(`, `${`
|
|
566
|
+
- Prevents command injection
|
|
567
|
+
|
|
568
|
+
**Field List Validation**
|
|
569
|
+
- Valid characters: alphanumeric, `.`, `_`, `-`, `,`
|
|
570
|
+
- Maximum field name length: 100 characters
|
|
571
|
+
- Minimum 1 field, maximum 20 fields
|
|
572
|
+
- No empty field names
|
|
573
|
+
|
|
574
|
+
**Blocked Flags**
|
|
575
|
+
- `-i`, `--interface` - Live capture blocked
|
|
576
|
+
- `-w`, `--write` - File writing blocked
|
|
577
|
+
- `-b`, `--ring-buffer` - Ring buffer blocked
|
|
578
|
+
|
|
579
|
+
**Packet Limits**
|
|
580
|
+
- Minimum: 1 packet
|
|
581
|
+
- Maximum: 100,000 packets per analysis
|
|
582
|
+
- Default: 10,000 packets
|
|
583
|
+
|
|
584
|
+
### What Gets Blocked
|
|
585
|
+
|
|
586
|
+
The server explicitly rejects:
|
|
587
|
+
- Live network capture (no `-i` flag)
|
|
588
|
+
- File writing operations (no `-w` flag)
|
|
589
|
+
- Relative file paths
|
|
590
|
+
- Path traversal attempts
|
|
591
|
+
- Files larger than 2GB
|
|
592
|
+
- Empty PCAP files
|
|
593
|
+
- Invalid file extensions
|
|
594
|
+
- Shell metacharacters in filters
|
|
595
|
+
- Overly long display filters (>512 chars)
|
|
596
|
+
- Too many fields (>20)
|
|
597
|
+
- Dangerous command injection patterns
|
|
598
|
+
|
|
599
|
+
### Error Handling
|
|
600
|
+
|
|
601
|
+
- File not found returns clear error message
|
|
602
|
+
- Invalid filter syntax caught and reported
|
|
603
|
+
- Timeout errors handled gracefully
|
|
604
|
+
- Parse errors reported with context
|
|
605
|
+
- Tool execution errors captured
|
|
606
|
+
|
|
607
|
+
### Offline Analysis Only
|
|
608
|
+
|
|
609
|
+
**IMPORTANT**: This server is designed for **offline PCAP analysis only**. Live network capture is explicitly disabled for security reasons:
|
|
610
|
+
|
|
611
|
+
1. No `-i` (interface) flag allowed
|
|
612
|
+
2. No `-w` (write) flag allowed
|
|
613
|
+
3. Must provide existing PCAP file path
|
|
614
|
+
4. Cannot capture live traffic
|
|
615
|
+
|
|
616
|
+
This design ensures:
|
|
617
|
+
- No unauthorized network monitoring
|
|
618
|
+
- No sensitive traffic capture
|
|
619
|
+
- Safe execution in restricted environments
|
|
620
|
+
- Compliance with security policies
|
|
621
|
+
|
|
622
|
+
## Common Use Cases
|
|
623
|
+
|
|
624
|
+
### Network Forensics
|
|
625
|
+
- Analyze captured traffic from security incidents
|
|
626
|
+
- Extract IOCs (IPs, domains, URLs)
|
|
627
|
+
- Reconstruct attack chains
|
|
628
|
+
- Identify malicious payloads
|
|
629
|
+
|
|
630
|
+
### Protocol Analysis
|
|
631
|
+
- Debug custom protocols
|
|
632
|
+
- Analyze protocol compliance
|
|
633
|
+
- Identify protocol issues
|
|
634
|
+
- Study protocol behavior
|
|
635
|
+
|
|
636
|
+
### Performance Analysis
|
|
637
|
+
- Identify retransmissions
|
|
638
|
+
- Analyze latency patterns
|
|
639
|
+
- Find bandwidth bottlenecks
|
|
640
|
+
- Study connection patterns
|
|
641
|
+
|
|
642
|
+
### Security Research
|
|
643
|
+
- Analyze malware traffic
|
|
644
|
+
- Study C2 communications
|
|
645
|
+
- Identify data exfiltration
|
|
646
|
+
- Research vulnerabilities
|
|
647
|
+
|
|
648
|
+
## Display Filter Examples
|
|
649
|
+
|
|
650
|
+
```
|
|
651
|
+
# HTTP
|
|
652
|
+
http.request.method == "POST"
|
|
653
|
+
http.host contains "example"
|
|
654
|
+
http.response.code == 404
|
|
655
|
+
|
|
656
|
+
# DNS
|
|
657
|
+
dns.qry.name contains "malware"
|
|
658
|
+
dns.flags.response == 1
|
|
659
|
+
dns.qry.type == 1 # A records
|
|
660
|
+
|
|
661
|
+
# TCP
|
|
662
|
+
tcp.flags.syn == 1 && tcp.flags.ack == 0 # SYN packets
|
|
663
|
+
tcp.analysis.retransmission # Retransmissions
|
|
664
|
+
tcp.port == 443 # HTTPS
|
|
665
|
+
|
|
666
|
+
# IP
|
|
667
|
+
ip.addr == 192.168.1.1
|
|
668
|
+
ip.src == 10.0.0.0/8
|
|
669
|
+
ip.ttl < 64
|
|
670
|
+
|
|
671
|
+
# TLS/SSL
|
|
672
|
+
tls.handshake.type == 1 # Client Hello
|
|
673
|
+
ssl.record.version == 0x0303 # TLS 1.2
|
|
674
|
+
|
|
675
|
+
# Combined
|
|
676
|
+
(http || dns) && ip.src == 192.168.1.100
|
|
677
|
+
tcp.port == 443 && !(tcp.flags.syn == 1)
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
## Limitations
|
|
681
|
+
|
|
682
|
+
- **File Size**: Maximum 2GB PCAP files
|
|
683
|
+
- **Packet Count**: Maximum 100,000 packets per analysis
|
|
684
|
+
- **Filter Length**: Maximum 512 characters
|
|
685
|
+
- **Field Count**: Maximum 20 fields for extraction
|
|
686
|
+
- **Timeout**: Maximum 600 seconds (10 minutes) per operation
|
|
687
|
+
- **Live Capture**: Not supported (offline analysis only)
|
|
688
|
+
- **File Writing**: Not supported (read-only operations)
|
|
689
|
+
|
|
690
|
+
## Troubleshooting
|
|
691
|
+
|
|
692
|
+
**"tshark command not found"**
|
|
693
|
+
- Install Wireshark/tshark: `brew install wireshark` or `apt-get install tshark`
|
|
694
|
+
- Update `TSHARK_PATH` in `src/cli-executor.ts`
|
|
695
|
+
|
|
696
|
+
**"PCAP file not found"**
|
|
697
|
+
- Use absolute paths only (start with `/`)
|
|
698
|
+
- Verify file exists: `ls -l /path/to/file.pcap`
|
|
699
|
+
- Check file permissions
|
|
700
|
+
|
|
701
|
+
**"Analysis timed out"**
|
|
702
|
+
- Reduce `max_packets` parameter
|
|
703
|
+
- Use more specific display filters
|
|
704
|
+
- Increase `timeout` parameter (max 600 seconds)
|
|
705
|
+
|
|
706
|
+
**"Invalid display filter"**
|
|
707
|
+
- Verify filter syntax in Wireshark first
|
|
708
|
+
- Check for unsupported characters
|
|
709
|
+
- Reduce filter complexity
|
|
710
|
+
|
|
711
|
+
**"File too large"**
|
|
712
|
+
- Split PCAP files: `editcap -c 100000 input.pcap output.pcap`
|
|
713
|
+
- Use display filters to reduce data
|
|
714
|
+
- Maximum supported: 2GB
|
|
715
|
+
|
|
716
|
+
## License
|
|
717
|
+
|
|
718
|
+
ISC License - see LICENSE file for details
|
|
719
|
+
|
|
720
|
+
## Resources
|
|
721
|
+
|
|
722
|
+
- **Wireshark**: https://www.wireshark.org/
|
|
723
|
+
- **Tshark Documentation**: https://www.wireshark.org/docs/man-pages/tshark.html
|
|
724
|
+
- **Display Filters**: https://wiki.wireshark.org/DisplayFilters
|
|
725
|
+
- **Protocol Fields**: https://www.wireshark.org/docs/dfref/
|