CHANGE MAC ADDRESS OF SYSTEM AND STAY ANONYMOUS ON THE NETWORK USING PYTHON

MAC address stands for Media Access Control address. Mac address of a device is a unique, physical and permanent address assigned to a network interface controller (NIC) for communication at data link layer of network fragment. Mac address is assigned to the network interfaces by device manufacturers,weather it is wired card, wireless card or Ethernet all have a MAC address which is unique to that device. No two devices in the world can have same MAC addresses. MAC addresses are generally written in the form of 12 hexadecimal digits. For example, consider the following MAC address:  A0-D3-7A-32-4A-A1. One exceptional example of mac address is ff:ff:ff:ff:ff:ff, it is called as broadcast MAC address which addresses every network card on the network, it means when any device send a packet to broadcast MAC it is delivered to all the host or clients on the local area network.

To check the MAC address of the Windows operating system, open the Command Prompt (cmd), in cmd type ipconfig/all and press enter , A Physical Address displays for each adapter. The Physical Address is your device’s MAC address.




Difference between IP and MAC address

Every Network devices have two types of address one is IP address and another is MAC address. IP stands for Internet Protocol it is 32 bit logical address while MAC address is physical address. IP address is assigned to the every device which is connected to the network so that the device can be located on that network. Networks using the TCP/IP protocol route messages based on the IP address of the destination. TCP and IP is generally used together in the networking, IP address changes every time as device get connected to the new network. There are four classes of IP addresses that are Class A, Class B, Class C and Class D. An IP address is generally represented in dot decimal notation, consisting of four decimal number separated by periods form example 192.168.1.105. IP address used in the Internet to identify computer and to communicate.

As dissussed earlier, MAC address stand for Media Access Control, it is static and physical address which is associated with the machine, it is assigned to the network interfaces by device manufacturers. The MAC address is used with in Local Area Network (LAN) to identify devices and transfer data between devices. Each piece of data or packet that is sent with in a network contains a Source MAC and Destination MAC, so the packet flow from source to destination

Why change the mac address ?

Changing the MAC address of the device can be very helpful during the tasks like hacking and penetration testing some of the potential reasons are listed below -

Increase Anonymity
Since MAC Address is physical , unique address to each interface to each network devices and because it is used to identify the devices than changing the MAC Address will make us anonymous on the network.
Impersonate other Devices
MAC Address often used by filters to prevent or allow devices to connect to networks and do specific tasks on the network.So being able to change your MAC Address to another device’s MAC Address will make us impersonate this device and allow us to do things that we might not able to do.

Bypass Filters
We are able to Bypass Filters or connect to networks that on the specific devices with specific MAC address can connect to and we will also be able to change our identity.

Steps to Change MAC address -

Here there are steps for changing the MAC address in Debian-Derived Linux Distribution.

Disable the Network Interface
      ifconfig  “interface name” down
Modify MAC Address
  ifconfig  “interface name” hw ether “new mac address”
Enable the Network Interface
  ifconfig  “interface name” up

In the next section we will learn how to implement these steps in our python program

 

Using Python Modules and Executing System 

As in the previous section we have seen steps to change the MAC address, actually those steps are nothing but the system commands. So in our python program we will execute system commands in order to change MAC address.

We want our python program to be able to execute terminal commands in the same way that we are executing them manually. For executing system commands in python script there is python module called subprocess.

Subprocess Module in python

The subprocess module allows us to spawn processes, connect to their input/output/error pipes, and obtain their return codes.


The subprocess module contains No. Of functions
These functions allows to execute system commands
Commands depends on the Operating system which Execute the Script.


Syntax
import subprocess
subprocess.call(“COMMAND”, Shell=True)

Code-




Example-

FIGURE 1

 In the Figure 1 as we can see that the Mac address of the device is 00:11:22:33:44:55

FIGURE 2

In the FIGURE 2, the script mac.py is executed and it asks the interface for which the MAC address is to be changed and the new MAC address.

FIGURE 3
In FIGURE 3 the python script mac.py is executed and it has changed the MAC address of the device from 00:11:22:33:44:55 to aa:11:22:ff:66:44


Comments

Popular Posts