0%

python实现小米运动多方刷步

前言

为了实现微信、支付宝等刷步数的功能,借用了小米运动的第三方接口,使用python模拟登录,再去伪造步数数据。

在小米运动中开启多端同步,数据上传后即会产生对应的同步

代码编写

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
import requests
import random
import re
import time

# 机型伪装
headers = {
'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/20.6.18)'
}


# 登录模块
def login(user, pwd):
# 获取登录code
global code
url1 = "https://api-user.huami.com/registrations/+86" + user + "/tokens"
# 登录专用的请求头
headers_login = {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)"
}
# post请求的相关数据
data1 = {
"client_id": "HuaMi",
"password": pwd,
"redirect_uri": "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
"token": "access"
}
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
	res1 = requests.post(url=url1, data=data1, headers=headers_login, allow_redirects=False)
# 获取头部中的Location信息
location = res1.headers["Location"]
# 异常处理 通过正则取得相关的数据
try:
code_pattern = re.compile("(?<=access=).*?(?=&)")
code = code_pattern.findall(location)[0]
except Exception as e:
print("登录code获取失败!\n", e)
exit(-1)
# 模拟登录处理
url2 = "https://account.huami.com/v2/client/login"
# post请求提交的数据
data2 = {
"app_name": "com.xiaomi.hm.health",
"app_version": "4.6.0",
"code": code,
"country_code": "CN",
"device_id": "2C8B4939-0CCD-4E94-8CBA-CB8EA6E613A1",
"device_model": "phone",
"grant_type": "access_token",
"third_name": "huami_phone",
}
res2 = requests.post(url=url2, data=data2, headers=headers_login).json()
# 对返回的json数据进行处理
login_token = res2.get("token_info").get("login_token")
user_id = res2.get("token_info").get("user_id")
# 如果处理的值为空啧关闭程序
if login_token is not None and user_id is not None:
return login_token, user_id
else:
print("login_token和user_id为空")
exit(-1)
# 获取时间戳
def get_time():
url = 'http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp'
response = requests.get(url, headers=headers).json()
# 对请求返回的json数据进行处理
t = response.get('data').get('t')
# 空值处理
if t is None:
print("时间戳获取失败")
exit(-1)
return t


# 获取token相关的数据
def get_app_token(login_token):
url = "https://account-cn.huami.com/v1/client/app_tokens?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&login_token={}".format(
login_token)
response = requests.get(url, headers=headers).json()
# 解析get请求得到的json数据
app_token = response.get('token_info').get('app_token')
# 空值处理
if app_token is None:
print("app_token获取失败")
exit(-1)
return app_token


# 微信server酱的简单使用
def vx_server(message):
# message即是需要传的数据
data = {
'text': '小米运动刷步结果通知',
'desp': message
}
url = '你的server酱链接'
response = requests.post(url=url, data=data)
# 对请求的status_code进行判断
if response.status_code == 200:
print("微信消息推送成功!")
else:
print("微信消息推送失败!")


# 主程序
def domain(user, pwd, step):
# 讲传进的值进行string转换
user = str(user)
pwd = str(pwd)
step = str(step)
# 传值的空值处理
if user is None and pwd is None:
print("参数设置有误,请重新设置!")
exit(-1)
if step is None:
step = str(random.randint(10000, 19999))
print("步数为空 已为您设置随即步数 (10000~19999)")
# 模拟登录
login_token, user_id = login(user, pwd)
# 获得时间戳
t = get_time()
# 获取token
app_token = get_app_token(login_token)
# 对data_json进行处理
today = time.strftime("%F")
data_json = '%5B%7B%22data_hr%22%3A%22%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2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2C%5C%22is%5C%22%3A169%2C%5C%22lb%5C%22%3A10%2C%5C%22to%5C%22%3A23%2C%5C%22dt%5C%22%3A0%2C%5C%22rhr%5C%22%3A58%2C%5C%22ss%5C%22%3A69%2C%5C%22stage%5C%22%3A%5B%7B%5C%22start%5C%22%3A1698%2C%5C%22stop%5C%22%3A1711%2C%5C%22mode%5C%22%3A4%7D%2C%7B%5C%22start%5C%22%3A1712%2C%5C%22stop%5C%22%3A1728%2C%5C%22mode%5C%22%3A5%7D%2C%7B%5C%22start%5C%22%3A1729%2C%5C%22stop%5C%22%3A1818%2C%5C%22mode%5C%22%3A4%7D%2C%7B%5C%22start%5C%22%3A1819%2C%5C%22stop%5C%22%3A1832%2C%5C%22mode%5C%22%3A5%7D%2C%7B%5C%22start%5C%22%3A1833%2C%5C%22stop%5C%22%3A1920%2C%5C%22mode%5C%22%3A4%7D%2C%7B%5C%22start%5C%22%3A1921%2C%5C%22stop%5C%22%3A1928%2C%5C%22mode%5C%22%3A5%7D%2C%7B%5C%22start%5C%22%3A1929%2C%5C%22stop%5C%22%3A2030%2C%5C%22mode%5C%22%3A4%7D%5D%7D%2C%5C%22stp%5C%22%3A%7B%5C%22ttl%5C%22%3A125%2C%5C%22dis%5C%22%3A82%2C%5C%22cal%5C%22%3A5%2C%5C%22wk%5C%22%3A7%2C%5C%22rn%5C%22%3A0%2C%5C%22runDist%5C%22%3A23%2C%5C%22runCal%5C%22%3A3%7D%2C%5C%22goal%5C%22%3A8000%2C%5C%22tz%5C%22%3A%5C%2228800%5C%22%2C%5C%22sn%5C%22%3A%5C%22e716882f93da%5C%22%7D%22%2C%22source%22%3A24%2C%22type%22%3A0%7D%5D'
finddate = re.compile(r'.*?date%22%3A%22(.*?)%22%2C%22data.*?')
findstep = re.compile(r'.*?ttl%5C%22%3A(.*?)%2C%5C%22dis.*?')
data_json = re.sub(finddate.findall(data_json)[0], today, str(data_json))
data_json = re.sub(findstep.findall(data_json)[0], step, str(data_json))
url = 'https://api-mifit-cn.huami.com/v1/data/band_data.json?&t={}'.format(t)
# 请求头
head = {
"apptoken": app_token,
"Content-Type": "application/x-www-form-urlencoded"
}
data = 'userid={}&last_sync_data_time=1597306380&device_type=0&last_deviceid=DA932FFFFE8816E7&data_json={}'.format(
user_id, data_json)
response = requests.post(url, data=data, headers=head).json()
# 解析返回成功的json数据 并提取 返回状态信息
result = "时间:{}\n修改步数为:{}".format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), step) + "\n状态:" + response.get('message')
return result


if __name__ == '__main__':
# 程序调用 设置相应的账号和密码 以及需要刷的步数 如果步数step为空 则会自动随机一个10000~19999之间的步数
res = domain(user="你的小米账号", pwd="你的小米账号密码", step=你需要刷入的步数)
print(res)
# 调用server酱 发送微信信息
vx_server(message=res)

运行截图

本文标题:python实现小米运动多方刷步

文章作者:fanchen

发布时间:2021年02月02日 - 20:10:53

最后更新:2021年02月05日 - 18:28:13

原始链接:http://88fanchen.github.io/posts/8ecfb50e/

许可协议:署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。