Skip to content

Instantly share code, notes, and snippets.

@abhi923
Created December 16, 2021 11:13
Show Gist options
  • Save abhi923/b4779a3c1a3b5383736e8b5ffc57c958 to your computer and use it in GitHub Desktop.
Save abhi923/b4779a3c1a3b5383736e8b5ffc57c958 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import subprocess
import optparse
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)
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")
(options, arguments) = parser.parse_args()
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