Translate in Your language

Friday, 13 March 2020

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.

# 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")
    subprocess.call(["ifconfig", iface, "down"])
    subprocess.call(["ifconfig", iface, "hw", "ether", nmac])
    subprocess.call(["ifconfig", iface, "up"])
    print("MAC Address changed Successfully to: " + nmac)

mchange()

Other versions of this code:

GUI based
Input Parsing

No comments:

Post a comment

Followers

Popular Posts This Week