Macbot 0.2 – An interactive commandline script for macchanger *** Major Bugfix ***

*** MAJOR BUGFIX, Version 0.2 release ***

Ever got angry when Network Manager didn’t use the new MAC address you just assigned to interface wlan0? Macbot 0.2 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.

Changelog 0.2:
—————

Major fixes:

– Fixed the part that places the cloned-mac-address=XX:XX:XX:XX:XX:XX into the corresponding
/etc/NetworkManager/system-connections/file. Now, it doesn’t put it fixed into line 12 of the
the WLAN file, but actively looks for any ‘cloned-mac-address=XX:XX:XX:XX:XX:XX’, deletes
it and writes it anew, just below the ‘mac-address=XX:XX:XX:XX:XX:XX’ string, where it does
belong!

Minor fixes:

– Modified output string, so it repeats the chosen interface.

—————

Code:

#!/bin/bash

# This is the macbot.sh script. An easy script to interactively run macchanger on debian distributions employing network-manager.
# Needs to be run as root.
# Thanks to Hai @ http://wuhrr.wordpress.com for the bit with select, and http://chris.com/ascii/index.php?art=television/futurama
# for the ascii_art.
# GNU General Public License applies.
# Author: Manuel Weber (mmweber@gmx.net)


#	This is the main screen.
#	It includes user input for network interface that mac has to be changed.
#	Sanitizing input has yet to be implemented.
#
#  Changelog 0.2
#--------------------
#
#  - Fixed the part that places the cloned-mac-address=XX:XX:XX:XX:XX:XX into 
#    doesn't put it fixed into line 12 of the the WLAN file, but actively looks
#    for any 'cloned-mac-address=XX:XX:XX:XX:XX:XX', deletes it and writes it 
#    anew, just below the 'mac-address=XX:XX:XX:XX:XX:XX' string, where it does
#    belong!
#  
#  - Modified output string, so it repeats the chosen interface.	
#
#--------------------


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


-

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


read int 
echo

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

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: '
echo
echo




# 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 remove any old cloned MAC addresses
# and replace them with a fresh one.

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

	fi
	break
done



ifconfig wlan0 up
service network-manager start

echo
echo
echo
echo "Changed MAC address of interface $int to: $mac"
echo
echo
echo

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

2 responses to “Macbot 0.2 – An interactive commandline script for macchanger *** Major Bugfix ***

  1. Some follow up questions from my comment under your .1 version.

    After running your script, should the Cloned MAC address field for the connection selected with your script remain blank, or should it get populated with the MAC address selected by macchanger?

    Your script assumes that one has preselected and established the wlan0 connection that is to be chosen with the menu in your script – right? If so, the original uncloned MAC address will be publicly broadcast before your script changes it to the cloned address, right? Unless a wlan0 connection is established it won’t show up as being selectable in your menu, right?

    If so, for those that NEVER want their hardwired wlan0 MAC address to be made public, your script wont work? To accomplish total MAC annonominity, seems to me that one would first need to run macchanger to obtain a Cloned MAC address, and then MANUALLY populate the Cloned MAC address field for the wlan0 connection one is planning to use before one actually establishes the connection with the wlan0 connection that one intends to use, right?, in which case your script wont work for total privacy freaks, right?

    Or am I misunderstanting something, which is very possible because I am only just learning how to use Ubuntu.

    • 1. Yes after running my script the Clone MAC address field should get populated. That’s why I rewrote the script. Macbot 0.1 obviously often failed to do so correctly.

      2. Yes, true.

      3. If you never want your hardwired wlan0 MAC addres to be made public, my script doesn’t provide the necessary functions. It is just a workaround for the strange implementation of macchanger and NetworkManager in Ubuntu (12.04). If you are out for total privacy I would suggest to check out https://tails.boum.org/download/index.en.html . That is a excellent distro with all tools necessary to protect your privacy. It is also updated regularly, so it is considerably safe. Since it’s based on Debian the leap from Ubuntu shouldn’t be to big for you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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