-
Notifications
You must be signed in to change notification settings - Fork 46
/
checkIn_ZhangFei_getToken.py
136 lines (120 loc) · 4.39 KB
/
checkIn_ZhangFei_getToken.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
'''
new Env('掌上飞车扫码登陆')
cron: 1 1 1 1 1
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
___/`---'\___
.' \\| |// '.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' |_/ |
\ .-\__ '-' ___/-. /
___'. .' /--.--\ `. .'___
."" '< `.___\_<|>_/___.' >' "".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `_. \_ __\ /__ _/ .-` / /
=====`-.____`.___ \_____/___.-`___.-'=====
`=---='
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
佛祖保佑 永不宕机 永无BUG
Author: BNDou
Date: 2024-04-11 22:20:35
LastEditTime: 2024-06-12 19:19:34
FilePath: \Auto_Check_In\checkIn_ZhangFei_getToken.py
Description:
'''
import sys
import io
import re
import time
import qrcode
import requests
try:
from PIL import Image
from pyzbar.pyzbar import decode
except ModuleNotFoundError as e:
if "PIL" in str(e):
print(f"❌ {e}\n请到依赖管理中安装python环境的“pillow”")
elif "pyzbar" in str(e):
print(f"❌ {e}\n请到依赖管理中安装python环境的“pyzbar”")
sys.exit()
except ImportError as e:
print(f"❌ {e}\n请安装 zbar 库,安装指令:apk add zbar-dev")
sys.exit()
# def get_auth_token(t):
# """官方算法:根据supertoken计算auth_token"""
# e, r = 0, len(t)
# for n in range(r):
# e = 33 * e + ord(t[n])
# return e % 4294967296
def get_ptqrtoken(t):
"""官方算法:根据qrsig计算ptqrtoken"""
e, r = 0, len(t)
for n in range(r):
e += (e << 5) + ord(t[n])
return 2147483647 & e
if __name__ == "__main__":
print("🔴 没事不要随便扫,扫码登录后,寻宝和购物用的token就失效了")
print("🔴 需要重新在app端抓包获取token,得不偿失")
print("🔴 除非你只用签到脚本,不需要那俩功能")
print("✌ 请使用手机QQ扫描二维码")
# 1、获取需要扫码的图片并切获取qrsig
url = "https://xui.ptlogin2.qq.com/ssl/ptqrshow?daid=381&appid=716027609&pt_3rd_aid=1105330667"
res_qr = requests.get(url)
qrsig = res_qr.cookies.get('qrsig')
# print("\nqrsig =", qrsig)
# 打印二维码
barcode_url = ''
barcodes = decode(Image.open(io.BytesIO(res_qr.content)))
for barcode in barcodes:
barcode_url = barcode.data.decode("utf-8")
qr = qrcode.QRCode(version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=2)
qr.add_data(barcode_url)
qr.make(fit=True)
# invert=True白底黑块
qr.print_ascii(invert=True)
# 2、获取ptqrtoken
ptqrtoken = get_ptqrtoken(qrsig)
# print("ptqrtoken =", ptqrtoken)
# 3、监控用户是否扫成功
while (True):
params = {
"ptqrtoken": ptqrtoken,
"u1": "http://connect.qq.com",
"from_ui": "1",
"daid": "381",
"aid": "716027609",
"pt_3rd_aid": "1105330667",
"pt_openlogin_data": "refer_cgi%3Dm_authorize%26response_type%3Dtoken%26client_id%3D1105330667%26redirect_uri%3Dauth%253A%252F%252Ftauth.qq.com%252F%26",
}
query_string = "&".join([f"{k}={v}" for k, v in params.items()])
url = f"https://xui.ptlogin2.qq.com/ssl/ptqrlogin?{query_string}"
res_login = requests.get(
url=url,
headers={
'Cookie':
'; '.join([
f'{key}={value}'
for key, value in res_qr.cookies.get_dict().items()
])
})
print(res_login.text)
if "登录成功" in res_login.text:
# 4、提取 openid appid access_token
openid = re.search(r"openid=(\w+)", res_login.text).group(1)
appid = re.search(r"appid=(\w+)", res_login.text).group(1)
access_token = re.search(r"access_token=(\w+)",
res_login.text).group(1)
print(
f"\nopenid = {openid}\nappid = {appid}\naccess_token = {access_token}"
)
break
# 两秒循环检测
time.sleep(2)