Created
May 11, 2015 21:40
-
-
Save jlongman/24deb2f8aaef1d2afa30 to your computer and use it in GitHub Desktop.
dpkt GRE stripping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Extracts IP content from GRE and writes to arg[1].out | |
# Drops non GRE | |
# requires dpkt gre patch | |
import dpkt | |
import sys | |
fin = open(sys.argv[1]) | |
fout = open(sys.argv[1] + ".out", "w") | |
pcap = dpkt.pcap.Reader(fin) | |
pcapout = dpkt.pcap.Writer(fout) | |
frame_counter = 0 | |
for ts, buf in pcap: | |
eth = dpkt.ethernet.Ethernet(buf) | |
ip = eth.data | |
if ip.p == 47: | |
payload = ip.data.data | |
inner_ip = payload.data | |
eth.data = inner_ip | |
pcapout.writepkt(eth) | |
fin.close() | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment