Skip to content

Commit 92166f1

Browse files
jmwampleewust
andauthored
Anonymizing Packet Capture tool for Conjure (#168)
* captool working for pcap from file source * Remove lifetimes from PacketHandler * Split interfaces / read pcap dir into functions * Capture from interfaces * runs with interface * limits seem to be working. need a bit more live testing * termation handler fix and write gzipped * disable error logging for common errors * bug fixes and error handling instead of unwrap within threads. panics == bad * seemss to work for Eth and IP packets, adding better test next * unit tests working for Eth and IPvX link types * support raw linktype for tun interfaces * handling funky link layer types for tun interfaces * anonymize ipv6 flow label and add cli opt for v4 / v6 only * flow tracking WIP * WIP fixing issues and adding flow tracking * flow tracking passing tests, integration next * cautously optimistic - integration compiling, tests succeeding * fixed timestamp issue, flow tracking integration complete, tests passing * help messages for cli args * change cli arg name * default log level in release to warn and err on empty targets --------- Co-authored-by: Eric Wustrow <[email protected]>
1 parent 9fdfe9d commit 92166f1

File tree

9 files changed

+2749
-0
lines changed

9 files changed

+2749
-0
lines changed

util/captool/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "captool"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
9+
[dependencies]
10+
pcap = "1.0.0"
11+
maxminddb = "0.23.0"
12+
ipnet = "2.7.2"
13+
threadpool = "1.8.1"
14+
pnet = "0.33.0"
15+
hmac = "0.12.1"
16+
sha2 = "*"
17+
rand = "0.8.5"
18+
pcap-file = "2.0.0"
19+
clap = { version = "4.2.2", features = ["derive"] }
20+
signal-hook = "0.3.15"
21+
flate2 = "1.0.25"
22+
log = "0.4.17"
23+
simple_logger = "4.1.0"
24+
25+
[dev-dependencies]
26+
tempfile = "3.5.0"
27+
byteorder_slice = "3.0.0"
28+
hex = "0.4.3"

util/captool/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Packet Capture Tool
2+
3+
This packet capture tool allows us to rapidly capture and anonymize packets
4+
for flow analysis in relation to conjure stations.
5+
6+
This requires that the tool:
7+
8+
- read from multiple sources in parallel
9+
- has access to GeoIP2 mmdbs to look up Country and ASN info
10+
- deteministically anonymize client IPs and ports.
11+
- write pcapng format with supplemental ASN/CC/subnet info in optional comments
12+
13+
Address anonymization is done by first determining what the addresses parent
14+
subnet allocation is. We then replace the client address with a deterministically
15+
chosen random addres by filling the host mask with bytes from an HMAC of the
16+
flow tuple. we do the same for client ports. This allows us to ensure that the
17+
separate packets within the same flow will still be linked, without
18+
client-identifying information.
19+
20+
The Key for the HMAC is generated at runtime from the system CSPRNG and never
21+
written to disk, only being stored in memory during the capture.
22+
23+
---
24+
25+
## Capture Parameters
26+
27+
Flows are captured from first SYN for TCP and from first seen for UDP.

util/captool/rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"

0 commit comments

Comments
 (0)