#!/bin/sh

#Change this to your own server if you like
URL=http://asset.tempestdev.com/hpass/hpass.php?type=

#The location of your MAC list
MACS=/tmp/hpass.macs

#Code block, don't touch!
MACNUM=0
[ ! -f $MACS ] && wget $URL$1 -O $MACS
MACNUM=$(grep -v x $MACS | wc -l)
[ $MACNUM = 0 ] && sed -ri "s/x(.*)/\1/" $MACS && MACNUM=$(grep -v x $MACS | wc -l)
MACTOTAL=$(cat $MACS | wc -l)
RANDOM=$(awk 'BEGIN { srand();  print int(1 + rand() * 100000); }')
MAC=$(grep -v x $MACS | head -n $(($RANDOM%${MACNUM}+1)) | tail -n 1 | cut -d , -f 1)
sed -ri s/$MAC/x$MAC/ $MACS
#End of code block

#This sets the MAC in NVRAM
nvram set wl0_hwaddr=$MAC

#Commit the change
nvram commit

#Restart the wireless
service wireless restart