-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugtalk.py
165 lines (124 loc) · 4.07 KB
/
debugtalk.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# coding:utf-8
import os
import hashlib
import logging
import time
import uuid
from typing import List
import random
import string
# commented out function will be filtered
# def get_headers():
# return {"User-Agent": "hrp"}
def get_headers():
headers = {
'User-Agent-Platform': 'Dalvik/2.1.0 (Linux; U; Android 10; GLK-AL00 Build/HUAWEIGLK-AL00)',
'lib_net_work_version': '3.0.1',
'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 10; GLK-AL00 Build/HUAWEIGLK-AL00)',
'Content-Type': 'application/json; charset=UTF-8',
'Connection': 'close',
'appid': 114
}
return headers
def get_user_agent():
return "Dalvik/2.1.0 (Linux; U; Android 10; GLK-AL00 Build/HUAWEIGLK-AL00)"
def sleep(n_secs):
time.sleep(n_secs)
return f"slept: {n_secs}" # 必须return否则报错
def sum(*args):
result = 0
for arg in args:
result += arg
return result
def sum_ints(*args: List[int]) -> int:
result = 0
for arg in args:
result += arg
return result
def sum_two_int(a: int, b: int) -> int:
return a + b
def sum_two_string(a: str, b: str) -> str:
return a + b
def sum_strings(*args: List[str]) -> str:
result = ""
for arg in args:
result += arg
return result
def concatenate(*args: List[str]) -> str:
result = ""
for arg in args:
result += str(arg)
return result
def setup_hook_example(name):
logging.warning("setup_hook_example")
return f"setup_hook_example: {name}"
def teardown_hook_example(name):
logging.warning("teardown_hook_example")
return f"teardown_hook_example: {name}"
def url(is_test, host, name):
if is_test == 'test':
test = 'test-'
else:
test = ''
url = {
'api': f'http://{test}api-{host}',
'report': f'http://{test}new-appreport-{host}',
'cos': f'http://{test}cos-static-{host}',
'h5': f'http://{test}h5-{host}'
}
result = url[name]
print(result)
return result
def get_str_md5(oaid, ware_id, imei, tim, udi, DEVICE_SECRET) -> str:
# md5(oaid + ware_id + imei + time + udi + 秘钥)
string = concatenate(oaid, ware_id, imei, tim, udi, DEVICE_SECRET)
result = hashlib.md5(string.encode('utf8')).hexdigest() # 创建MD5对象,可以直接传入要加密的数据
print(result) # 转化为16进制打印md5值
return result
def get_time():
timestamp = int(time.time() * 1000) # 将秒数转换为毫秒数
timestamp = str(timestamp) # 将秒数转换为字符串
# print(timestamp)
return timestamp
def get_token():
import jwt
payload = {
"aud": "user",
"exp": 1682647042,
"jti": "253_6631",
"iat": 1680055042,
"nbf": 1680055042,
"IsReal": "0",
"Udi": "987cbbf2c141324cb024a75b09f3773f",
"AppId": 253,
"Uid": 6631
}
rc4 = "c6e4b44b219a784b"
reg = "c6e4b44b219a784be0ef0efe8344c9d9302de4bd6c5e569898d038ddd8752271"
update ="581e1b32b6e0d00b039c3c825116aab5293e3a76acef097e646542e1df4cdcb1"
business ="581e1b32b6e0d00b"
report_p ="1152921504606847229"
report_s ="039c3c825116aab5"
secret = report_s
algorithm = 'HS256'
token = jwt.encode(payload, secret, algorithm=algorithm)
print(token)
assert token=='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ1c2VyIiwiZXhwIjoxNjgyNjQ3MDQyLCJqdGkiOiIyNTNfNjYzMSIsImlhdCI6MTY4MDA1NTA0MiwibmJmIjoxNjgwMDU1MDQyLCJJc1JlYWwiOiIwIiwiVWRpIjoiOTg3Y2JiZjJjMTQxMzI0Y2IwMjRhNzViMDlmMzc3M2YiLCJBcHBJZCI6MjUzLCJVaWQiOjY2MzF9.agEv0iH2azLRZU_CnRZCQhDjPbjSENvULQmwDvfRfIc'
return token
# get_token()
def get_random(a, b):
rand_num = random.randint(a, b)
return rand_num
def generate_random_string(length):
"""
生成随机字符串
:param length: 字符串长度
:return: 随机字符串
"""
letters_and_digits = string.ascii_lowercase + string.digits
return ''.join(random.choice(letters_and_digits) for i in range(length))
def get_oaid():
# 使用Python的uuid模块生成符合标准格式的UUID
unique_id = uuid.uuid4() # 生成 UUID
oaid = str(unique_id)
return oaid