Created
September 17, 2022 18:22
-
-
Save Rgghgh/03e060579bdc910d14acce81d177b4de 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
| from scapy.all import * | |
| from scapy.utils import PcapWriter | |
| packets = rdpcap('cap.pcap') | |
| new_cap = PcapWriter("cap_new.pcap") | |
| # old: new | |
| mapping = { | |
| '203.76.192.10': '1.1.1.1' | |
| } | |
| #replace orinigal address | |
| for p in packets: | |
| if (p[IP].src in mapping): | |
| p[IP].src = mapping[p[IP].src] | |
| if (p[IP].dst in mapping): | |
| p[IP].dst = mapping[p[IP].dst] | |
| new_cap.write(p) | |
| wrpcap("cap_new.pcap", packets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment