![]() |
|
Macchanger script - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: Macchanger script (/Thread-Macchanger-script) |
Macchanger script - hunt3r972 - 02-25-2014 Code: #!/bin/bash
echo
echo " _______ _______ _______ _______ _______ _ _______ _______ _______ "
echo "( )( ___ )( ____ \( ____ \|\ /|( ___ )( ( /|( ____ \( ____ \( ____ )"
echo "| () () || ( ) || ( \/| ( \/| ) ( || ( ) || \ ( || ( \/| ( \/| ( )|"
echo "| || || || (___) || | | | | (___) || (___) || \ | || | | (__ | (____)|"
echo "| |(_)| || ___ || | | | | ___ || ___ || (\ \) || | ____ | __) | __)"
echo "| | | || ( ) || | | | | ( ) || ( ) || | \ || | \_ )| ( | (\ ( "
echo "| ) ( || ) ( || (____/\| (____/\| ) ( || ) ( || ) \ || (___) || (____/\| ) \ \__"
echo "|/ \||/ \|(_______/(_______/|/ \||/ \||/ )_)(_______)(_______/|/ \__/"
echo
echo "By 9H4C7K3R2 - v1.2"
echo "@ Script to automatize macchanging with the macchanger tool"
echo "@ Possibility too choose a mac address or randomly generate one"
function menu(){
echo
echo "MENU"
echo "1. Change MAC address"
echo "2. Restore default MAC address"
echo "3. Restart Network-Manager"
echo "4. Restart Network card"
echo "5. Exit"
}
function changemac(){
echo -n "[+] Interface: "
read interface
echo "[+] Informations about the interface"
echo
macchanger -s $interface
echo
echo "How to change the MAC address ?:"
echo "1. Random Generation"
echo "2. Choose a Specific MAC address"
echo -n "Choice: "
read choixmenu
if [ $choixmenu == "1" ]
then
echo
echo "[+] Interface $interface down"
ifconfig $interface down
echo "[+] Changing MAC address"
macchanger -r $interface > /dev/null 2>&1
echo "[+] Interface $interface up"
ifconfig $interface up
echo "[+] Informations about the interface"
echo
macchanger -s $interface
fi
if [ $choixmenu == "2" ]
then
echo
echo -n "Type the address MAC you want (ex: e4:26:4a:1c:a4:b8): "
read newmac
echo "[+] Interface $interface down"
ifconfig $interface down
echo "[+] Changing MAC address"
macchanger -m $newmac $interface > /dev/null 2>&1
echo "[+] Interface $interface up"
ifconfig $interface up
echo "[+] Informations about the interface"
echo
macchanger -s $interface
fi
}
function restoremac(){
echo
echo -n "[+] Interface: "
read interface
echo "[+] Informations about the interface"
echo
macchanger -s $interface
echo
echo "[+] Interface $interface down"
ifconfig $interface down
echo "[+] Restoring default MAC address"
macchanger -p $interface > /dev/null 2>&1
echo "[+] Interface $interface up"
ifconfig $interface up
echo "[+] Informations about the interface"
echo
macchanger -s $interface
}
function restartnm(){
/etc/init.d/network-manager stop
/etc/init.d/network-manager start
}
function restartntwk(){
/etc/init.d/networking stop
/etc/init.d/networking start
}
function quitter(){
exit
}
selectionmenu=0;
while [ $selectionmenu -ne 5 ]
do
menu
read -p "Choose a menu: " selectionmenu
case $selectionmenu in
1) changemac;;
2) restoremac;;
3) restartnm;;
4) restartntwk;;
5) quitter;;
esac
doneRE: Macchanger script - Ligeti - 02-25-2014 Hi I didn't read the whole code, but I think, there is a much better way for you to change mac address without the use of macchanger... NO? Because using a tool wrapped by another, doing the same thing (the same way), I know that the topic is Bash and not MAC Changer... but still (would look better IMHO) Peace
RE: Macchanger script - hunt3r972 - 02-25-2014 @Ligeti If you have a way to do it quicker you can tell me, I'll improve the script 'cause i'm ok with you: it's not the perfect way to do it. I just wanted to automatize macchanger because it's annoying to do ifconfig eth0 down + macchanger -r eth0 + ifconfig eth0 up each time, without talking about the issues it can gives (shutting down internet connection for no reason) RE: Macchanger script - chmod - 02-25-2014 just add this line to your .bashrc Code: alias cm="ifconfig wlan0 down && macchanger -r wlan0 && ifconfig wlan0 up"You will have to log out and back in, then simply open a terminal and enter cm RE: Macchanger script - hunt3r972 - 02-26-2014 @chmod does it help to avoid internet connection shutting down ? RE: Macchanger script - chmod - 02-26-2014 (02-26-2014, 09:37 AM)hunt3r972 Wrote: @chmod does it help to avoid internet connection shutting down ? To change a mac address of a device you have to put the device down, there is no way around it afaik (although this command takes 0.026 seconds to complete on my system), all this does is create a short hand version if a command so instead of typing out the whole thing you can set a phrase instead. The "&&" tells bash if the command on the left completes successfully execute the command on the right so essentially this is no different from your script it's just a shorter version. RE: Macchanger script - Ligeti - 02-26-2014 (02-26-2014, 09:58 AM)chmod Wrote: To change a mac address of a device you have to put the device down, there is no way around it afaik (although this command takes 0.026 seconds to complete on my system), all this does is create a short hand version if a command so instead of typing out the whole thing you can set a phrase instead. The "&&" tells bash if the command on the left completes successfully execute the command on the right so essentially this is no different from your script it's just a shorter version. Thanks, yes the device should be down to change the mac address, which i not a problem if you add it to the alias... No? Thanks for sharing
RE: Macchanger script - chmod - 02-26-2014 (02-26-2014, 06:45 PM)Ligeti Wrote: Thanks, yes the device should be down to change the mac address, which i not a problem if you add it to the alias... No? Yeah it's certainly not a problem and is included in the alias I provided, it's actually 3 commands on one line although non backtrack users might wanna throw a sudo in there as all of those commands require elevated privileges RE: Macchanger script - Ligeti - 02-26-2014 Well let's face it... if someone wants to shortcut mac changing he must be too lazy lol (unless you want to create a new level of layer 2 DDoS) :p RE: Macchanger script - chmod - 02-26-2014 (02-26-2014, 07:33 PM)Ligeti Wrote: Well let's face it... if someone wants to shortcut mac changing he must be too lazy lol (unless you want to create a new level of layer 2 DDoS) :p Is it lazy or smart? why waste time typing and risking RSI when you can make the computer do all the work for you? I use alias all the time along with !! to save on typing. |