Code Monkey home page Code Monkey logo

sanicap's Introduction

Sanicap

A python based packet capture sanitizer

Features

  • Clean your pcaps for worry-free sharing
  • Can randomize/sequentialize:
    • MAC addresses
    • IPv4/IPv6 addresses
  • Override VLAN number
  • Integrates with scapy, pyshark, cloud-pcap

Installation

  • A setup.py file is coming soon. For now, copy to directory of your project.
  • to build a docker container, check out this repository and then run docker build -t sanicap in the top level directory.

Usage

In another python script

>>> from sanicap import sanitize
>>> sanicap.sanitize('/path/to/test.pcap', sequential=True, ipv4_mask=8, ipv6_mask=16)
This file has 23 IPv4/IPv6 endpoints and 6 MAC endpoints
File created: /path/to/test_sanitized_141205-124237.pcap

As a CLI utility

The examples below use the docker container, but this would also work if the dependencies in requirements.txt are installed directly on your system.

Help:

$ docker run -ti sanicap -h
usage: sanicap.py [-h] [-o FILEPATH_OUT] [-s SEQUENTIAL] [-a APPEND] [--ipv4mask IPV4MASK] [--ipv6mask IPV6MASK]
                  [--macmask MACMASK] [--startipv4 STARTIPV4] [--startipv6 STARTIPV6] [--startmac STARTMAC]
                  [--fixedvlan FIXEDVLAN]
                  filepath_in

positional arguments:
  filepath_in           The pcap file to sanitize.

optional arguments:
  -h, --help            show this help message and exit
  -o FILEPATH_OUT, --filepath_out FILEPATH_OUT
                        File path to store the sanitized pcap.
  -s SEQUENTIAL, --sequential SEQUENTIAL
                        Use sequential IPs/MACs in sanitization.
  -a APPEND, --append APPEND
                        Append to, instead of overwriting output file..
  --ipv4mask IPV4MASK   Apply a mask to sanitized IPv4 addresses (Eg. mask of 8 preserves first octet).
  --ipv6mask IPV6MASK   Apply a mask to sanitized IPv6 addresses (Eg. mask of 16 preserves first chazwazza).
  --macmask MACMASK     Apply a mask to sanitized IPv6 addresses (Eg. mask of 24 preserves manufacturer).
  --startipv4 STARTIPV4
                        Start sequential IPv4 sanitization with this IPv4 addresses.
  --startipv6 STARTIPV6
                        Start sequential IPv6 sanitization with this IPv6 addresses.
  --startmac STARTMAC   Start sequential MAC sanitization with this MAC addresses.
  --fixedvlan FIXEDVLAN
                        Overwrite VLANID (fixed)

    usage: sanicap.py [-h] [-o FILEPATH_OUT] [-s SEQUENTIAL] [--ipv4mask IPV4MASK]
                      [--ipv6mask IPV6MASK] [--macmask MACMASK]
                      [--startipv4 STARTIPV4] [--startipv6 STARTIPV6]
                      [--startmac STARTMAC]
                      filepath_in

Example:

$ docker run -ti -v $(pwd):/data sanicap /data/test.pcap -o /data/out.pcap -s True --ipv4mask=8
This file has 85 IPv4/IPv6 endpoints and 38 MAC endpoints
File created: /data/out.pcap

ToDo

  • Add pcapng support
  • standalone CLI usage
  • Anonymize DNS Queries
  • Anonymize HTTP host info
  • Anonymize HTTP data? (not sure what yet, maybe just POST data)
  • python BPF capture filter (apply to pcap files)

sanicap's People

Contributors

simeonmiteff avatar thepacketgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.