Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import logging
from scapy.all import *
from json import dumps
from sys import argv
if len(argv) < 2:
print 'Usage:\n\t%s <your.pcap>' % (argv[0])
packet_data = rdpcap(argv[1])
formatted_objs = []
for packet in packet_data:
packet_obj = {}
if Raw in packet:
packet_obj['load'] = packet[Raw].load
if IP in packet:
packet_obj['source_addr'] = packet[IP].src
packet_obj['dest_addr'] = packet[IP].dst
if TCP in packet:
packet_obj['source_port'] = packet[TCP].sport
packet_obj['dest_port'] = packet[TCP].dport
print dumps(formatted_objs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment