Skip to content

Instantly share code, notes, and snippets.

@rofl0r
Created April 10, 2019 00:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofl0r/e935cae71f7c9f418348803b2b0394a2 to your computer and use it in GitHub Desktop.
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
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