anoncap reference
anoncap is a standalone pcap/pcapng anonymizer built on Wireshark's capture and dissector stack. It rewrites supported identifiers, strips sensitive capture metadata, and writes an anonymized capture that remains useful for troubleshooting and sharing.
PacketSafari uses the same engine and adds managed upload, sibling capture handling, mapping lookup, AI-policy integration, and the private DeepAnon rules profile. For the product workflow, see Anoncap in PacketSafari.
Name
anoncap - anonymize packet captures while preserving protocol structure.
Synopsis
anoncap [options] <input> [output]
anoncap -r <input> [-w <output>] [options]
anoncap --batch [options]
anoncap --batch-coherent [options]
anoncap --write-default-rules <path>
anoncap --explain-defaults
If you pass only an input path, anoncap writes <input-stem>-anon.pcapng next to the source capture. Existing output paths are refused unless --overwrite is set.
Download
Latest public release assets:
The assets are runnable bundles containing the binary, required shared libraries, public baseline rules, and checksums. They are not single naked binary files.
Linux:
wget https://github.com/oripka/wireshark/releases/latest/download/anoncap-linux-x64.tar.gz
tar -xzf anoncap-linux-x64.tar.gz
cd anoncap
./bin/anoncap --version
macOS Apple silicon:
curl -L -o anoncap-macos-arm64.tar.gz https://github.com/oripka/wireshark/releases/latest/download/anoncap-macos-arm64.tar.gz
tar -xzf anoncap-macos-arm64.tar.gz
cd anoncap
./bin/anoncap --version
macOS Intel:
curl -L -o anoncap-macos-x64.tar.gz https://github.com/oripka/wireshark/releases/latest/download/anoncap-macos-x64.tar.gz
tar -xzf anoncap-macos-x64.tar.gz
cd anoncap
./bin/anoncap --version
Windows PowerShell:
Invoke-WebRequest `
-Uri "https://github.com/oripka/wireshark/releases/latest/download/anoncap-windows-x64.zip" `
-OutFile "anoncap-windows-x64.zip"
Expand-Archive .\anoncap-windows-x64.zip -DestinationPath .
Set-Location .\anoncap
.\bin\anoncap.exe --version
The macOS and Windows bundles are unsigned. If the OS blocks the binary after download, allow it according to your local security policy, then rerun --version before processing captures.
Quick Start
./bin/anoncap input.pcapng
Equivalent explicit public-share forms:
./bin/anoncap --public-share input.pcapng
./bin/anoncap --nano-trace input.pcapng
Choose an output path:
./bin/anoncap -r input.pcapng -w output-anon.pcapng
./bin/anoncap input.pcapng output-anon.pcapng
Inspect the release defaults:
./bin/anoncap --explain-defaults
Run the slower audit preset:
./bin/anoncap --paranoid input.pcapng --report anon.report.json
Default Behavior
The default profile is the public-share profile. It is designed for common public trace sharing where L7 payload bytes should be reduced while network and troubleshooting structure stays readable.
Current defaults:
- anonymizes L2-L4 identifiers, including MAC, ARP-linked values, IPv4, IPv6, TCP/UDP-adjacent fields, ICMP, DHCP, DNS, safe HTTP/HTTP2 host fields, TLS SNI, and X.509 DNS names where supported
- preserves broad topology shape: RFC1918, loopback, link-local, multicast, IPv6 ULA/link-local/multicast classes, IPv4 subnet shape, IPv6 prefix shape, and MAC OUI shape
- uses deterministic mappings within one run
- strips sensitive pcapng metadata by default: comments, name-resolution blocks, decryption secrets, application/OS strings, interface metadata, and address info
- preserves packet count, timestamps, interface linkage, and supported headers
- performs boundary-only adaptive packet slicing by default
- does not use a fixed 256-byte target unless you explicitly request a fixed
--snaplen - keeps unknown top-level encapsulations whole rather than cutting at a guessed boundary
- does not run redissection validation or leak verification unless requested
- prints a concise stderr summary after successful runs
Default adaptive slicing preserves supported nested/tunnel and quote headers before truncating later payload bytes. Current public coverage includes GRE, TEB/Ethernet-in-GRE, ERSPAN, IP-in-IP, IPv6-in-IP, VXLAN, VXLAN-GPE, Geneve, GTP-U/GTPv2 UDP payloads, L2TP, Teredo, ICMP/ICMPv6 quoted packets, PPPoE, MPLS, NSH, and inner L3/L4 headers.
Options
Input and output
| Option | Meaning |
|---|---|
-r <path> | Input capture path. |
-w <path> | Output capture path. Defaults to <input-stem>-anon.pcapng when omitted. |
<input> [output] | Positional equivalent for simple runs. |
-- | Stop option parsing. Later arguments are treated as positional paths. |
--overwrite | Allow replacing an existing output path. Without this, existing outputs are refused. |
-h, --help | Print help and exit. |
-v, --version | Print version info and exit. |
Presets
| Option | Meaning |
|---|---|
--public-share | Explicitly select the default public-share profile. |
--nano-trace | Alias for --public-share. It is shorter, not a different mode. |
--paranoid | Enable validation, leak scanning, coverage scan, uncovered-field warnings, and verification-failure explanations together. |
--explain-defaults | Print the current default profile details and exit. Takes no input or output path. |
Rules and forced values
| Option | Meaning |
|---|---|
--rules <path> | Load a rules JSON file instead of the discovered/default built-in rules. |
--write-default-rules <path> | Write the built-in public rules JSON and exit. Takes no input or output path. |
--params <path> | Read line-based sensitive values and force those values through payload scrubbing. |
--params-anon-out <path> | Write anonymized values corresponding to --params, one per line. |
--map-out <path> | Write anonymization mapping report JSON. |
Batch modes
| Option | Meaning |
|---|---|
--batch | Batch-anonymize capture files in the current directory to *-anon.pcapng. |
--batch-coherent | Batch-anonymize with one shared mapping context across the sorted fileset. Use this for dumpcap ring buffers and multi-point captures that need consistent replacements across files. |
--recursive | Recurse subdirectories in batch mode. Requires --batch or --batch-coherent. |
--batch launches separate processing per file and does not guarantee coherent mappings across files. --batch-coherent keeps one mapping context across all files in the run.
Batch modes process regular .pcap, .pcapng, and .cap files. Entries whose name contains -anon are skipped so anonymized siblings are not reprocessed. Files are scanned in sorted order, and outputs are named <input-stem>-anon.pcapng.
Plain --batch does not support --map-out, --report, or --diagnostics-out. --batch-coherent supports --map-out, but does not support --report, --diagnostics-out, --display-filter, --safe-diagnostics, or --pdml.
Payload reduction
| Option | Meaning |
|---|---|
--unsupported-payload-policy keep | Keep unsupported payload bytes. This disables default packet slicing unless --snaplen is supplied. |
--unsupported-payload-policy truncate | Truncate to the fixed --snaplen boundary. |
--unsupported-payload-policy adaptive-truncate | Truncate at the adaptive safe header boundary. This is the public-share default. |
--unsupported-payload-policy zero-after-boundary | Keep packet length but zero bytes after the selected boundary. |
--snaplen <bytes> | Add a fixed packet slicing floor. Adaptive mode may preserve more than this when needed for supported headers. |
--adaptive-snaplen | Preserve nested tunnel/L3/L4 headers before truncating. This is already the default slicing policy. |
--no-force-generic-payload-rewrite | Skip the default same-length generic L4 payload cleanup pass. |
--drop-transport-only | For undecoded TCP/UDP packets not later reassembled, replace bare transport payloads with a visible same-length sanitized marker. |
Invalid combinations are rejected. For example, --unsupported-payload-policy keep cannot be combined with --snaplen or --adaptive-snaplen, because keep means no slicing unless a separate fixed policy is chosen.
Validation and leak checks
| Option | Meaning |
|---|---|
--validate | Reopen the anonymized output and redisect modified packets after write. This can be slow on large captures. |
--verify-leaks | Scan output payloads for leaked original values from the replacement set. |
--coverage-scan | Emit coverage diagnostics for unanonymized fields. |
--flag-unanonymized-fields | Promote uncovered fields to warnings. |
--explain-verify-failures | Emit safe failure/skip context for forced rewrite and leak-check decisions. |
--show-leaked-values | Include leaked original values in leak diagnostics. Use only in controlled local debugging. |
Reports and machine-readable output
| Option | Meaning |
|---|---|
--report <path> | Write summary report JSON. Includes packet, slicing, payload-byte, validation, leak-scan, and audit-policy state. |
--diagnostics-out <path> | Write diagnostics as JSONL. |
--safe-diagnostics | Print safe structural diagnostics to stdout. |
--display-filter | Print a leak-check display filter to stdout. |
--pdml | Write anonymized PDML to stdout instead of a normal capture output workflow. |
RTP media scrub
| Option | Meaning |
|---|---|
--rtp-silence-replacement | Replace supported RTP voice payloads with codec-valid silence. Current support targets RTP v2 over UDP with static G.711 payload types 0 PCMU and 8 PCMA. It preserves RTP sequence, timestamp, SSRC, payload type, payload length, packet count, and timing. |
Broad dynamic-payload codec replacement, video RTP, Opus, AMR, G.729, and SRTP-aware media handling are not the current public guarantee.
Progress and debugging
| Option | Meaning |
|---|---|
--progress | Show phase-aware progress on stderr. This is the default. |
--no-progress, -no-progress | Disable phase-aware progress output. |
--debug-spans | Emit span-level diagnostics. |
--debug-raw-values | Allow raw values in debug logs. Use only in controlled local debugging. |
Exit Behavior
anoncap returns non-zero for malformed input, invalid rules, unsupported required transforms, output conflicts, validation failure, leak-check failure under the active policy, and other processing failures. It refuses to overwrite existing output paths unless --overwrite is supplied.
Output Artifacts
| Artifact | How to create it |
|---|---|
| anonymized capture | default output path, positional output, or -w |
| mapping report | --map-out anon.map.json |
| summary report | --report anon.report.json |
| diagnostics JSONL | --diagnostics-out anon.diag.jsonl |
| anonymized forced-value list | --params-anon-out anonymized-values.txt |
| default public rules JSON | --write-default-rules anoncap-rules.json |
| leak-check display filter | --display-filter |
| anonymized PDML | --pdml |
Examples
Default public-share run:
./bin/anoncap input.pcapng
Explicit output:
./bin/anoncap -r input.pcapng -w output-anon.pcapng
Audit run:
./bin/anoncap \
--paranoid \
input.pcapng \
--report anon.report.json \
--diagnostics-out anon.diag.jsonl \
--map-out anon.map.json
Coherent dumpcap fileset:
cd capture-fileset
../anoncap/bin/anoncap --batch-coherent --recursive --map-out anoncap-map.json
Fixed slicing floor:
./bin/anoncap input.pcapng output-sliced.pcapng --snaplen 512
Zero payload tail after the selected boundary:
./bin/anoncap input.pcapng output-zero-tail.pcapng \
--snaplen 256 \
--unsupported-payload-policy zero-after-boundary
Keep full payload bytes for a custom/deep rules profile:
./bin/anoncap input.pcapng output-deep.pcapng \
--rules anoncap-rules.json \
--unsupported-payload-policy keep
Forced sensitive-value scrub:
./bin/anoncap input.pcapng output-anon.pcapng \
--params sensitive-values.txt \
--params-anon-out anonymized-values.txt
RTP G.711 silence replacement:
./bin/anoncap input.pcapng output-rtp-silence.pcapng \
--rtp-silence-replacement \
--unsupported-payload-policy keep
Rules JSON
Rules JSON lets you extend or replace the built-in public profile. The current shipped model is intentionally field-oriented: match a Wireshark field abbreviation, classify the value shape, and choose the narrowest compatible transform.
Minimal file:
{
"rule_sets": [
{
"id": "custom",
"rules": [
{
"id": "diameter-origin-host",
"enabled": true,
"match": {
"kind": "field_exact",
"value": "diameter.Origin-Host"
},
"transform": {
"kind": "shape_preserving_hostname"
}
}
]
}
]
}
Top-level keys
| Key | Type | Meaning |
|---|---|---|
rule_sets | array | Required. Contains enabled rules grouped into rule sets. |
failure_policy.mode | string | Optional. best_effort disables fail-closed behavior for supported rule failures. Omit for the safer default. |
metadata_policy | object | Optional pcapng metadata preservation policy. |
diagnostics_policy | object | Optional diagnostics defaults. |
validation_policy.enabled | boolean | Optional. Enables redissection validation unless already enabled on the CLI. |
transform_policy | object | Optional topology/shape preservation policy for address transforms. |
advanced_helpers | object | Optional protocol-helper switches. Mostly useful for curated/private profiles. |
prime_fields | array | Optional field abbreviations to prime during dissection. |
sip_payload_signatures, sip_payload_needles, sip_line_prefixes, sip_header_restore_markers, sip_private_header_prefixes | arrays | Optional SIP payload helper configuration for advanced profiles. |
diameter_target_fields, diameter_safe_direct_text_fields, diameter_hostname_text_fields | arrays | Optional Diameter helper field sets for advanced profiles. |
sip_generated_header_map | array | Optional advanced SIP mapping from generated field abbreviation to literal SIP header name. |
sip_header_rules | array | Optional advanced SIP header handling rules with name, field, and handler. |
The built-in public rules can be exported with:
./bin/anoncap --write-default-rules anoncap-rules.json
If --rules is omitted, anoncap first looks for anoncap-rules.json in the current working directory, then ./anoncap-rules.json, and then falls back to the built-in public rules JSON compiled into the binary.
Rule sets and rules
Each rule entry supports:
| Key | Required | Meaning |
|---|---|---|
id | recommended | Stable human-readable rule id. |
enabled | no | Defaults to true. Set false to disable the rule. |
match.kind | yes | Match strategy. Current practical values are field_exact and field_type. |
match.value | yes | Field abbreviation or field type string, depending on match.kind. |
transform.kind | yes | Transform to apply. |
transform.mask_character | only for masked_text | First character is used as the mask byte/character. Defaults to x. |
Use field_exact for normal authoring. It matches one exact Wireshark field abbreviation such as ip.src, tls.handshake.extensions_server_name, or diameter.Origin-Host.
Transform kinds
| Transform | Use for |
|---|---|
pseudonymize_ipv4 | IPv4 fields and IPv4 AVPs/IEs. |
pseudonymize_ipv6 | IPv6 fields and IPv6 AVPs/IEs. |
pseudonymize_mac | MAC/EUI fields. |
pseudonymize_uint | Numeric identifiers such as TEIDs, UE IDs, and other fixed-size integer IDs. |
pseudonymize_bytes | Raw byte identities where byte length must be preserved. |
pseudonymize_plmn | MCC/MNC or PLMN-like values. |
pseudonymize_imsi | IMSI values. |
pseudonymize_msisdn | MSISDN / phone-number-like subscriber identifiers. |
pseudonymize_imei | IMEI / IMEISV / MEI-like device identifiers. |
rewrite_network_name | Network-name-like values such as APN/DNN where supported. |
shape_preserving_hostname | Hostnames, realms, FQDNs, APNs, DNNs, SNI, and DNS-like names where the encoding is supported. |
shape_preserving_text | General structured text identifiers. |
masked_text | Same-length masking with transform.mask_character. |
zero_fill | Same-length zero fill for compatible fields. |
infer_by_identifier | Mixed text/digit/identifier values where anoncap should choose a safer internal family. |
Rules alone are usually enough only when the field owns a patchable packet byte span and the encoding is already supported. Label-encoded names, TBCD identifiers, UTF-16 strings, reassembled payload ownership, generated fields, and packet-level fallbacks can require engine support in addition to a JSON rule.
Metadata policy
{
"metadata_policy": {
"preserve_name_resolution": false,
"preserve_decryption_secrets": false,
"preserve_comments": false,
"preserve_application_metadata": false,
"preserve_interface_metadata": false,
"preserve_address_info": false
}
}
Supported keys:
preserve_name_resolutionpreserve_decryption_secretspreserve_commentspreserve_application_metadatapreserve_interface_metadatapreserve_optional_interface_metadata(alias for interface metadata preservation)preserve_address_info
The public default strips these sensitive/optional metadata classes.
Diagnostics policy
{
"diagnostics_policy": {
"coverage_scan": true,
"flag_unanonymized_fields": true,
"debug_spans": false,
"debug_raw_values": false
}
}
CLI flags can also enable these behaviors. Raw-value diagnostics should only be used in controlled local debugging.
Transform policy
{
"transform_policy": {
"ipv4": {
"preserve_rfc1918_class": true,
"preserve_loopback_class": true,
"preserve_link_local_class": true,
"preserve_multicast_class": true,
"preserve_subnet_shape": true,
"preserve_last_octet_special_cases": true
},
"ipv6": {
"preserve_ula_class": true,
"preserve_link_local_class": true,
"preserve_multicast_class": true,
"preserve_prefix_shape": true
}
}
}
MAC OUI preservation is part of the public default engine behavior. The current public CLI does not expose separate command-line toggles for these topology-preservation settings; use a rules JSON profile when you need policy changes.
Advanced helpers
{
"advanced_helpers": {
"sdp_inline_rewrites": true,
"sip_payload_rewrites": true,
"diameter_value_rewrites": true,
"diameter_unknown_vendor_rewrites": false,
"generic_payload_rewrites": true,
"force_generic_payload_rewrite": true,
"rtp_silence_replacement": false,
"named_value_rewrites": true,
"private_sip_vendor_rewrites": false,
"tel_text_rewrites": true,
"sip_header_restore": true,
"sip_content_length_update": true
}
}
These switches are for curated rules profiles. Do not enable broad helpers casually; protocol-specific helpers can alter payload handling and should be validated on representative captures.
Public vs DeepAnon
The public standalone baseline is conservative. It covers network identifiers, topology-preserving address mapping, safe DNS/DHCP/HTTP/HTTP2/TLS/X.509 name paths, metadata stripping, adaptive slicing, audit switches, and custom rules.
The private PacketSafari / DeepAnon profile is broader and corpus-driven. It adds deeper telecom, enterprise identity, Windows auth/name, mobile-core, RADIUS, SIP/SDP, Diameter, PFCP/GTP/S1AP/NGAP/NAS, and selected OT coverage through a private rules file plus private regression tests.
