-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuptVpn.py
85 lines (77 loc) · 3.83 KB
/
buptVpn.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import requests
from PIL import Image
from io import BytesIO
from yanzhengma import shibie
def refreshCookie(CookieName,xuehao,passwd,vpn_account,vpn_passwd):
s = requests.session()
s.verify = False
init_headers = {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Host": "vpn.bupt.edu.cn",
"Referer":"https://vpn.bupt.edu.cn/",
'content-type': 'charset=utf8',
}
# https://vpn.bupt.edu.cn/global-protect/login.esp
response=s.get("https://vpn.bupt.edu.cn/global-protect/login.esp",headers=init_headers)
PHPSESSID=response.headers['Set-Cookie'].split(';')[0]
login_headers = {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Host": "vpn.bupt.edu.cn",
"Referer":"https://vpn.bupt.edu.cn/global-protect/login.esp",
'Content-Type':'application/x-www-form-urlencoded',
'Origin': 'https://vpn.bupt.edu.cn',
'Cookie':PHPSESSID
}
post_data={
'prot':'https:',
'server':'vpn.bupt.edu.cn',
'inputStr':'',
'action':'getsoftware',
'user':vpn_account,
'passwd':vpn_passwd,
'ok':'Log In'
}
response=s.post('https://vpn.bupt.edu.cn/global-protect/login.esp',post_data,headers=login_headers)
GP_SESSION_CK=response.headers['Set-Cookie'].split(';')[0]
jwxt_headers={
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Host": "vpn.bupt.edu.cn",
# "Referer":"https://vpn.bupt.edu.cn/global-protect/login.esp",
# 'Content-Type':'application/x-www-form-urlencoded',
# 'Origin': 'https://vpn.bupt.edu.cn',
'Cookie':PHPSESSID+';'+GP_SESSION_CK
}
response=s.get('https://vpn.bupt.edu.cn/https/jwxt.bupt.edu.cn',headers=jwxt_headers)
PAN_GP_CK_VER=response.headers['Set-Cookie'].split(',')[0].split(';')[0].strip()
PAN_GP_CACHE_LOCAL_VER_ON_SERVER=response.headers['Set-Cookie'].split(',')[1].split(';')[0].strip()
yzm_headers={
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Host": "vpn.bupt.edu.cn",
"Referer":"https://vpn.bupt.edu.cn/https/jwxt.bupt.edu.cn",
'Cookie':PHPSESSID+';'+GP_SESSION_CK+';'+PAN_GP_CK_VER+';'+PAN_GP_CACHE_LOCAL_VER_ON_SERVER
}
response=s.get("https://vpn.bupt.edu.cn/https/jwxt.bupt.edu.cn/validateCodeAction.do?gp-1&random=",headers=yzm_headers)
image=Image.open(BytesIO(response.content))
image.save('yzm.png')
zjh=xuehao
mm=passwd
v_yzm=shibie('yzm.png')
post_data={
'type':'sso',
'zjh':zjh,
'mm':mm,
'v_yzm':v_yzm
}
print(v_yzm)
login_headers={
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Host": "vpn.bupt.edu.cn",
"Referer":"https://vpn.bupt.edu.cn/https/jwxt.bupt.edu.cn",
"Origin": "https://vpn.bupt.edu.cn",
"Cookie":PHPSESSID+';'+GP_SESSION_CK+';'+PAN_GP_CK_VER+';'+PAN_GP_CACHE_LOCAL_VER_ON_SERVER,
"Content-Type": "application/x-www-form-urlencoded",
}
response=s.post('https://vpn.bupt.edu.cn/https/jwxt.bupt.edu.cn/jwLoginAction.do?',post_data,headers=login_headers)
with open(CookieName,'w',encoding='utf-8') as cookieStore:
cookieStore.write(PHPSESSID+';'+GP_SESSION_CK+';'+PAN_GP_CK_VER+';'+PAN_GP_CACHE_LOCAL_VER_ON_SERVER)
return "OK"