某米社区日常任务
代码写的很乱,大佬勿喷,嘴下留情自行安装响应的库,还有一个js的库”crypto-js”
目前只包含了浏览帖子和拔萝卜,后续更新日常签到,因某米账号有限,测试需要时间
import json
import re
import time
import urllib
import execjs
import requests
mobile = "这里填你的手机号"
pwd = '这里填你的密码'
deviceId = "这里填你的设备id" 格式:AAaAa1-aCC1aAAA1,自己抓包或者自己瞎编
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 14; 2211133C Build/UKQ1.230804.001) APP/xiaomi.vipaccount APPV/240123 MK/WGlhb21pIDEz "
"SDKV/5.1.0.release.18 PassportSDK/5.1.0.release.21 passport-ui/5.1.0.release.21",
"Host": "account.xiaomi.com",
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip"
}
# 取13位时间戳
def timestamp():
return int(round(time.time() * 1000))
# 32位大写MD5加密
def md5(str):
import hashlib
m = hashlib.md5()
m.update(str.encode('utf-8'))
return m.hexdigest().upper()
# 正则取出{}中的内容
def get_json(text):
start = text.find('{')
end = text.rfind('}')
return text
# 登陆
def login():
cookies1 = {
"userId": mobile,
"deviceId": deviceId
}
url1 = "https://account.xiaomi.com/pass/serviceLogin"
params1 = {
"_json": "true",
"sid": "miui_vip",
"_locale": "zh_CN"
}
# print('第一次请求头:', headers)
response1 = requests.get(url1, headers=headers, cookies=cookies1, params=params1)
response1 = json.loads(get_json(response1.text))
# print('第一次响应值:', response1)
# 第一次请求获取qs和_sign
cookies2 = {
"deviceId": deviceId
}
url2 = "https://account.xiaomi.com/pass/serviceLoginAuth2"
data = {
"qs": response1['qs'],
# ?_json=true&sid=miui_vip&_locale=zh_CN
"callback": "https://api.vip.miui.com/sts",
"_json": "true",
"_sign": response1['_sign'],
"user": mobile,
"hash": md5(pwd),# 密码
"sid": "miui_vip",
"_locale": "zh_CN"
}
headers["Content-Length"] = "241"
# print('第二次请求头:', headers)
response2 = requests.post(url2, headers=headers, cookies=cookies2, data=data)
response2 = json.loads(get_json(response2.text))
# print('第二次响应值:', response2)
if '成功' in response2['desc']:
print('登陆成功,开始提取miui_vip所需参数......')
else:
print('登陆失败')
location = response2['location']
# 将location进行url解码
location = urllib.parse.unquote(location)
# 正则表达式模式来匹配auth, nonce, 和_ssign参数的值
auth_pattern = r"auth=([^&]+)"
nonce_pattern = r"nonce=([^&]+)"
ssign_pattern = r"_ssign=([^&]+)"
# 使用re.search找到匹配的字符串
auth_match = re.search(auth_pattern, location)
nonce_match = re.search(nonce_pattern, location)
ssign_match = re.search(ssign_pattern, location)
# 如果找到匹配项,提取参数值
auth_value = auth_match.group(1) if auth_match else None
nonce_value = nonce_match.group(1) if nonce_match else None
ssign_value = ssign_match.group(1) if ssign_match else None
# 打印提取的值
print("auth:", auth_value)
print("nonce:", nonce_value)
print("_ssign:", ssign_value)
print('数据提取完成,等待发起miui_vip请求......')
return response2['nonce'], response2['ssecurity'], auth_value, nonce_value, ssign_value
login_info = login()
with open(r"xiaomi-sha-1-base64.js") as f:
ctx = execjs.compile(f.read())
clientSign = ctx.call('sha', 'nonce=' + str(login_info) + '&' + login_info)
def get_miui_vip():
cookies = {
"deviceId": deviceId
}
url = "https://api.vip.miui.com/sts"
params = {
"d": deviceId,
"ticket": "0",
"pwd": "1",
"p_ts": str(timestamp()),
"fid": "0",
"p_lm": "1",
"auth": login_info,
"m": "1",
"_group": "DEFAULT",
"tsl": "0",
"p_ca": "0",
"p_ur": "CN",
"p_idc": "China",
"nonce": login_info,
"_ssign": login_info,
"_userIdNeedEncrypt": "true",
"clientSign": clientSign
}
del headers['Content-Length']
headers['Host'] = 'api.vip.miui.com'
response = requests.get(url, headers=headers, cookies=cookies, params=params)
if response.json() == {'R': '', 'S': 'OK'}:
print('##################miui_vip数据获取成功##################')
else:
print('miui_vip数据获取失败')
# for i in response.cookies:
# print(i)
return response.cookies['cUserId'], response.cookies['miui_vip_ph'], response.cookies['miui_vip_serviceToken'], response.cookies['miui_vip_slh']
miui_vip_info = get_miui_vip()
print('cUserId:', miui_vip_info)
print('miui_vip_ph:', miui_vip_info)
print('miui_vip_serviceToken:', miui_vip_info)
print('miui_vip_slh:', miui_vip_info)
# 活动请求头
act_headers = {
"Host": "api.vip.miui.com",
"Connection": "keep-alive",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"sec-ch-ua": "\"Android WebView\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117\"",
"Accept": "application/json",
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryEW1J8DDHB8YZntmZ",
"sec-ch-ua-mobile": "?1",
"User-Agent": "Mozilla/5.0 (Linux; Android 14; 2211133C Build/UKQ1.230804.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36XiaoMi/HybridView/ app/vipaccount/dev.240123",
"sec-ch-ua-platform": "\"Android\"",
"Origin": "https://web.vip.miui.com",
"X-Requested-With": "com.xiaomi.vipaccount",
"Sec-Fetch-Site": "same-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://web.vip.miui.com/",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"
}
# 活动cookies
act_cookies = {
"cUserId": miui_vip_info,
"miui_vip_ph": miui_vip_info,
"miui_vip_slh": miui_vip_info,
"miui_vip_serviceToken": miui_vip_info
}
# 每日任务—拔萝卜
def Pluck_turnips():
print('开始每日任务拔萝卜......')
url = "https://api.vip.miui.com/api/carrot/pull"
params = {
"miui_vip_ph": miui_vip_info
}
headers = act_headers
headers["Content-Length"] = '166'
data = {
"------WebKitFormBoundarytBideCUbNWgxfi9W\nContent-Disposition: form-data; name": "\"miui_vip_ph\"\n\n" + miui_vip_info[
1] + "\n------WebKitFormBoundarytBideCUbNWgxfi9W--\n"
}
response = requests.post(url, headers=headers, cookies=act_cookies, params=params, data=data).json()
print(response)
# 每日任务-浏览帖子10s
def BROWSE_POST_10S():
url = "https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2"
params = {
"miui_vip_ph": miui_vip_info
}
headers = act_headers
headers['Content-Length'] = '274'
data = {
"------WebKitFormBoundaryEW1J8DDHB8YZntmZ\nContent-Disposition: form-data; name": "\"action\"\n\nBROWSE_POST_10S\n------WebKitFormBoundaryEW1J8DDHB8YZntmZ\nContent-Disposition: form-data; name=\"miui_vip_ph\"\n\n" +
miui_vip_info[
1] + "\n------WebKitFormBoundaryEW1J8DDHB8YZntmZ--\n"
}
response = requests.post(url, headers=headers, cookies=act_cookies, params=params, data=data).json()
print(response)
BROWSE_POST_10S()
Pluck_turnips()
var crypto_js = require("crypto-js");
function sha(str){
return crypto_js.enc.Base64.stringify(crypto_js.enc.Hex.parse(crypto_js.SHA1(str).toString()))
}
头脑发热的少年 发表于 2024-2-27 09:53
我用的proxypin,这个抓包工具可以root情况下可以直接刷证书模块,很方便
小米现在没法root 就是准备签到搞到5级 root 能给个参考么 非常感谢! 我是1级,连续好几天签到基本上都是1经验了,再加上浏览帖子10s的1,每天才加2,按这节奏一年也搞不到5级,前两天发现每周只开放4个15分钟的答题时间,据说题目还越来越BT……基本上宣布关闭解锁渠道啦!我现在用的不是小米,本来想换小米的,果断止损把小米社区删了{:1_927:} 好功能多多分享 想要你那个茅台.py。。。。。{:1_899:}
想要你那个茅台.py。。。。。 cnyuan 发表于 2024-2-22 17:20
想要你那个茅台.py。。。。。
是不是京东的,是i茅台app的申购,况且还没写好{:1_890:} 龙小邪 发表于 2024-2-22 12:30
想要你那个茅台.py。。。。。
是不是京东的,是i茅台app的申购,况且还没写好{:1_890:} 小米社区签到有验证 tianya0908 发表于 2024-2-23 13:49
小米社区签到有验证
极验三代验证,网上已经分析的很清楚了,照猫画虎 可以试着把 js 代码改成 Python 的 头脑发热的少年 发表于 2024-2-23 15:49
极验三代验证,网上已经分析的很清楚了,照猫画虎
捉不了包 没法搞 可以给个参考么 万分感谢
页:
[1]
2