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 interface exists
44 if ! /sbin/ifconfig "$IFACE" > /dev/null 2>&1
49 # Check if they are using our essid
52 curr_essid=`/sbin/iwconfig $IFACE | grep ESSID \
53 | sed 's/.*ESSID:"\([^"]\+\)".*/\1/'`
54 if [ "$curr_essid" != "$ESSID" ]
61 str=`date +"$KEY_FORMAT"`
62 size=$(($KEY_SIZE * 2))
63 key=`echo "$str" | $HASH_PROG | cut -c-$size`
65 # Compute the new channel
66 if [ -n "$ROTATE_CHANNEL" ]
68 chan=1`echo $key | tr abcdef 847502 | cut -c-6`
69 chan=$(($chan % $MAX_CHANNEL + 1))
70 channel="channel $chan"
74 /sbin/iwconfig $IFACE key $SECURITY_MODE $key $channel $COMMIT
76 # vim: set et sw=2 sts=2 :