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`
|
|
|
6 |
MAC_ADDRESSES="00:11:22:33:44:50 00:11:22:33:44:51 00:11:22:33:44:52"
|
|
|
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';"
|
|
|
16 |
db_radcheck_insert_res=$(mysql -u $DB_USER -p$DB_PASSWORD -D radius -e "$db_query2" -Ns)
|
|
|
17 |
echo -n "$MAC "
|
|
|
18 |
done
|
|
|
19 |
echo
|