Python script that change you machine MAC
#--------------------------------------
# Tool to change the mac address of a machine
# Programmar: Saleh J. Makkawy
#---------------------------------
# All moduals needed for the tool
import subprocess
import optparse
# Function to read arguments from user
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.")
(otions,arguments)=parser.parse_args()
if not options.interface:
parser.error("[-] Please specifiy an interface, use --help or -h for more help.")
elif not options.new_mac:
parser.error("[-] Please specifiy a new mac, use --help or -h for more help.")
return options
def change_mac(interface, new_mac):
print("[+] Changing MAC address for"+ interface + "to"+ new_mac)
subprocess.call(["ifconfig",interface,"down"])
subprocess.call(["ifconfig",interface,"hw", "ether", new_mac])
subprocess.call(["ifconfig",interface,"up"])
# options =get_arguments()
# change_mac(options.interface, options.new_mac)
ifconfig_result= subprocess.check_output(["ifconfig", options.interface])
print(ifconfig_result)