forked from SDU-toolhub/SDU_login_API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcas_sms_auth.py
More file actions
57 lines (53 loc) · 1.58 KB
/
cas_sms_auth.py
File metadata and controls
57 lines (53 loc) · 1.58 KB
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
from random import random
from tkinter import Label, PhotoImage, Tk
from httpx import Client
mobile = "" # Your mobile number
service = "" # "https://aiassist.sdu.edu.cn/common/actionCasLogin?redirect_url=https%3A%2F%2Faiassist.sdu.edu.cn%2Fpage%2Fsite%2FnewPc%3Flogin_return%3Dtrue"
client = Client()
if mobile == "":
mobile = input("手机号: ")
if service == "":
exit("请填写service")
while True:
window = Tk()
window.title("图片验证码")
window.bind("<Escape>", lambda e: window.destroy())
photo = PhotoImage(data=client.get("https://pass.sdu.edu.cn/cas/code").content)
img_label = Label(window, image=photo)
img_label.pack(pady=10)
window.mainloop()
imgcode = input("图片验证码: ")
url = (
client.post(
"https://pass.sdu.edu.cn/cas/loginByMorE",
data={
"method": "sendMobileCode",
"sendConfirm": imgcode,
"mobile": mobile,
"random": random(),
},
)
.json()
.get("redirectUrl")
)
if url == "login":
break
else:
print("图片验证码错误,请重试。")
mobilecode = input("短信验证码: ")
if (
url := client.post(
"https://pass.sdu.edu.cn/cas/loginByMorE",
data={
"method": "login",
"mobile": mobile,
"mobileCode": mobilecode,
"random": random(),
"service": service,
},
)
.json()
.get("redirectUrl")
):
res = client.get(url, follow_redirects=True)
print(client.cookies)