Subversion Repositories ALCASAR

Rev

Rev 2971 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2971 rexy 1
#!/bin/bash
2
PASSWD_FILE="/root/ALCASAR-passwords.txt"
3
USER_NAME="test"
4
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
5
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
3053 rexy 6
MAC_ADDRESSES="00:11:22:33:44:50 00:11:22:33:44:51 00:11:22:33:44:52" # write here @MAC or user_names (delimiter=space)
2971 rexy 7
 
8
for MAC in $MAC_ADDRESSES
9
do      
10
        salt=`cat /dev/urandom | tr -dc '[:alnum:]' | head -c8`
11
        export algo_salt='$5$'$salt
12
        export pass='PASSWORD'
13
        pass_salt=$(perl -e'print crypt($ARGV[0],$ARGV[1])' $pass $algo_salt)
14
        db_query1="INSERT INTO radcheck (username,attribute,op,value) VALUES ('$MAC', 'Crypt-Password', ':=', '$pass_salt'); INSERT INTO userinfo (username) VALUES ('$MAC');"
15
        db_query2="DELETE FROM radcheck WHERE username = '$MAC'; DELETE FROM userinfo WHERE username = '$MAC';"
3053 rexy 16
        db_radcheck_insert_res=$(mysql -u $DB_USER -p$DB_PASSWORD -D radius -e "$db_query2" -Ns)  # choose here db_query1 or 2
2971 rexy 17
        echo -n "$MAC "
18
done    
19
echo