MAC-Spoofing script
From wiki.breedveld.net
This script let you spoof your MAC-address
It will use zenity and gedit
Before using, please read the short comment in this script
#!/bin/bash
#-------------------------------------------------------#
# /usr/local/bin/mac_spoof.sh
#
# Mac-Spoofing Script 4 Linux users
#
# 23-09-2009 v1.0 Roland Breedveld
#-------------------------------------------------------#
#
# MAC addresses in /usr/local/bin/mac_addresses.txt
# Fist time running will create is with your own MAC in it
#
# for some cards you first need to stop the interface
# for changing the MAC-address, if so uncomment this row:
# export START_STOP_IF_CARD=1
#
#-------------------------------------------------------#
export SCRIPT=`basename ${0}`
if [ -z "$(whoami|grep root)" ]
then
sudo /usr/local/bin/${SCRIPT} ${*}
else
while [ -z "${SELECT}" ]
do
if [ -z "${CUR_MAC}" ]
then
CUR_MAC=$(ifconfig eth0 2>&1 |grep HWaddr|awk '{print $NF}')
fi
if [ ! -f /usr/local/bin/mac_addresses.txt -a ! -z "${CUR_MAC}" ]
then
echo "Original_MAC ${CUR_MAC}" > /usr/local/bin/mac_addresses.txt
fi
SELECT_LIST=$(cat /usr/local/bin/mac_addresses.txt|awk -v mac="${CUR_MAC}" '{if(mac == $2 ){print " TRUE "}else{print " FALSE "}; print $2" "$1}')
SELECT_LIST="${SELECT_LIST} FALSE edit Edit_MAC_list FALSE new Add_New_MAC"
SELECT=$(zenity --height=600 --width=400 --list --radiolist --column "Sel" --column "MAC-address" --column "Locatie" ${SELECT_LIST})
if [ -z "${SELECT}" ]
then
exit 1
fi
if [ "${SELECT}" = "edit" ]
then
zenity --info --title="MAC-address Edit" --text="Attention, don't use spaces in the Location desription, but use _"
gedit /usr/local/bin/mac_addresses.txt
SELECT=""
CUR_MAC=""
fi
if [ "${SELECT}" = "new" ]
then
NEW_MAC=$(zenity --title "New Address" --entry --text "Type your new MAC-address")
NEW_LOC=$(zenity --title "New Address" --entry --text "Type your new Location" |sed 's/ /_/g')
echo "${NEW_LOC} ${NEW_MAC}" >> /usr/local/bin/mac_addresses.txt
SELECT=""
CUR_MAC=${NEW_MAC}
fi
done
if [ "${START_STOP_IF_CARD}" = "1" ]
then
ifconfig eth0 down
fi
ifconfig eth0 hw ether ${SELECT}
if [ "${START_STOP_IF_CARD}" = "1" ]
then
then
ifconfig eth0 up
fi
ifconfig eth0 |grep HWaddr|awk '{print $NF}'
(
while [ -z "${IFLINE}" ]
do
IFLINE=$(ifconfig eth0|grep "inet addr")
sleep 1
done
)| zenity --text "Wait for ip-address ..." --progress --pulsate --auto-close
zenity --info --title="MAC-address spoofed" --text="New MAC-addres: ${SELECT} Interface configured to $(ifconfig eth0|grep "inet addr")"
fi
