Site icon Virtual Maestro

Changing MAC address using python code – prompting input

Changing MAC address is common process when comes to security domain for operations like pen-testing. However, can also be used on virtual environment for linux based workloads. Copy below code and save it as .py file. Then run the python script to test.

Other versions of this code:

GUI based
Input Parsing

# Mac changer code

Import subprocess

iface = input("Name of Interface for changing MAC Address: ")
nmac = input("Type the new MAC Address to be used: ")

def mchange():
    print("Changing the MAC Address as per the input")["ifconfig", iface, "down"])["ifconfig", iface, "hw", "ether", nmac])["ifconfig", iface, "up"])
    print("MAC Address changed Successfully to: " + nmac)


Exit mobile version