What is mac address?
A Mac address or Media access control address is a unique identifier of any device which is assign to network interface control card or NIC card for communication at the data link layer of any network segment. Physical address are most often assigned by the manufacturer of a NIC and are stored in its hardware, such as the card’s read-only memory or some other firmware mechanism
It has 6 octets which is separated by colan(:) each octets contain 8-bit and total 48-bit of address space, First three octets specify organizationally unique identifier and last three octets network interface control specific.
How to change mac address using python script?
Python is also a very powerful & most important programming language in hacking and security field. However perl and ruby are also very smart and powerful languages. Although There are many tools available in the market which is written in python so here we discuss about to change mac address of Linux Operating system using python script.
Let’s find out the hardware address of our system with ifconfig command.This will change the mac address of your Linux operating system.
Changing Physical address using python script.
1. #!/usr/bin/env python
2. import subprocess
3. interface = raw_input(“Interface > “)
4. new_mac = raw_input(“New MAC > “)
5. subprocess.call([“ifconfig”, interface, “down”])
6. subprocess.call([“ifconfig”, interface, “hw”, “ether”, new_mac])
7. subprocess.call([“ifconfig”, interface, “up”])
Understanding pyhton script for mac changing
In this script first line is for syntax to write a python script in Linux OS. Second line we import a library called subprocess which contains commands of Linux operating system. Third & fourth line will take the input from the user and store in the variable interface & new_mac respectively. Last three lines are used to calling the function called call which contains Linux commands. Above all code will change mac address of linux operating system. Let’s run this script, we can see finally our hardware address is change.