Created
April 10, 2019 00:13
-
-
Save rofl0r/e935cae71f7c9f418348803b2b0394a2 to your computer and use it in GitHub Desktop.
replaces all occurences of a specified mac address in a pcap file with a random new one
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
import sys, os | |
def usage(): | |
print "usage: %s file.pcap AA:BB:CC:DD:EE:FF"%sys.argv[0] | |
print "where AA:BB:CC:DD:EE:FF is the mac address you want replaced" | |
sys.exit(1) | |
if len(sys.argv) < 3: usage() | |
file_arg = sys.argv[1] | |
mac_arg = sys.argv[2] | |
mac = mac_arg.replace(':', '').decode('hex') | |
assert(len(mac) == 6) | |
new_mac = os.urandom(6) | |
with open(file_arg, "r") as h: fc = h.read() | |
with open(file_arg, "w") as h: h.write(fc.replace(mac, new_mac)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment