Skip to content

maruki00/ShadowMAC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

MAC Address Changer

Overview

MAC Address Changer is a Python script that allows you to modify the MAC address of a specified network interface on supported Unix-based systems.

The script can:

  • Change to a custom MAC address
  • Generate and assign a random MAC address
  • Validate MAC address format
  • Ensure root privileges before execution
  • Detect supported operating systems

Requirements

  • Python 3.x
  • Root privileges (sudo)
  • Unix-based operating system:
    • Linux
    • macOS (Darwin)

The script relies on the ifconfig command to update the MAC address.


Supported Platforms

The script supports:

  • linux
  • linux2
  • darwin

If run on an unsupported operating system, it will return an error.


Usage

Run the script using sudo:

sudo python3 script.py --iface=<Network Interface> <--mac=<MAC> OR --random=True>

Required Arguments

Argument Description
--iface Network interface (e.g., eth0, wlan0, en0)
--mac 12-digit MAC address (without colons)
--random Generate a random MAC address

Note: Use only one of --mac or --random.


Examples

Set a Custom MAC Address

sudo python3 script.py --iface=eth0 --mac=001122AABBCC

The script will format the MAC as:

00:11:22:AA:BB:CC

Generate a Random MAC Address

sudo python3 script.py --iface=eth0 --random=True

This generates a 12-character hexadecimal MAC address automatically.


MAC Address Validation

The script ensures:

  • Exactly 12 hexadecimal characters
  • Allowed characters:
    • 0–9
    • A–F
    • a–f

If invalid, you will see:

[x] mac addrress not valid .

Root Privileges

The script must be executed as root:

sudo python3 script.py ...

If not run as root:

[x] use script as root .

How It Works

  1. Detects operating system
  2. Checks root privileges
  3. Parses command-line arguments
  4. Validates MAC address
  5. Brings interface down
  6. Changes MAC address
  7. Brings interface back up

Internally executes:

ifconfig <iface> down
ifconfig <iface> hw ether <mac>
ifconfig <iface> up

Error Handling

The script will display usage instructions if:

  • Required arguments are missing
  • Invalid arguments are provided
  • MAC address format is incorrect
  • OS is unsupported
  • Root privileges are missing

Main Class Structure

class changeMacAddress

Key methods:

  • detectOs()
  • hasRootPrivilege()
  • parseArgs()
  • parseMacAddress()
  • isValideMAc()
  • randomMacAddress()
  • changeMacAddress()
  • usage()

Disclaimer

Changing your MAC address may:

  • Temporarily disconnect your network
  • Violate certain network policies

Use responsibly and only on networks you are authorized to modify.


License

Provided as-is for educational and testing purposes.

About

MAC Address Changer is a Python script that allows you to modify the MAC address of a specified network interface on supported Unix-based systems.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages