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)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.