forked from huxiaofan1223/jxnu_srun
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jxnu_wifi.py
96 lines (94 loc) · 2.49 KB
/
jxnu_wifi.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
86
87
88
89
90
91
92
93
94
95
96
import requests
import time
import re
from encryption.srun_md5 import *
from encryption.srun_sha1 import *
from encryption.srun_base64 import *
from encryption.srun_xencode import *
header={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36'
}
init_url="http://172.16.8.6"
get_challenge_api="http://172.16.8.6/cgi-bin/get_challenge"
srun_portal_api="http://172.16.8.6/cgi-bin/srun_portal"
get_info_api="http://172.16.8.6/cgi-bin/rad_user_info?callback=jQuery112406118340540763985_1556004912581&_=1556004912582"
n = '200'
type = '1'
ac_id='1'
enc = "srun_bx1"
def get_chksum():
chkstr = token+username
chkstr += token+hmd5
chkstr += token+ac_id
chkstr += token+ip
chkstr += token+n
chkstr += token+type
chkstr += token+i
return chkstr
def get_info():
info_temp={
"username":username,
"password":password,
"ip":ip,
"acid":ac_id,
"enc_ver":enc
}
i=re.sub("'",'"',str(info_temp))
i=re.sub(" ",'',i)
return i
def init_getip():
global ip
init_res=requests.get(init_url,headers=header)
print("初始化获取ip")
ip=re.search('id="user_ip" value="(.*?)"',init_res.text).group(1)
print("ip:"+ip)
def get_token():
# print("获取token")
global token
get_challenge_params={
"callback": "jQuery112404953340710317169_"+str(int(time.time()*1000)),
"username":username,
"ip":ip,
"_":int(time.time()*1000),
}
get_challenge_res=requests.get(get_challenge_api,params=get_challenge_params,headers=header)
token=re.search('"challenge":"(.*?)"',get_challenge_res.text).group(1)
print(get_challenge_res.text)
print("token为:"+token)
def do_complex_work():
global i,hmd5,chksum
i=get_info()
i="{SRBX1}"+get_base64(get_xencode(i,token))
hmd5=get_md5(password,token)
chksum=get_sha1(get_chksum())
print("所有加密工作已完成")
def login():
srun_portal_params={
'callback': 'jQuery11240645308969735664_'+str(int(time.time()*1000)),
'action':'login',
'username':username,
'password':'{MD5}'+hmd5,
'ac_id':ac_id,
'ip':ip,
'chksum':chksum,
'info':i,
'n':n,
'type':type,
'os':'windows+10',
'name':'windows',
'double_stack':'0',
'_':int(time.time()*1000)
}
# print(srun_portal_params)
srun_portal_res=requests.get(srun_portal_api,params=srun_portal_params,headers=header)
print(srun_portal_res.text)
if __name__ == '__main__':
global username,password
username="201626203044@cmcc"
password="15879684798qq"
init_getip()
get_token()
do_complex_work()
login()
res=requests.get(get_info_api,headers=header)
print(res.text)