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
39 # Unless you know what you're doing, and in that case, send me the patch ;)
43 # Check if they are using our essid
46 curr_essid=`/sbin/iwconfig $IFACE | grep ESSID \
47 | sed 's/.*ESSID:"\([^"]\+\)".*/\1/'`
48 if [ "$curr_essid" != "$ESSID" ]
55 str=`date +"$KEY_FORMAT"`
56 size=$(($KEY_SIZE * 2))
57 key=`echo "$str" | $HASH_PROG | cut -c-$size`
59 # Compute the new channel
60 if [ -n "$ROTATE_CHANNEL" ]
62 chan=`echo $key | tr abcdef 847502 | cut -c-6`
63 chan=$(($chan % $MAX_CHANNEL + 1))
64 channel="channel $chan"
68 /sbin/iwconfig $IFACE key $SECURITY_MODE $key $channel $COMMIT
70 # vim: set et sw=2 sts=2 :