it-pcap-triage 0.6__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.
- it_pcap_triage-0.6/LICENSE +21 -0
- it_pcap_triage-0.6/PKG-INFO +197 -0
- it_pcap_triage-0.6/README.md +184 -0
- it_pcap_triage-0.6/pyproject.toml +30 -0
- it_pcap_triage-0.6/setup.cfg +4 -0
- it_pcap_triage-0.6/src/it_pcap_triage/__init__.py +1 -0
- it_pcap_triage-0.6/src/it_pcap_triage/__main__.py +4 -0
- it_pcap_triage-0.6/src/it_pcap_triage/analyzer.py +136 -0
- it_pcap_triage-0.6/src/it_pcap_triage/checks/dependencies.py +62 -0
- it_pcap_triage-0.6/src/it_pcap_triage/cli.py +124 -0
- it_pcap_triage-0.6/src/it_pcap_triage/config.py +54 -0
- it_pcap_triage-0.6/src/it_pcap_triage/data/protocol_risks.yml +15 -0
- it_pcap_triage-0.6/src/it_pcap_triage/data/reference_catalog.yml +52 -0
- it_pcap_triage-0.6/src/it_pcap_triage/data/security_mappings.yml +122 -0
- it_pcap_triage-0.6/src/it_pcap_triage/data/security_references.yml +20 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/cleartext_auth.py +55 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/dns_anomalies.py +107 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/exfiltration.py +37 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/insecure_protocols.py +45 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/scanning.py +102 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/suricata_alerts.py +55 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/tls_hygiene.py +44 -0
- it_pcap_triage-0.6/src/it_pcap_triage/detectors/windows_auth.py +40 -0
- it_pcap_triage-0.6/src/it_pcap_triage/engines/suricata.py +19 -0
- it_pcap_triage-0.6/src/it_pcap_triage/engines/tshark.py +45 -0
- it_pcap_triage-0.6/src/it_pcap_triage/engines/zeek.py +9 -0
- it_pcap_triage-0.6/src/it_pcap_triage/model/finding.py +43 -0
- it_pcap_triage-0.6/src/it_pcap_triage/model/host.py +28 -0
- it_pcap_triage-0.6/src/it_pcap_triage/parsers/suricata_eve.py +28 -0
- it_pcap_triage-0.6/src/it_pcap_triage/parsers/tshark_stats.py +86 -0
- it_pcap_triage-0.6/src/it_pcap_triage/parsers/zeek_logs.py +46 -0
- it_pcap_triage-0.6/src/it_pcap_triage/references.py +56 -0
- it_pcap_triage-0.6/src/it_pcap_triage/report/html.py +56 -0
- it_pcap_triage-0.6/src/it_pcap_triage/report/templates/report.html +286 -0
- it_pcap_triage-0.6/src/it_pcap_triage/scoring/risk.py +79 -0
- it_pcap_triage-0.6/src/it_pcap_triage/stats.py +107 -0
- it_pcap_triage-0.6/src/it_pcap_triage/storage/__init__.py +0 -0
- it_pcap_triage-0.6/src/it_pcap_triage/storage/sqlite_store.py +183 -0
- it_pcap_triage-0.6/src/it_pcap_triage/utils.py +87 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/PKG-INFO +197 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/SOURCES.txt +43 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/dependency_links.txt +1 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/entry_points.txt +2 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/requires.txt +2 -0
- it_pcap_triage-0.6/src/it_pcap_triage.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 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,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: it-pcap-triage
|
|
3
|
+
Version: 0.6
|
|
4
|
+
Summary: Offline IT PCAP analyzer using Zeek, Suricata and tshark.
|
|
5
|
+
Author: Hoek
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: PyYAML>=6.0.1
|
|
11
|
+
Requires-Dist: Jinja2>=3.1.3
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# IT PCAP Triage
|
|
15
|
+
|
|
16
|
+
Offline analyzer for enterprise IT packet captures.
|
|
17
|
+
|
|
18
|
+
IT PCAP Triage runs **Zeek**, **Suricata**, **capinfos** and compact **tshark** protocol summaries against a PCAP/PCAPNG file. It parses their output, correlates activity by host/protocol, scores findings and generates a compact HTML security report.
|
|
19
|
+
|
|
20
|
+
The project does not implement its own packet inspection engine. It orchestrates trusted offline engines and turns their output into an evidence-based security report.
|
|
21
|
+
|
|
22
|
+
## Architecture
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
PCAP
|
|
26
|
+
├── Zeek → behavioral logs / metadata / protocol logs
|
|
27
|
+
├── Suricata → IDS alerts / IOC / exploit-pattern alerts
|
|
28
|
+
├── capinfos → PCAP metadata
|
|
29
|
+
├── tshark → protocol hierarchy summary
|
|
30
|
+
└── Python → correlation / scoring / SQLite evidence / HTML report
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
TShark is not used to dump huge raw conversation logs into the report. It is used as a compact statistics source. Conversation, endpoint, top talker, service and port summaries are calculated from Zeek `conn.log`.
|
|
34
|
+
|
|
35
|
+
## Focus areas
|
|
36
|
+
|
|
37
|
+
- cleartext protocols and exposed credentials,
|
|
38
|
+
- legacy/insecure IT protocols,
|
|
39
|
+
- SMB/NTLM/Kerberos/LDAP/Windows network risks,
|
|
40
|
+
- DNS abuse and tunneling indicators,
|
|
41
|
+
- TLS and HTTP hygiene issues,
|
|
42
|
+
- scanning and lateral movement patterns,
|
|
43
|
+
- Suricata IDS alerts,
|
|
44
|
+
- suspicious beaconing and data movement,
|
|
45
|
+
- policy violations based on a user-defined network baseline.
|
|
46
|
+
|
|
47
|
+
## Required system tools
|
|
48
|
+
|
|
49
|
+
The tool fails closed if any required engine is missing:
|
|
50
|
+
|
|
51
|
+
- `zeek`
|
|
52
|
+
- `suricata`
|
|
53
|
+
- `tshark`
|
|
54
|
+
- `capinfos`
|
|
55
|
+
|
|
56
|
+
## Install system dependencies
|
|
57
|
+
|
|
58
|
+
### Debian / Ubuntu / Kali
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
sudo apt update
|
|
62
|
+
sudo apt install -y python3 python3-pip pipx tshark zeek suricata
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Fedora
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
sudo dnf install -y python3 python3-pip pipx wireshark-cli zeek suricata
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Make sure `pipx` is available in your shell:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
pipx ensurepath
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Restart your shell if needed.
|
|
78
|
+
|
|
79
|
+
## Install IT PCAP Triage
|
|
80
|
+
|
|
81
|
+
Install from PyPI with `pipx`:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
pipx install it-pcap-triage
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Check the installation and required system tools:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
it-pcap-triage check
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run analysis:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
it-pcap-triage analyze samples/test.pcapng --out out/test-report
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Open the report:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
xdg-open out/test-report/report.html
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Output
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
out/test-report/
|
|
109
|
+
├── report.html
|
|
110
|
+
├── summary.json
|
|
111
|
+
├── findings.json
|
|
112
|
+
├── hosts.json
|
|
113
|
+
├── timings.json
|
|
114
|
+
├── triage.db
|
|
115
|
+
├── logs/
|
|
116
|
+
│ └── run.log
|
|
117
|
+
└── engines/
|
|
118
|
+
├── zeek/
|
|
119
|
+
├── suricata/
|
|
120
|
+
└── tshark/
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The main output is:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
report.html
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The JSON files and SQLite database are intended for automation, debugging and deeper investigation.
|
|
130
|
+
|
|
131
|
+
## Advanced: Evidence DB
|
|
132
|
+
|
|
133
|
+
The analysis also creates a SQLite evidence store:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
triage.db
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Useful inspection commands:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
sqlite3 out/test-report/triage.db '.tables'
|
|
143
|
+
sqlite3 out/test-report/triage.db \
|
|
144
|
+
'select severity, category, title from findings order by id;'
|
|
145
|
+
sqlite3 out/test-report/triage.db \
|
|
146
|
+
'select host, risk_score, suricata_alerts, peers_count from host_profiles order by risk_score desc limit 20;'
|
|
147
|
+
sqlite3 out/test-report/triage.db \
|
|
148
|
+
'select src_ip, dest_ip, signature, severity from suricata_alerts limit 20;'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Reference mapping policy
|
|
152
|
+
|
|
153
|
+
The project does not bundle NIST PDFs, CIS PDFs, MITRE STIX bundles or other third-party source documents.
|
|
154
|
+
|
|
155
|
+
Runtime enrichment uses curated source names and mappings in:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
src/it_pcap_triage/data/reference_catalog.yml
|
|
159
|
+
src/it_pcap_triage/data/security_mappings.yml
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This avoids redistributing third-party documents and keeps the report clear about which public framework or document each recommendation is based on.
|
|
163
|
+
|
|
164
|
+
The report references documents by name, section/control/technique and URL where applicable, for example:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
NIST SP 800-52 Rev.2
|
|
168
|
+
NIST SP 800-81 Rev.3
|
|
169
|
+
NIST SP 800-41 Rev.1
|
|
170
|
+
CIS Controls v8.1
|
|
171
|
+
MITRE ATT&CK Enterprise
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Local development
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
git clone https://github.com/h0ek/it-pcap-triage.git
|
|
178
|
+
cd it-pcap-triage
|
|
179
|
+
|
|
180
|
+
python3 -m venv .venv
|
|
181
|
+
source .venv/bin/activate
|
|
182
|
+
|
|
183
|
+
pip install -e .
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Run locally:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
it-pcap-triage check
|
|
190
|
+
it-pcap-triage analyze samples/test.pcapng --out out/test-report
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Limitations
|
|
194
|
+
|
|
195
|
+
This is a triage tool, not a SIEM, permanent IDS sensor or full forensic platform.
|
|
196
|
+
|
|
197
|
+
Findings such as DNS tunneling, beaconing, lateral movement or ransomware-like behavior are indicators and require validation.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# IT PCAP Triage
|
|
2
|
+
|
|
3
|
+
Offline analyzer for enterprise IT packet captures.
|
|
4
|
+
|
|
5
|
+
IT PCAP Triage runs **Zeek**, **Suricata**, **capinfos** and compact **tshark** protocol summaries against a PCAP/PCAPNG file. It parses their output, correlates activity by host/protocol, scores findings and generates a compact HTML security report.
|
|
6
|
+
|
|
7
|
+
The project does not implement its own packet inspection engine. It orchestrates trusted offline engines and turns their output into an evidence-based security report.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
PCAP
|
|
13
|
+
├── Zeek → behavioral logs / metadata / protocol logs
|
|
14
|
+
├── Suricata → IDS alerts / IOC / exploit-pattern alerts
|
|
15
|
+
├── capinfos → PCAP metadata
|
|
16
|
+
├── tshark → protocol hierarchy summary
|
|
17
|
+
└── Python → correlation / scoring / SQLite evidence / HTML report
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
TShark is not used to dump huge raw conversation logs into the report. It is used as a compact statistics source. Conversation, endpoint, top talker, service and port summaries are calculated from Zeek `conn.log`.
|
|
21
|
+
|
|
22
|
+
## Focus areas
|
|
23
|
+
|
|
24
|
+
- cleartext protocols and exposed credentials,
|
|
25
|
+
- legacy/insecure IT protocols,
|
|
26
|
+
- SMB/NTLM/Kerberos/LDAP/Windows network risks,
|
|
27
|
+
- DNS abuse and tunneling indicators,
|
|
28
|
+
- TLS and HTTP hygiene issues,
|
|
29
|
+
- scanning and lateral movement patterns,
|
|
30
|
+
- Suricata IDS alerts,
|
|
31
|
+
- suspicious beaconing and data movement,
|
|
32
|
+
- policy violations based on a user-defined network baseline.
|
|
33
|
+
|
|
34
|
+
## Required system tools
|
|
35
|
+
|
|
36
|
+
The tool fails closed if any required engine is missing:
|
|
37
|
+
|
|
38
|
+
- `zeek`
|
|
39
|
+
- `suricata`
|
|
40
|
+
- `tshark`
|
|
41
|
+
- `capinfos`
|
|
42
|
+
|
|
43
|
+
## Install system dependencies
|
|
44
|
+
|
|
45
|
+
### Debian / Ubuntu / Kali
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
sudo apt update
|
|
49
|
+
sudo apt install -y python3 python3-pip pipx tshark zeek suricata
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Fedora
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
sudo dnf install -y python3 python3-pip pipx wireshark-cli zeek suricata
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Make sure `pipx` is available in your shell:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
pipx ensurepath
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Restart your shell if needed.
|
|
65
|
+
|
|
66
|
+
## Install IT PCAP Triage
|
|
67
|
+
|
|
68
|
+
Install from PyPI with `pipx`:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
pipx install it-pcap-triage
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Check the installation and required system tools:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
it-pcap-triage check
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Run analysis:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
it-pcap-triage analyze samples/test.pcapng --out out/test-report
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Open the report:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
xdg-open out/test-report/report.html
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Output
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
out/test-report/
|
|
96
|
+
├── report.html
|
|
97
|
+
├── summary.json
|
|
98
|
+
├── findings.json
|
|
99
|
+
├── hosts.json
|
|
100
|
+
├── timings.json
|
|
101
|
+
├── triage.db
|
|
102
|
+
├── logs/
|
|
103
|
+
│ └── run.log
|
|
104
|
+
└── engines/
|
|
105
|
+
├── zeek/
|
|
106
|
+
├── suricata/
|
|
107
|
+
└── tshark/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The main output is:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
report.html
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The JSON files and SQLite database are intended for automation, debugging and deeper investigation.
|
|
117
|
+
|
|
118
|
+
## Advanced: Evidence DB
|
|
119
|
+
|
|
120
|
+
The analysis also creates a SQLite evidence store:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
triage.db
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Useful inspection commands:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
sqlite3 out/test-report/triage.db '.tables'
|
|
130
|
+
sqlite3 out/test-report/triage.db \
|
|
131
|
+
'select severity, category, title from findings order by id;'
|
|
132
|
+
sqlite3 out/test-report/triage.db \
|
|
133
|
+
'select host, risk_score, suricata_alerts, peers_count from host_profiles order by risk_score desc limit 20;'
|
|
134
|
+
sqlite3 out/test-report/triage.db \
|
|
135
|
+
'select src_ip, dest_ip, signature, severity from suricata_alerts limit 20;'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Reference mapping policy
|
|
139
|
+
|
|
140
|
+
The project does not bundle NIST PDFs, CIS PDFs, MITRE STIX bundles or other third-party source documents.
|
|
141
|
+
|
|
142
|
+
Runtime enrichment uses curated source names and mappings in:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
src/it_pcap_triage/data/reference_catalog.yml
|
|
146
|
+
src/it_pcap_triage/data/security_mappings.yml
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This avoids redistributing third-party documents and keeps the report clear about which public framework or document each recommendation is based on.
|
|
150
|
+
|
|
151
|
+
The report references documents by name, section/control/technique and URL where applicable, for example:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
NIST SP 800-52 Rev.2
|
|
155
|
+
NIST SP 800-81 Rev.3
|
|
156
|
+
NIST SP 800-41 Rev.1
|
|
157
|
+
CIS Controls v8.1
|
|
158
|
+
MITRE ATT&CK Enterprise
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Local development
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
git clone https://github.com/h0ek/it-pcap-triage.git
|
|
165
|
+
cd it-pcap-triage
|
|
166
|
+
|
|
167
|
+
python3 -m venv .venv
|
|
168
|
+
source .venv/bin/activate
|
|
169
|
+
|
|
170
|
+
pip install -e .
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Run locally:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
it-pcap-triage check
|
|
177
|
+
it-pcap-triage analyze samples/test.pcapng --out out/test-report
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Limitations
|
|
181
|
+
|
|
182
|
+
This is a triage tool, not a SIEM, permanent IDS sensor or full forensic platform.
|
|
183
|
+
|
|
184
|
+
Findings such as DNS tunneling, beaconing, lateral movement or ransomware-like behavior are indicators and require validation.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "it-pcap-triage"
|
|
7
|
+
version = "0.6"
|
|
8
|
+
description = "Offline IT PCAP analyzer using Zeek, Suricata and tshark."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Hoek" }
|
|
13
|
+
]
|
|
14
|
+
license = { text = "MIT" }
|
|
15
|
+
dependencies = [
|
|
16
|
+
"PyYAML>=6.0.1",
|
|
17
|
+
"Jinja2>=3.1.3"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
it-pcap-triage = "it_pcap_triage.cli:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["src"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
it_pcap_triage = [
|
|
28
|
+
"report/templates/*.html",
|
|
29
|
+
"data/*.yml"
|
|
30
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .engines.zeek import run_zeek
|
|
7
|
+
from .engines.suricata import run_suricata
|
|
8
|
+
from .engines.tshark import run_tshark_summary
|
|
9
|
+
from .parsers.zeek_logs import load_zeek_logs
|
|
10
|
+
from .parsers.suricata_eve import load_eve, split_eve
|
|
11
|
+
from .parsers.tshark_stats import load_tshark_summary
|
|
12
|
+
from .detectors.cleartext_auth import detect_cleartext_auth
|
|
13
|
+
from .detectors.insecure_protocols import detect_insecure_protocols
|
|
14
|
+
from .detectors.dns_anomalies import detect_dns_anomalies
|
|
15
|
+
from .detectors.tls_hygiene import detect_tls_hygiene
|
|
16
|
+
from .detectors.windows_auth import detect_windows_auth
|
|
17
|
+
from .detectors.scanning import detect_scanning
|
|
18
|
+
from .detectors.suricata_alerts import detect_suricata_alerts
|
|
19
|
+
from .detectors.exfiltration import detect_large_outbound
|
|
20
|
+
from .scoring.risk import sort_findings, build_host_profiles
|
|
21
|
+
from .report.html import render_report
|
|
22
|
+
from .stats import zeek_network_stats
|
|
23
|
+
from .storage.sqlite_store import EvidenceStore
|
|
24
|
+
from .references import enrich_findings_with_references, load_reference_catalog
|
|
25
|
+
from .utils import ensure_dir, write_json, human_duration
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _stage(label: str) -> None:
|
|
29
|
+
print(label, flush=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def analyze(
|
|
33
|
+
pcap: Path,
|
|
34
|
+
out_dir: Path,
|
|
35
|
+
config: dict,
|
|
36
|
+
suricata_config: str,
|
|
37
|
+
) -> None:
|
|
38
|
+
total_start = time.perf_counter()
|
|
39
|
+
ensure_dir(out_dir)
|
|
40
|
+
|
|
41
|
+
logs_dir = out_dir / "logs"
|
|
42
|
+
engines_dir = out_dir / "engines"
|
|
43
|
+
zeek_dir = engines_dir / "zeek"
|
|
44
|
+
suricata_dir = engines_dir / "suricata"
|
|
45
|
+
tshark_dir = engines_dir / "tshark"
|
|
46
|
+
ensure_dir(logs_dir)
|
|
47
|
+
ensure_dir(engines_dir)
|
|
48
|
+
|
|
49
|
+
run_log = logs_dir / "run.log"
|
|
50
|
+
run_log.write_text("", encoding="utf-8")
|
|
51
|
+
|
|
52
|
+
timings: dict[str, object] = {}
|
|
53
|
+
|
|
54
|
+
_stage("[1/5] Running Zeek behavioral analysis...")
|
|
55
|
+
timings["zeek"] = run_zeek(pcap, zeek_dir, run_log)
|
|
56
|
+
|
|
57
|
+
_stage("[2/5] Running Suricata IDS analysis...")
|
|
58
|
+
timings["suricata"] = run_suricata(pcap, suricata_dir, run_log, suricata_config)
|
|
59
|
+
|
|
60
|
+
_stage("[3/5] Running capture/protocol summary...")
|
|
61
|
+
tshark_timings = run_tshark_summary(pcap, tshark_dir, run_log)
|
|
62
|
+
timings["tshark_summary"] = sum(tshark_timings.values())
|
|
63
|
+
timings["tshark_files"] = tshark_timings
|
|
64
|
+
|
|
65
|
+
_stage("[4/5] Parsing, correlating and storing evidence...")
|
|
66
|
+
parse_start = time.perf_counter()
|
|
67
|
+
zeek = load_zeek_logs(zeek_dir)
|
|
68
|
+
eve = load_eve(suricata_dir / "eve.json")
|
|
69
|
+
eve_by_type = split_eve(eve)
|
|
70
|
+
top_limit = int(config.get("report", {}).get("top_limit", 25))
|
|
71
|
+
tshark_summary = load_tshark_summary(tshark_dir, top_limit=top_limit)
|
|
72
|
+
zeek_stats = zeek_network_stats(zeek, config=config, top_limit=top_limit)
|
|
73
|
+
|
|
74
|
+
findings = []
|
|
75
|
+
findings.extend(detect_cleartext_auth(zeek, eve_by_type, config))
|
|
76
|
+
findings.extend(detect_insecure_protocols(zeek, tshark_summary, config))
|
|
77
|
+
findings.extend(detect_dns_anomalies(zeek, eve_by_type, config))
|
|
78
|
+
findings.extend(detect_tls_hygiene(zeek, eve_by_type, config))
|
|
79
|
+
findings.extend(detect_windows_auth(zeek, config))
|
|
80
|
+
findings.extend(detect_scanning(zeek, config))
|
|
81
|
+
findings.extend(detect_suricata_alerts(eve_by_type, config))
|
|
82
|
+
findings.extend(detect_large_outbound(zeek, config))
|
|
83
|
+
findings = enrich_findings_with_references(sort_findings(findings))
|
|
84
|
+
|
|
85
|
+
hosts = build_host_profiles(zeek, findings, eve_by_type)
|
|
86
|
+
timings["parsing_and_detection"] = time.perf_counter() - parse_start
|
|
87
|
+
|
|
88
|
+
db_path = out_dir / "triage.db"
|
|
89
|
+
if db_path.exists():
|
|
90
|
+
db_path.unlink()
|
|
91
|
+
store = EvidenceStore(db_path)
|
|
92
|
+
store.set_meta("pcap", str(pcap))
|
|
93
|
+
store.set_meta("timings", timings)
|
|
94
|
+
store.insert_reference_catalog(load_reference_catalog())
|
|
95
|
+
store.insert_stat("tshark_summary", tshark_summary)
|
|
96
|
+
store.insert_stat("zeek_network_stats", zeek_stats)
|
|
97
|
+
for finding in findings:
|
|
98
|
+
store.insert_finding(finding)
|
|
99
|
+
for host in hosts:
|
|
100
|
+
store.insert_host(host)
|
|
101
|
+
for event in eve_by_type.get("alert", []):
|
|
102
|
+
store.insert_suricata_alert(event)
|
|
103
|
+
store.commit()
|
|
104
|
+
store.close()
|
|
105
|
+
|
|
106
|
+
_stage("[5/5] Generating compact report...")
|
|
107
|
+
report_start = time.perf_counter()
|
|
108
|
+
write_json(out_dir / "findings.json", [f.to_dict() for f in findings])
|
|
109
|
+
write_json(out_dir / "hosts.json", [h.to_dict() for h in hosts])
|
|
110
|
+
write_json(out_dir / "summary.json", {
|
|
111
|
+
"pcap": str(pcap),
|
|
112
|
+
"finding_count": len(findings),
|
|
113
|
+
"host_count": len(hosts),
|
|
114
|
+
"timings": timings,
|
|
115
|
+
"tshark_summary": tshark_summary,
|
|
116
|
+
"zeek_network_stats": zeek_stats,
|
|
117
|
+
"evidence_db": str(db_path),
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
render_report(
|
|
121
|
+
out_dir / "report.html",
|
|
122
|
+
pcap,
|
|
123
|
+
findings,
|
|
124
|
+
hosts,
|
|
125
|
+
tshark_summary,
|
|
126
|
+
zeek_stats,
|
|
127
|
+
config,
|
|
128
|
+
timings=timings,
|
|
129
|
+
db_path=db_path,
|
|
130
|
+
)
|
|
131
|
+
timings["report_generation"] = time.perf_counter() - report_start
|
|
132
|
+
timings["total"] = time.perf_counter() - total_start
|
|
133
|
+
|
|
134
|
+
write_json(out_dir / "timings.json", timings)
|
|
135
|
+
|
|
136
|
+
_stage(f"[OK] Analysis completed in {human_duration(timings['total'])}")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
REQUIRED_BINARIES = ["zeek", "suricata", "tshark", "capinfos"]
|
|
9
|
+
|
|
10
|
+
SURICATA_CONFIG_CANDIDATES = [
|
|
11
|
+
"/etc/suricata/suricata.yaml",
|
|
12
|
+
"/usr/local/etc/suricata/suricata.yaml",
|
|
13
|
+
"/usr/share/suricata/suricata.yaml",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def find_binary(name: str) -> str | None:
|
|
18
|
+
return shutil.which(name)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def check_binaries() -> tuple[bool, dict[str, str | None]]:
|
|
22
|
+
results = {binary: find_binary(binary) for binary in REQUIRED_BINARIES}
|
|
23
|
+
return all(results.values()), results
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def find_suricata_config(path: str | None = None) -> tuple[bool, str, str]:
|
|
27
|
+
"""
|
|
28
|
+
Returns:
|
|
29
|
+
ok, path, status
|
|
30
|
+
|
|
31
|
+
status:
|
|
32
|
+
ok
|
|
33
|
+
not_found
|
|
34
|
+
not_file
|
|
35
|
+
not_readable
|
|
36
|
+
"""
|
|
37
|
+
candidates = [path] if path else SURICATA_CONFIG_CANDIDATES
|
|
38
|
+
|
|
39
|
+
for candidate_raw in candidates:
|
|
40
|
+
if not candidate_raw:
|
|
41
|
+
continue
|
|
42
|
+
|
|
43
|
+
candidate = Path(candidate_raw)
|
|
44
|
+
|
|
45
|
+
if not candidate.exists():
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
if not candidate.is_file():
|
|
49
|
+
return False, str(candidate), "not_file"
|
|
50
|
+
|
|
51
|
+
if not os.access(candidate, os.R_OK):
|
|
52
|
+
return False, str(candidate), "not_readable"
|
|
53
|
+
|
|
54
|
+
return True, str(candidate), "ok"
|
|
55
|
+
|
|
56
|
+
fallback = path or SURICATA_CONFIG_CANDIDATES[0]
|
|
57
|
+
return False, fallback, "not_found"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def check_suricata_config(path: str | None = None) -> tuple[bool, str]:
|
|
61
|
+
ok, config_path, _status = find_suricata_config(path)
|
|
62
|
+
return ok, config_path
|