Created
December 16, 2021 11:17
-
-
Save abhi923/b32d0c0d4d18fc4c0246c10043b71cc5 to your computer and use it in GitHub Desktop.
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
#!/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