ot-pcap-triage 0.3.8__tar.gz

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.
Files changed (25) hide show
  1. ot_pcap_triage-0.3.8/LICENSE +21 -0
  2. ot_pcap_triage-0.3.8/PKG-INFO +435 -0
  3. ot_pcap_triage-0.3.8/README.md +404 -0
  4. ot_pcap_triage-0.3.8/pyproject.toml +49 -0
  5. ot_pcap_triage-0.3.8/setup.cfg +4 -0
  6. ot_pcap_triage-0.3.8/src/ot_pcap_triage/__init__.py +1 -0
  7. ot_pcap_triage-0.3.8/src/ot_pcap_triage/analyzer.py +495 -0
  8. ot_pcap_triage-0.3.8/src/ot_pcap_triage/cli.py +1065 -0
  9. ot_pcap_triage-0.3.8/src/ot_pcap_triage/control_references.yml +86 -0
  10. ot_pcap_triage-0.3.8/src/ot_pcap_triage/metadata.py +207 -0
  11. ot_pcap_triage-0.3.8/src/ot_pcap_triage/metadata_template.yml +74 -0
  12. ot_pcap_triage-0.3.8/src/ot_pcap_triage/mitre_ics_context.yml +198 -0
  13. ot_pcap_triage-0.3.8/src/ot_pcap_triage/protocol_catalog.yml +169 -0
  14. ot_pcap_triage-0.3.8/src/ot_pcap_triage/reports.py +574 -0
  15. ot_pcap_triage-0.3.8/src/ot_pcap_triage/rules.py +248 -0
  16. ot_pcap_triage-0.3.8/src/ot_pcap_triage/templates/report.html.j2 +453 -0
  17. ot_pcap_triage-0.3.8/src/ot_pcap_triage/templates/report.md.j2 +332 -0
  18. ot_pcap_triage-0.3.8/src/ot_pcap_triage/tshark.py +180 -0
  19. ot_pcap_triage-0.3.8/src/ot_pcap_triage/utils.py +42 -0
  20. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/PKG-INFO +435 -0
  21. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/SOURCES.txt +23 -0
  22. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/dependency_links.txt +1 -0
  23. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/entry_points.txt +2 -0
  24. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/requires.txt +4 -0
  25. ot_pcap_triage-0.3.8/src/ot_pcap_triage.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 hoek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,435 @@
1
+ Metadata-Version: 2.4
2
+ Name: ot-pcap-triage
3
+ Version: 0.3.8
4
+ Summary: Offline passive OT PCAP triage helper using tshark.
5
+ Author: Hoek
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/h0ek/ot-pcap-triage
8
+ Project-URL: Source, https://github.com/h0ek/ot-pcap-triage
9
+ Project-URL: Issues, https://github.com/h0ek/ot-pcap-triage/issues
10
+ Keywords: ot,ics,pcap,tshark,wireshark,security,scada
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Security
22
+ Classifier: Topic :: System :: Networking :: Monitoring
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: PyYAML>=6.0
27
+ Requires-Dist: Jinja2>=3.1
28
+ Requires-Dist: matplotlib>=3.8
29
+ Requires-Dist: graphviz>=0.20
30
+ Dynamic: license-file
31
+
32
+ # ot-pcap-triage
33
+
34
+ Offline passive OT PCAP triage helper using `tshark`.
35
+
36
+ `ot-pcap-triage` reads existing `.pcap` / `.pcapng` files and generates a lightweight triage report for passive OT/ICS network assessment.
37
+
38
+ It does not actively scan, inject packets, or connect to any target.
39
+
40
+ ## What it does
41
+
42
+ `ot-pcap-triage` helps analyze passive OT traffic by generating:
43
+
44
+ - HTML and Markdown reports;
45
+ - finding candidates and review points;
46
+ - endpoint and conversation summaries;
47
+ - passive asset inventory;
48
+ - industrial protocol observations;
49
+ - risky/external communication indicators;
50
+ - redacted sensitive/plaintext evidence;
51
+ - timeline and communication graphs;
52
+ - suggested metadata for follow-up context-aware analysis.
53
+
54
+ The tool is intended for **triage and analyst support**, not automatic vulnerability confirmation.
55
+
56
+ ## Fedora install
57
+
58
+ ```bash
59
+ sudo dnf install -y git wireshark-cli python3 python3-pip graphviz p7zip p7zip-plugins
60
+ ```
61
+
62
+ ## Debian / Kali install
63
+
64
+ ```bash
65
+ sudo apt install -y git tshark wireshark-common python3 python3-pip graphviz p7zip-full
66
+ ```
67
+
68
+ ## Python install with virtualenvwrapper
69
+
70
+ Clone the repository:
71
+
72
+ ```bash
73
+ git clone https://github.com/h0ek/ot-pcap-triage
74
+ cd ot-pcap-triage
75
+ ```
76
+
77
+ Create and install in a virtualenv:
78
+
79
+ ```bash
80
+ mkvirtualenv ot-pcap-triage -p python3
81
+ pip install -e .
82
+ ```
83
+
84
+ Verify:
85
+
86
+ ```bash
87
+ ot-pcap-triage --help
88
+ ot-pcap-triage --check-deps
89
+ ```
90
+
91
+ ## Basic usage
92
+
93
+ PCAP-only mode:
94
+
95
+ ```bash
96
+ ot-pcap-triage capture.pcapng
97
+ ```
98
+
99
+ PCAP with factory/site metadata:
100
+
101
+ ```bash
102
+ ot-pcap-triage capture.pcapng --metadata capture.yml
103
+ ```
104
+
105
+ Custom output directory:
106
+
107
+ ```bash
108
+ ot-pcap-triage capture.pcapng -o output/test1
109
+ ```
110
+
111
+ More evidence frames per rule:
112
+
113
+ ```bash
114
+ ot-pcap-triage capture.pcapng --max-evidence 25
115
+ ```
116
+
117
+ Graph size tuning:
118
+
119
+ ```bash
120
+ ot-pcap-triage capture.pcapng --graph-top-n 25
121
+ ```
122
+
123
+ Dependency-only preflight:
124
+
125
+ ```bash
126
+ ot-pcap-triage --check-deps
127
+ ```
128
+
129
+ ## Metadata template
130
+
131
+ A default metadata template is provided:
132
+
133
+ ```text
134
+ metadata_template.yml
135
+ ```
136
+
137
+ Copy it for a specific capture:
138
+
139
+ ```bash
140
+ cp metadata_template.yml plant1-line2-capture.yml
141
+ nano plant1-line2-capture.yml
142
+ ```
143
+
144
+ Use it:
145
+
146
+ ```bash
147
+ ot-pcap-triage capture.pcapng --metadata plant1-line2-capture.yml -o output/plant1-line2
148
+ ```
149
+
150
+ ## Recommended workflow
151
+
152
+ Best workflow when the factory/site can provide context:
153
+
154
+ ```text
155
+ 1. Ask the factory/site to fill metadata_template.yml.
156
+
157
+ 2. Run PCAP-only mode first:
158
+ ot-pcap-triage capture.pcapng -o out-pass1
159
+
160
+ 3. Review out-pass1/suggested_metadata.yml.
161
+
162
+ 4. Compare observed/inferred data with the factory-provided metadata.
163
+
164
+ 5. Create reviewed metadata:
165
+ cp factory_metadata.yml reviewed_metadata.yml
166
+ nano reviewed_metadata.yml
167
+
168
+ 6. Add useful observations from suggested_metadata.yml manually.
169
+
170
+ 7. Run context-aware mode:
171
+ ot-pcap-triage capture.pcapng --metadata reviewed_metadata.yml -o out-pass2
172
+
173
+ 8. Use out-pass2/report.html and findings.json for manual validation.
174
+ ```
175
+
176
+ When no metadata exists:
177
+
178
+ ```bash
179
+ ot-pcap-triage capture.pcapng -o out-pass1
180
+ cp out-pass1/suggested_metadata.yml reviewed_capture.yml
181
+ nano reviewed_capture.yml
182
+ ot-pcap-triage capture.pcapng --metadata reviewed_capture.yml -o out-pass2
183
+ ```
184
+
185
+ ## Metadata behavior
186
+
187
+ ```text
188
+ factory metadata = expected architecture
189
+ suggested_metadata.yml = observed/inferred helper
190
+ reviewed_metadata.yml = human-reviewed combination
191
+ ```
192
+
193
+ The generated `suggested_metadata.yml` is not authoritative. It must be reviewed.
194
+
195
+ If `--metadata` is provided, the provided metadata is used for expected-vs-observed checks, but `suggested_metadata.yml` is still generated as observed/inferred enrichment.
196
+
197
+ ## Output files
198
+
199
+ Default output directory:
200
+
201
+ ```text
202
+ output/<pcap-name>-<timestamp>/
203
+ report.html
204
+ report.md
205
+ summary.json
206
+ findings.json
207
+ endpoints.csv
208
+ conversations.csv
209
+ protocols.csv
210
+ sensitive_hits_redacted.csv
211
+ suggested_metadata.yml
212
+ commands_used.txt
213
+ timeline_packets.png
214
+ communication_graph.png
215
+ industrial_risk_graph.png
216
+ industrial_protocol_graph.png
217
+ external_communication_graph.png
218
+ ```
219
+
220
+ Some files may be missing if there is no matching data or an optional renderer is unavailable. For example, graph images require Graphviz `dot`.
221
+
222
+ ## Report sections
223
+
224
+ The HTML and Markdown reports include:
225
+
226
+ - PCAP Summary;
227
+ - Baseline Mode Notice, when no metadata YAML was provided;
228
+ - NIST SP 800-82r3 Review Context;
229
+ - MITRE ATT&CK for ICS Review Context;
230
+ - Top Risky Observations;
231
+ - Observed Industrial Protocols;
232
+ - Top S7/COTP Communication Paths, when S7 traffic is observed;
233
+ - Extended Protocol Candidates;
234
+ - Traffic Timeline;
235
+ - Communication Graph;
236
+ - Industrial / Risk Communication Graph;
237
+ - Industrial Protocol Graph;
238
+ - External Communication Graph;
239
+ - Graph Legend;
240
+ - Passive Asset Inventory;
241
+ - Cleartext Management Surface;
242
+ - IT/OT Convergence Indicators;
243
+ - Engineering / Scanner Candidates;
244
+ - Analyst Questions;
245
+ - Capture Quality Notes;
246
+ - Finding Candidates;
247
+ - Top Endpoints;
248
+ - Top Conversations;
249
+ - Rule Results;
250
+ - Protocol Hierarchy Raw.
251
+
252
+ ## Baseline mode without metadata
253
+
254
+ When no metadata YAML is provided, the tool still reports generic OT/ICS best-practice review points.
255
+
256
+ Examples:
257
+
258
+ - public DNS;
259
+ - public NTP;
260
+ - VPN-like traffic;
261
+ - plaintext protocols;
262
+ - discovery/name-resolution noise;
263
+ - TCP connection anomalies;
264
+ - observed industrial protocols.
265
+
266
+ Without metadata, these are usually `candidate` or `informational` observations that require validation with the local OT/site owner.
267
+
268
+ Metadata does not make the tool “work”; metadata increases confidence and enables expected-vs-observed checks.
269
+
270
+ ## Finding candidates
271
+
272
+ A finding candidate is not automatically a confirmed vulnerability.
273
+
274
+ Typical statuses:
275
+
276
+ | Status | Meaning |
277
+ |---|---|
278
+ | `candidate` | Potential issue detected automatically. |
279
+ | `confirmed_by_rule` | Strong direct evidence, for example cleartext credential indicator. |
280
+ | `informational` | Useful observation, not a finding by itself. |
281
+
282
+ Manual validation is required.
283
+
284
+ ## OT enrichment
285
+
286
+ The report includes OT-specific enrichment sections:
287
+
288
+ - `Passive Asset Inventory` — inferred roles based on observed protocols and ports;
289
+ - `Cleartext Management Surface` — Telnet/FTP/HTTP/SNMP/RSH-like management exposure candidates;
290
+ - `IT/OT Convergence Indicators` — public communication, VPN-like traffic, cross-subnet industrial communication;
291
+ - `Engineering / Scanner Candidates` — hosts that initiate industrial protocol communication to controllers/devices.
292
+
293
+ These sections are heuristic. Without metadata, they are review points. With metadata, they help validate expected-vs-observed architecture.
294
+
295
+ ## Protocol catalog enrichment
296
+
297
+ `protocol_catalog.yml` contains a curated list of industrial, utility, and building automation protocol port mappings.
298
+
299
+ The catalog is used for enrichment only:
300
+
301
+ - it helps label possible industrial/building/utility protocol candidates;
302
+ - it does not automatically create high-severity findings;
303
+ - matches based only on ports are shown as candidates;
304
+ - analyst validation is required.
305
+
306
+ The report section `Extended Protocol Candidates` shows catalog matches with:
307
+
308
+ - protocol name;
309
+ - category;
310
+ - matched port;
311
+ - packet/byte counters;
312
+ - confidence;
313
+ - note.
314
+
315
+ This is useful when a protocol is not decoded by Wireshark/tshark but the traffic uses a known industrial port.
316
+
317
+ ## NIST SP 800-82r3 review context
318
+
319
+ Reports include an optional `NIST SP 800-82r3 Review Context` section.
320
+
321
+ This maps observed PCAP findings to high-level OT security themes such as:
322
+
323
+ - network segmentation and boundary protection;
324
+ - remote access control;
325
+ - plaintext protocol exposure;
326
+ - anomaly and event monitoring;
327
+ - industrial protocol security;
328
+ - asset inventory validation;
329
+ - IT/OT convergence review.
330
+
331
+ This is **not** a compliance certification. It is analyst guidance that helps connect packet evidence to recognized OT security review areas.
332
+
333
+ Source: https://doi.org/10.6028/NIST.SP.800-82r3
334
+
335
+ ## MITRE ATT&CK for ICS review context
336
+
337
+ Reports include an optional `MITRE ATT&CK for ICS Review Context` section.
338
+
339
+ This maps observed PCAP findings to related ATT&CK for ICS techniques to consider, such as:
340
+
341
+ - Remote Services;
342
+ - Internet Accessible Device;
343
+ - Remote System Discovery;
344
+ - Port Scan;
345
+ - Broadcast Discovery;
346
+ - Multicast Discovery;
347
+ - Standard Application Layer Protocol;
348
+ - Commonly Used Port;
349
+ - Rogue Master;
350
+ - Unauthorized Message;
351
+ - Program Upload / Program Download context where later evidence supports it.
352
+
353
+ This is **not** proof of adversary activity. It is a contextual mapping to help analysts think about how observed network behavior could relate to known adversary techniques.
354
+
355
+ MITRE context is generated from:
356
+
357
+ ```text
358
+ mitre_ics_context.yml
359
+ ```
360
+
361
+ Source: https://attack.mitre.org/matrices/ics/
362
+
363
+ ## Traffic timeline
364
+
365
+ Reports include a `Traffic Timeline` section with a static PNG chart generated from the PCAP.
366
+
367
+ Behavior:
368
+
369
+ - bucket size is selected automatically;
370
+ - captures up to roughly 2 hours use 1-minute buckets;
371
+ - larger captures use 5-minute buckets;
372
+ - series shown: S7/COTP, DNS, NTP, ICMP, VPN, Discovery, and Other.
373
+
374
+ Output file:
375
+
376
+ ```text
377
+ timeline_packets.png
378
+ ```
379
+
380
+ ## Communication graphs
381
+
382
+ Reports include Graphviz-based static communication maps:
383
+
384
+ - `communication_graph.png` — top communication paths by packet count;
385
+ - `industrial_risk_graph.png` — industrial, external, or otherwise high-interest paths;
386
+ - `industrial_protocol_graph.png` — industrial-only communication view;
387
+ - `external_communication_graph.png` — public/external communication view.
388
+
389
+ Graph behavior:
390
+
391
+ - graph size is controlled with `--graph-top-n`;
392
+ - node labels include IP plus a short inferred role when available;
393
+ - nodes are grouped into subnet clusters;
394
+ - edge labels show protocol, packet count, and byte count;
395
+ - graph legend is included in the report.
396
+
397
+ ## Public test PCAPs
398
+
399
+ Public ICS/SCADA PCAPs are available at Netresec:
400
+
401
+ ```text
402
+ https://www.netresec.com/?page=PcapFiles
403
+ ```
404
+
405
+ Useful sections:
406
+
407
+ - `SCADA/ICS Network Captures`;
408
+ - `4SICS ICS Lab PCAP files`;
409
+ - `DigitalBond S4x15 ICS Village CTF PCAPs`.
410
+
411
+ ## Performance notes
412
+
413
+ Main packet aggregation is streamed from `tshark` line-by-line instead of loading all packet rows into memory.
414
+
415
+ This reduces Python memory usage for large PCAP files.
416
+
417
+ The tool still runs additional `tshark` passes for rule evidence and counts, so large files can still take time.
418
+
419
+ Temporary partial files are written to:
420
+
421
+ ```text
422
+ output/<pcap-name>/.work/
423
+ ```
424
+
425
+ The `.work` directory is removed after a successful run. If the tool crashes, it may remain for debugging.
426
+
427
+ ## Limitations
428
+
429
+ - Passive PCAP only.
430
+ - Traffic not visible at the capture point cannot be assessed.
431
+ - Short captures may miss scheduled jobs, vendor access, or engineering activity.
432
+ - SPAN/mirror oversubscription may cause missing packets.
433
+ - Encrypted payloads cannot be fully inspected.
434
+ - Findings are candidates/review points until manually validated.
435
+ - Absence of evidence is not evidence of absence.