Last active
December 10, 2019 19:21
-
-
Save netscylla/1bd174f6d64138243f4fcfdf67ad05b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 python3 | |
# | |
# Quick hack to anonymise pcap for distribution to 3rd parties for vendor debugging | |
# (c)2019 Andy @ Netscylla | |
# | |
from scapy.all import * | |
from scapy.utils import rdpcap,wrpcap | |
my_mac1="00:0c:29:fc:25:be" | |
my_mac2="00:0c:29:25:24:17" | |
my_ip1='10.1.1.1' | |
my_ip2='10.1.1.2' | |
pkts=rdpcap("/tmp/test.pcap") | |
for pkt in pkts: | |
if pkt['Ethernet'].dst == my_mac1: | |
pkt['Ethernet'].dst = "aa:aa:aa:bb:bb:bb" | |
if pkt['Ethernet'].src == my_mac2: | |
pkt['Ethernet'].src = "aa:aa:aa:cc:cc:cc" | |
if pkt['Ethernet'].src == my_mac1: | |
pkt['Ethernet'].src = "aa:aa:aa:bb:bb:bb" | |
if pkt['Ethernet'].dst == my_mac2: | |
pkt['Ethernet'].dst = "aa:aa:aa:cc:cc:cc" | |
if pkt['IP'].proto == (6 ||17): | |
if pkt["IP"].src == my_ip1: | |
pkt["IP"].src ="172.16.1.1" | |
if pkt["IP"].dst ==my_ip2: | |
pkt["IP"].dst ="172.16.1.2" | |
if pkt["IP"].dst ==my_ip1: | |
pkt["IP"].dst ="172.16.1.1" | |
if pkt["IP"].src ==my_ip2: | |
pkt["IP"].src ="172.16.1.2" | |
wrpcap("/tmp/test-mod.pcap",pkts) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment