3 # Copyleft 2006 - Leandro Lucarella <luca at llucax.com.ar>
4 # This script is under the BOLA license, please see the LICENSE file.
10 # Base key used to compute the actual key
11 KEY_BASE="My WEP is better than yours"
12 # Security mode (open/restricted)
14 # Comment this if you don't want to rotate the channel
16 # Channels supported by the wireless interface
18 # Uncomment if you want the script to work only if you're on a specific essid
20 # Uncomment if your wireless interface need the commit command
25 # The format has to be in date(1) format, and probably has to have a relation
26 # with the frequency the script is executed. The default value is useful for a
27 # 1/2 day frequency (rotation every 12 hs). date(1) is executed with C locale so
29 # A good crontab line for this is:
30 # 0 0,12 * * * /path/to/script
31 KEY_FORMAT="$KEY_BASE%D%p"
32 # Key size, 1-5 for 64bit encryption, 6-13 for 128bit encryption
34 # Hash command/algorithm used to compute the actual key
37 IFCONFIG="/sbin/ifconfig"
39 IWCONFIG="/sbin/iwconfig"
43 # Unless you know what you're doing, and in that case, send me the patch ;)
47 # Check if interface exists
48 if ! $IFCONFIG "$IFACE" > /dev/null 2>&1
53 # Check if they are using our essid
56 curr_essid=`$IWCONFIG $IFACE | grep ESSID \
57 | sed 's/.*ESSID:"\([^"]\+\)".*/\1/'`
58 if [ "$curr_essid" != "$ESSID" ]
65 str=`date +"$KEY_FORMAT"`
66 size=$(($KEY_SIZE * 2))
67 key=`echo "$str" | $HASH_PROG | cut -c-$size`
69 # Compute the new channel
70 if [ -n "$ROTATE_CHANNEL" ]
72 chan=1`echo $key | tr abcdef 847502 | cut -c-6`
73 chan=$(($chan % $MAX_CHANNEL + 1))
74 channel="channel $chan"
78 $IWCONFIG $IFACE key $SECURITY_MODE $key $channel $COMMIT
80 # vim: set et sw=2 sts=2 :