-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogout1.sh
37 lines (31 loc) · 904 Bytes
/
logout1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# --------------------------------------
# auto logout for wg.suda.edu.cn
# ---------------------------------------
function urlencode()
{
s="$1"
tmp=''
for (( i = 0 ; i < ${#s} ; i++ ))
do
ch=${s:$i:1}
case "$ch"
in [a-zA-Z0-9]) tmp="$tmp""$ch";;
* ) tmp="$tmp""%""$(printf "%x" \'$ch)"
esac
done
echo $tmp;
}
username=""
password=""
url=http://wg.suda.edu.cn/indexn.aspx
html=$(curl $url)
s=${html#*value=\"}
VIEWSTATE=${s%%\"*}
s=${s#*value=\"}
EVENTVALIDATION=${s%%\"*}
VIEWSTATE=$(urlencode $VIEWSTATE)
EVENTVALIDATION=$(urlencode $EVENTVALIDATION)
#logout
html=$(curl $url -H 'Content-Type: application/x-www-form-urlencoded' --data "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=""$VIEWSTATE""&__EVENTVALIDATION=""$EVENTVALIDATION""&TextBox1=""$username""&TextBox2=""$password""&nw=RadioButton2&tm=RadioButton8&Button4=%e9%80%80%e5%87%ba%e7%bd%91%e5%85%b3")
#echo $html