Git Product home page Git Product logo

pcap-parser's Introduction

Pcap Parser

Python utility to parse pcap files and extract flow-related information from them.

Getting started:

This utility requires macOS. You need to have Python 3 installed.

Also make sure to have Wireshark installed on your macOS.

Set up the environment:

$ python3 -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt

Run the parser:

To parse individual pcap files:

$ python parse.py <output_csv_file> <path_to_pcap_file>

To parse all pcap files in a directory:

$ python parse.py <output_csv_file> <directory_containing_pcap_files>

pcap-parser's People

Contributors

billfitzgerald avatar crazyideas21 avatar rameen-mahmood avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

billfitzgerald

pcap-parser's Issues

handle pcap from ARP spoofing

If you have captured packets with tcpdump while IoT Inspector is running, you'll see duplicate packets to and from the Inspector-running host. Here's an example of what you would expect:

Let's say you're running IoT Inspector on a host with the mac address H. You're capturing packets between a device with mac address D and the Internet. The gateway has a mac address of G. On H, you're running tcpdump. You will NOT see packets between D and G. If there's a packet from D to G, you'll see two packets in the capture:

  • From D to H (in the Ethernet header)
  • From H to G (in the Ethernet header)

Currently, this parser cannot handle the situation above. Users of this parser would have to manually identify and de-duplicate these packets.

I think @Rameen-Mahmood is one of the primary users of this script. Just make sure to handle this issue.

label more IPs with hostnames

The current version labels IPs with hostnames obtained from DNS and SNI (assuming TLS 1.2). However, there are still cases where the src_hostname or dst_hostname fields are empty, because the parser didn't see any corresponding IP-hostname mappings from DNS and SNI.

Here's one thing the user (say @Rameen-Mahmood) can do to mitigate this issue: Instead of parsing one pcap at a time, you can capture a bunch of pcaps (e.g., repeated experiments from the same app, or running tcpdump on multiple apps) and run this parser on the pcaps at the same time (e.g., python parser.py output.csv *.pcap). In this way, the parser can use DNS/SNI information extracted from one pcap and apply this IP-hostname mapping to other pcaps.

Still, I'd expect a number of IPs with no hostname labels. What I can do to mitigate this situation would be:

  • query against a private passive DNS API to turn these IPs into hostnames (although this process could be error-prone especially if the IPs are on shared infrastructure)
  • find the reverse DNS data (i.e., PTR records) for unlabeled IP addresses (although this process is moot in cases where the PTR records simply correspond to the IP address, e.g., the PTR record of 54.156.150.34 is ec2-54-156-150-34.compute-1.amazonaws.com, which is not useful and you could have used the IP address instead)

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.