自动签到

Hulk Lv1

多此一举

因为学校的实习系统天天需要签到,实在是浪费精力,所以有了下面的过程.

过程

1. 抓包

用burp来代理流量,分别抓了以下请求和请求成功的响应json,问号为隐私

  • 登录 url: https://fw.tcc1955.edu.cn/newdgsx/mobile/login?loginName=????&password=????&schoolId=?????,参数分别为学号、密码、学校id POST
    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
    {
    "success": true,
    "code": 0,
    "data": {
    "sessionId": "?????????????",
    "user": {
    "createTime": 1648263450000,
    "teacherIn": null,
    "type": "STUDENT",
    "isTeacherEx": false,
    "creator": 1,
    "passwordChangeTime": ??????,
    "id": ????,
    "isStudent": true,
    "isTeacherIn": false,
    "latestUpdateCreator": 3107,
    "student": {
    "id": ????,
    "creator": 1,
    "latestUpdateCreator": 1,
    "createTime": 1648263423000,
    "latestUpdateTime": 1701705607000,
    "number": "???????", #学号
    "name": "???",
    "clazzId": ???,
    "userId": ???,
    "gender": "1",
    "birthdate": null,
    "homePhone": "",
    "homeName": "???",
    "mobilePhone": "????",
    "mobileShortNumber": null,
    "email": null,
    "qq": null,
    "weixin": null,
    "weixinOpenId": null,
    "isDeleted": false,
    "roleId": 5,
    "provinceId": null,
    "cityId": null,
    "provinceName": null,
    "cityName": null
    },
    "name": "???",
    "role": {
    "id": 5,
    "creator": null,
    "latestUpdateCreator": null,
    "createTime": null,
    "latestUpdateTime": null,
    "type": "STUDENT",
    "name": "学生",
    "memo": "学生",
    "sortNum": 5,
    "userHidden": false
    },
    "isAdmin": false,
    "latestUpdateTime": 1699343989000,
    "teacherEx": null,
    "roleId":,
    "loginName": "??"
    }
    },
    "msg": null,
    "errors": {}
    }
  • 获取签到历史 url: https://fw.tcc1955.edu.cn/newdgsx/mobile/process/stu-location/getMylistByDate?token=??????&startDate=2023-11-01&endDate=2023-12-01 参数token就是前面响应的sessionId,后面的参数为开始时间和截止时间 GET
    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
    {
    "success": true,
    "code": 0,
    "data": {
    "list": [
    {
    "id": ???,
    "creator": 3107,
    "latestUpdateCreator": 3107,
    "createTime": 1701491137000,
    "latestUpdateTime": 1701491137000,
    "studentId": 2480,
    "locationX": "???", #x坐标
    "locationY": "???", #y坐标
    "scale": 16,
    "label": "?????", #地名
    "sendTime": 1701446400000,
    "mapType": "baidu",
    "content": null,
    "isAbnormal": false,
    "abnormalType": null,
    "imei": "weizhi",
    "isEvection": false,
    "status": true,
    "auditOpinion": null,
    "applyOpinion": null,
    "internshipId": 68,
    "isIgnore": null,
    "studentName": "???",
    "checkType": "CHECKIN",
    "checkStatus": "3", #签到状态1为正常上班,3为休息,2为出差
    "customForms": null
    }
    ]
    },
    "msg": null,
    "errors": {}
    }
  • 签到 url: https://fw.tcc1955.edu.cn/newdgsx/mobile/process/stu-location/save?token=???&isAbnormal=0&checkType=CHECKIN&studentId=?&locationX=????&locationY=?????&scale=16&label=???&mapType=baidu&imei=weizhi&checkStatus=1&internshipId=68&attachIds= 参数主要就是token、坐标、地名、签到状态,其他参数填的跟历史记录一样,不知具体干什么的。POST
    1
    2
    3
    4
    5
    6
    7
    {
    "success": true,
    "code": 0,
    "data": null,
    "msg": null,
    "errors": {}
    }

2.编写python脚本

其实主要是分析url请求,后面编写脚本很容易,用request库写个简单的就够用了,先用登录请求获取token,再用token获取签到历史里的坐标和地名,最后签到就好了

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
#!/usr/bin/python3
import requests
import json


url1 = "https://fw.tcc1955.edu.cn/newdgsx/mobile/login"
url2 = "https://fw.tcc1955.edu.cn/newdgsx/mobile/process/stu-location/getMylistByDate"
url3 = "https://fw.tcc1955.edu.cn/newdgsx/mobile/process/stu-location/save"
# 准备POST请求的参数
payload = {
"loginName": "", #学号
"password": "", #密码
"schoolId": "???" #学校id
}


# 发送POST请求
response1 = requests.post(url1, data=payload)
data = json.loads(response1.text)
session_id = data["data"]["sessionId"]

params = {
"token": session_id,
"startDate": "2023-10-01", # 日期只改月份就可以了
"endDate": "2023-10-30" # 日期只改月份就可以了
}


response2 = requests.get(url2, params=params)
# 打印响应内容
#print(session_id)
data = json.loads(response2.text)
list_data = data["data"]["list"]
i = 0
locations_data = []
for item in list_data:
i+=1
location_x = item["locationX"]
location_y = item["locationY"]
internship_id = item["internshipId"]
label = item["label"]
location_data = {
"locationX": location_x,
"locationY": location_y,
"internshipId": internship_id,
"label": label
}
locations_data.append(location_data)

# 打印提取的数据
print(f"No.{i} LocationX: {location_x}, LocationY: {location_y}, InternshipId: {internship_id}, Label: {label}")
print("请选择要签到的地址No.后面的数字")
user_input = input("请输入一个数字: ")
try:
user_number = int(user_input)

except ValueError:
print("无法将输入转换为数字")
print(f"你选择的地址是{locations_data[ user_number - 1 ]['label']}")
# print(len(locations_data))
# print(type(locations_data[user_number - 1]['locationX']))
location = locations_data[ user_number - 1 ]
label = location['label']
location_x = location['locationX']
location_y = location['locationY']
internship_id = location['internshipId']
user_input = input("是否休息:(休息填3/正常填1) ")

#准备POST请求的参数
params = {
"token": session_id,
"isAbnormal": "0",
"checkType": "CHECKIN",
"studentId": "???",
"locationX": location_x,
"locationY": location_y,
"scale": "16",
"label": label,
"mapType": "baidu",
"imei": "weizhi",
"checkStatus": user_input,
"internshipId": internship_id,
"attachIds": ""
}



# 发送POST请求来签到
response = requests.post(url3, data=params)

#打印响应内容
print(response.text)⏎

3. 部署到服务器

我用的crontab定时任务,系统是arch,当然也可以在脚本里写上定时触发,不过没必要,毕竟最好保持KISS😙,如果要自动化签到记得把脚本中的交互给注释了。

1
crontab -e

添加下面的一行

1
0 9 * * * /path/to/autocheck.py #每天9点签一次到

吐槽

其实学校的实习系统用的慧职教🤐不是我说的(spring框架和远古的不知道啥玩意弄的实习系统)。真的不知道这些形式化的东西有啥用。顺带提一嘴,知道为啥学校教学水平不咋地了,你看看这系统做的🤡🤡🤡,万事还得靠自己,学习的动力又有了哈哈哈。

  • 标题: 自动签到
  • 作者: Hulk
  • 创建于 : 2023-12-05 19:53:49
  • 更新于 : 2023-12-05 21:02:43
  • 链接: https://blog.vmiss.shop/2023/12/05/自动签到/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论