Skip to content

Instantly share code, notes, and snippets.

@abhi923
Created December 16, 2021 11:17
Show Gist options
  • Save abhi923/b32d0c0d4d18fc4c0246c10043b71cc5 to your computer and use it in GitHub Desktop.
Save abhi923/b32d0c0d4d18fc4c0246c10043b71cc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
import optparse
def get_arguments():
parser = optparse.OptionParser()
parser.add_option("-i", "--interface", dest="interface", help="Interface to change its MAC address")
parser.add_option("-m", "--mac", dest="new_mac", help="NEW MAC address")
return parser.parse_args()
def change_mac(interface, new_mac):
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])
print("[+] Changing MAC address for " + interface + " to " + new_mac)
(options, arguments) = get_arguments()
change_mac(options.interface, options.new_mac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment