Advertisement
ibanezzaro

rand_mac

Jun 10th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. INTERFACE=en0
  4. OUI="/Users/Dario/bin/oui.txt"
  5. OUI_LEN=19004
  6.  
  7. while [ true ]; do
  8.     STATUS=`ifconfig ${INTERFACE} | grep status: | awk '{print $2}'`
  9.     if [ "$STATUS" = "inactive" ]; then
  10.         R=$(((RANDOM % ${OUI_LEN})+1))
  11.         PREFIX=`head -$R $OUI | tail -1`
  12.         CMD="sudo ifconfig ${INTERFACE} ether ${PREFIX}:"
  13.         for i in `seq 1 6`; do
  14.             R=$(((RANDOM % 15)+1))
  15.             C=`echo "obase=16; $R" | bc`
  16.             CMD="$CMD$C"
  17.             if [ $((i % 2)) = 0 ] && [ $i != 6 ]; then
  18.                 CMD="$CMD:"
  19.             fi
  20.         done
  21.         RESULT=`$CMD`
  22.         echo $CMD
  23.     fi
  24.     sleep 60
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement