Skip to content

Instantly share code, notes, and snippets.

@Zxilly
Created November 29, 2020 13:52
Show Gist options
  • Save Zxilly/03300ea52e644188c019d47bf0879f1d to your computer and use it in GitHub Desktop.
Save Zxilly/03300ea52e644188c019d47bf0879f1d to your computer and use it in GitHub Desktop.
Fxxk JGSU Web Auth (井冈山大学校园网登陆脚本)
#!/bin/sh
studentid='' # 用户名
password='' # 密码
IP=$(ubus call network.interface.wan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
# IP="10.73.26.189"
UA="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
function login() {
# IP="10.73.11.167"
# echo "DDDDD=${studentid}&upass=${password}&R1=0&R2=&R6=0&para=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login=&R7=0"
statusfull=$(curl 'http://192.168.167.46/a70.htm' \
-X POST \
-s -A "${UA}" \
-H "Cookie: program=ip; vlan=0; md5_login2=${studentid}%7C${password}; ip=${IP}" \
--data-raw "DDDDD=${studentid}&upass=${password}&R1=0&R2=&R6=0&para=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login=&R7=0")
# echo "${statusfull}"
status=$(echo "${statusfull}" | grep -a -oE '<!--Dr.COMWebLoginID_[0-9]\.htm-->')
# echo ${status}
if [ $status == '<!--Dr.COMWebLoginID_2.htm-->' ]; then
errormsg=$(echo "${statusfull}" | grep 'msga' | grep -oE "msga='.*'")
logger -t "校园网认证" "Login Failed:${errormsg}"
# echo "Log Failed:${errormsg}"
sleep 14
login
else
checkstatus
if [ $statuscode == '204' ]; then
lasturl=$(echo "${statusfull}" | grep 'UL' | grep -oE "UL='.*'")
logger -t "校园网认证" "Login Success:${lasturl}"
else
# echo "Judge it ${statuscode}"
sleep 14
login
fi
fi
}
function checkstatus() {
statuscode=$(curl -m 3 -o /dev/null -s -w %{http_code} -A "${UA}" http://connect.rom.miui.com/generate_204)
}
# 3成功2失败
function oneloop() {
checkstatus
# echo ${statuscode}
if [ $statuscode == '204' ]; then
# echo 'Normal'
# logger 'Normal'
sleep 1
elif [ $statuscode == '200' ]; then
# 直接劫持http替换成跳转js,同样是需要登陆
logger -t "校园网认证" "Disconnected,ERR=${statuscode}"
sleep 14
logger -t "校园网认证" "Try to Connect"
login
elif [ $statuscode == '000' ]; then
# logger -t "校园网认证" "DNS lookup error,ERR=000"
# 学校的网就是DNS老爆炸,这不是一个错误
sleep 1
elif [ $statuscode == '302' ]; then
# echo 'Failed'
logger -t "校园网认证" "Disconnected,ERR=${statuscode}"
sleep 14 # 虽然报错是3s,但是实际上应该是13s,猜测是检测10s+冷却3s
logger -t "校园网认证" "Try to Connect"
login
else
logger -t "校园网认证" "Uncaught error,ERR=${statuscode}"
fi
}
while true; do
oneloop
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment