I've been making a BASh script that changes your MAC Address to that of any manufacturer of your choice from a list. At the last part of the script that is run, it stops before finishing. Here is the code for that part:
function spoofUseMAC() {
echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Enter the number code for manufacturer: >>> " num
echo "[-] Generating MAC Address"
num=$( expr $num - 1 )
declare -a array
while read -r; do
array+=( "$REPLY" )
done < addr.txt
end=$( for i in {1..6} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' )
macAddress=${array[$num]}$end
echo "[-] MAC Address generated !"
echo "[-] Using address: $macAddress"
$skyBlue; $bold; echo
ifconfig
$white
read -p "[*] $($stopAllFX; $bgBlack; $white)Select an interface: >>> " iface
$yellow; echo "[-] $iface selected !"
$white; echo "[-] Disabling $iface ..."
ifconfig $iface down
ifconfig '$iface' hw ether '$macAddress'
echo "[-] MAC Address spoofed !"
sleep 1
echo "[-] Enabling $iface ..."
ifconfig '$iface' up
echo "[-] $iface enabled !"
echo "[-] Using address: $macAddress"
exit
}
function spoofSearchAgainOrNot() {
$bold; $white; echo
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search again"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Use one of these"
read -p ">>> " searchAgainOrNot
if [[ "$searchAgainOrNot" == "0" ]]; then
spoofSearch
elif [[ "$searchAgainOrNot" == "1" ]]; then
spoofUseMAC
else
spoofSearchAgainOrNot
fi
}
# Spoof, search option selected
function spoofSearch() {
$bold; echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Search for a manufacturer: >>> " search
$blue; awk -F '#' '{printf("%10d %s\n", NR, ":" $1 )}' /usr/bin/oui.txt | grep -i $search
spoofSearchAgainOrNot
}
# Spoof
function spoof() {
echo; $white
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search for a manufacturer"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Browse for a manufacturer through $($bold)long $($stopAllFX; $bgBlack; $white)list"
read -p ">>> " searchOrBrowse
if [[ $searchOrBrowse == "0" ]]; then
spoofSearch
elif [[ $searchOrBrowse == "1" ]]; then
spoofBrowse
else
spoof
fi
}
Why can't I use the internet (git clone says could not resolve hostname: github.com) after running this script? And why is it not finishing?
EDIT: This is supposed to work on MacOS and Linux. On MacOS, there is no ip route command, but in Linux, ip route results in:
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18 metric 600