spoof-mac-address.sh (618B)
1 #!/bin/bash -e 2 device=wlp3s0 3 4 yellow=$(tput setaf 3) 5 reset=$(tput sgr0) 6 7 function printmac { 8 ip link show $device | awk '{print $2}' | tail -n 1 9 } 10 11 echo -en "${yellow}Mac address of $device before:${reset}\t" 12 printmac 13 14 echo "Bringing $device down" 15 sudo ip link set $device down 16 17 sleepduration=$(echo 10 + $RANDOM/1000 | bc) 18 echo -e "${yellow}Sleeping $sleepduration seconds...${reset}" 19 sleep "$sleepduration" 20 21 echo "Spoofing MAC address for $device" 22 sudo macchanger -r "$device" 23 24 sleep 1 25 26 echo "Bringing $device up" 27 sudo ip link set $device up 28 29 echo -en "${yellow}Mac address of $device after:${reset}\t" 30 printmac