Macbot 0.1 – An interactive commandline script for macchanger.

Ever got angry when Network Manager didn’t use the new MAC address you just assigned to interface wlan0? Macbot 0.1 is the solution to your problems.

Just finished this little script that makes changing your MAC address easier. It runs under root in any Debian environment and needs macchanger and bash installed.

1. It will just query you for the interface you want to change.

2. It will shut down network-manager

3. It will change your maccaddres via (macchanger -A option).

4. It will rename your WLAN networks in /etc/NetworkManager/system-connections/ , changing ‘space’ to ‘_’

5. It will let you select the WLAN with which you want to use the spoofed MAC address

6. It will change the file accodingly and display back what your new MAC address is, then quits.

If you got improvements, corrections or any other comments, let me know.


# This is the script. An easy script to interactively run 
# macchanger on debian distributions employing network-manager.
# Needs to be run as root.
# Thanks to Hai @ for the bit with select 
# and for the 
# ascii_art.
# Author: Manuel Weber (

#    This is the main screen.
#    It awaits the user to select the interface to be changed.
#    Sanitizing input has yet to be implemented.

echo "        ###    The MAC Bot 0.1        ###"
echo "               T        "
echo '             .-"-.        '
echo "            |  ___|        "
echo "            | (.\/.)    "
echo "            |  ,,,'     "
echo "            | '###        "
echo "             '----'        "

echo 'Enter the interface you want to change (eg. wlan0): '

read int 

ifconfig $int down
service network-manager stop
macchanger -A $int

mac=`ip link show $int | awk '/ether/ {print $2}'`

# This part asks the user which Network has to be configured.

echo 'List of available, already used WLANs: '

# Changes to network directory
cd /etc/NetworkManager/system-connections/

# Change network names to be withouth space characters
rename "s/ /_/g" *

# Set the prompt for the select command
PS3="Type a number or 'q' to quit: "

# Create a list of files to display
fileList=$(find . -maxdepth 1 -type f)

# Show a menu and ask for input, then add line 12 to selected file

select fileName in $fileList; do
    if [ -n "$fileName" ]; then
        sed -i "12s/.*/cloned-mac-address=$mac/" ${fileName}

ifconfig wlan0 up
service network-manager start

echo "Changed MAC address of INT-x to: $mac"

# Functionality to add to script:
# 1. Display network interfaces to choose from
# 2. Display macchangermodes, a)Custom b) Another c)random
# 3.

5 responses to “Macbot 0.1 – An interactive commandline script for macchanger.

  1. What’s “GNU common license”? I’ve never heard of that.

    Isn’t shebang always at first line? I don’t think that shebang actually being interpreted as shebang but a normal comment.

    Why do you need to change MAC address?

    I’ve got rid of Network Manager years ago, probably 5 years already, but that’s probably only viable because I don’t have to change network settings, like, well, 5 years.

    • You’re right with the shebang, kinda mistook this one. Deleted that GNU license thing as well, doesn’t really apply here I guess.

      If you got a static setup you don’t really need macchanger. But that script can come handy in a couple situations. Be it spoofing your Ethernet or Wireless MAC address, both may come handy in a pentesting situation.

      Also if you’re using free wifi hotspots, that grant temporary access depending on your MAC, it might come handy as a workaround.

      Also Network-Manager is standard on the Ubuntu and Kali distros, it’s nice to have the script if you’re using the live systems.

      Thanks for your reply, well appreciated.

  2. In trying to find a solution to my issue: where my wlan(0) Cloned MAC address fails to be populated with the wlan(0) MAC address that macchanger selects. Is your solution above intended to populate the Cloned MAC address in network connections? If so, what step am I missing. I run your script at startup but although macchanger-gtk indicates that the MAC address is changed, the Cloned MAC address in Network Manager remains blank.

    • Hey Mark,
      yeah the script is supposed to do that. Just found out myself recently that the following bit sometimes fails to do what it’s supposed to:

      sed -i "12s/.*/cloned-mac-address=$mac/" ${fileName}

      If you look at the connections in your /etc/Network-Manager/system-connections folder, you will find your connections listed. The code is supposed to put the cloned MAC address in line 12 of the selected file (=Wifi-Connection), yet line 12 sometimes writes the code below the [IPv6] block, but it has to be at the end of the [802-11-wireless] block.

      So yeah, I have to rewrite the script that it works, and I will do so, supposedly that weekend. In the meantime you might need to take a look at the file you wanna change and change the script to:
      sed -i "XXs/.*/cloned-mac-address=$mac/" ${fileName}

      where XX means the line where it’s supposed to go.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s