Skip to content

Instantly share code, notes, and snippets.

@ph1ee
Last active April 23, 2021 08:18
Show Gist options
  • Save ph1ee/e1e365cde2a3ea99967723215fac22ea to your computer and use it in GitHub Desktop.
Save ph1ee/e1e365cde2a3ea99967723215fac22ea to your computer and use it in GitHub Desktop.
Remove the exported PDU layer and replace the IPv6 source/destination addresses from a pcap file
#!/usr/bin/env python3
import sys
from scapy.utils import rdpcap, wrpcap
from scapy.all import IPv6, UDP
def main():
packets = []
for exported_pdu in rdpcap(sys.argv[1]):
pkt = IPv6(exported_pdu.load[52:])
pkt.time = exported_pdu.time
pkt[IPv6].src = sys.argv[3]
pkt[IPv6].dst = sys.argv[4]
del pkt[IPv6][UDP].chksum
packets.append(pkt)
wrpcap(sys.argv[2], packets)
sys.exit(0)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment