Skip to main content

SharkReduce 🦈🔻

Utility to convert wireshark captures to useful datasets.

Installation

pip install sharkreduce

Steps to create reduced dataset

Step 1: Export capture using tshark

tshark -t e -Ndmnt -r all.pcapng -T fields \
  -e frame.time \
  -e eth.src_resolved \
  -e eth.dst_resolved  \
  -e _ws.col.Source \
  -e _ws.col.Destination \
  -e _ws.col.Protocol \
  -e tcp.len \
  -e udp.length \
  -e tcp.srcport \
  -e tcp.dstport \
  -e udp.srcport \
  -e udp.dstport \
  -e _ws.col.Time '(eth.type == 0x800) or (eth.type == 0x86dd)' > reduceme.tsv

Step 2: Fill device id file

Sharkreduce requires a device mac-address map file to create pretty reduced output.

Run it once to pre-fill the file with all mac IDs from your capture:

python3 -m sharkreduce -t 60000000 -n devices.yaml reduceme.tsv reduced.tsv

Note: -t 60000000 means that SharkReduce will create reduced bins of connections up to 60 seconds.

Note: The command will initially create an empty reduced.tsv!

The command will create a file called devices.yaml which looks like this:

devices: []
ignore: {}
unclassified:
  some-mac-adress:
    - dns-name
    - ip-adress
    - etc.

For each unclassified mac address, you will see some aliases (IP/Hostname) which helps you to determine which device the MAC belongs to.

If the MAC belongs to a device you want to analyse, think of a good name and create an entry under devices. Otherwise create an entry under ignored. Do this for all unclassified MACs:

devices:
  SuspiciousDevice:
    - some-mac-address
    - some-hostname
  OtherInterestingDevice:
    - other-mac
ignore:
  - router-mac-address
  - broadcast address

Step 3: Create initial reduced output.

Re-run

python3 -m sharkreduce -t 60000000 -n devices.yaml reduceme.tsv reduced.tsv

This time reduced.tsv should have a lot of data in it, with device identifiers that look very readable to you.

Step 4: Create/fill activity file

In order to determine activity periods for your devices to correctly fill the active_use column in the reduced output, you have to create an activity file. You can initialise the file like this:

python3 -m sharkreduce --init-activity -t 3600000000 -n devices.yaml reduceme.tsv reduced.tsv

This will READ from reduced.tsv to create a file called activity.yaml, where you can annotate your activity per device in ~1h intervals.

Set the active field to True where you think you have been actively using the device.

Step 5: Re-run sharkreduce with filled activity file

If it exists, sharkreduce will use the content of activity.yaml to fill the active_use column. So you just need to re-run ...

python3 -m sharkreduce -t 60000000 -n devices.yaml reduceme.tsv reduced.tsv

Note: If you change the devices.yaml you have to re-do steps 3, 4 and 5.

Step 6: Party! 🥳

Your pretty reduced capture with annotated device names and activity is now stored under reduced.tsv.

Release files for sharkreduce 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharkreduce 0.2.0
File Size Uploaded
sharkreduce-0.2.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharkreduce 0.2.0
File Interpreter ABI Platform
sharkreduce-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / sharkreduce-0.2.0.tar.gz

Download URL sharkreduce-0.2.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f13ae3c3ee99838849c1f48687b710e9b7b7638baf64aa2ddf4a857d4f90fbdf
BLAKE2b-256 checksum
How to use checksums
219a4fc2bc5d97363f7338e70065edb1ac7f92bbed086f9b6fe24e4e81a6056f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release files / sharkreduce-0.2.0-py3-none-any.whl

Download URL sharkreduce-0.2.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba80f57dc31145a35a2cbabed7df1a78d2fab1417ff95b087605af0c06be43be
BLAKE2b-256 checksum
How to use checksums
fb79aeccc634f2ffe0c89a5994488011b8d95e67c973d17ebda16c2f44527c27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page