修复天翼云盘签到
本帖最后由 bake 于 2024-8-19 11:50 编辑请求频繁被拦截了,加了随机延迟。
每天150M空间
"""
https://www.52pojie.cn/thread-1231190-1-1.html
感谢作者开源天翼云签到部分源码:
https://github.com/t00t00-crypto/cloud189-action/blob/master/checkin.py 及 (https://github.com/Dawnnnnnn/Cloud189/blob/master/functions/login_function.py)
"""
import time
import re
import json
import base64
import hashlib
# from urllib import parse
import urllib.parse,hmac
import rsa
import requests
import random
BI_RM = list("0123456789abcdefghijklmnopqrstuvwxyz")
B64MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
s = requests.Session()
# 在下面两行的引号内贴上账号(仅支持手机号)和密码
username = ""
password = ""
_ = """
if(username == "" or password == ""):
username = input("账号:")
password = input("密码:")
# """
assert username and password, "在第23、24行填入有效账号和密码"
# 钉钉机器人token 申请key 并设置密钥
ddtoken = ""
ddsecret = ""
# xuthuskey = "27a...........................7b"
if not ddtoken:
print("第36行的ddtoken 为空,签到结果将不会通过钉钉发送")
def int2char(a):
return BI_RM
def b64tohex(a):
d = ""
e = 0
c = 0
for i in range(len(a)):
if list(a) != "=":
v = B64MAP.index(list(a))
if 0 == e:
e = 1
d += int2char(v >> 2)
c = 3 & v
elif 1 == e:
e = 2
d += int2char(c << 2 | v >> 4)
c = 15 & v
elif 2 == e:
e = 3
d += int2char(c)
d += int2char(v >> 2)
c = 3 & v
else:
e = 0
d += int2char(c << 2 | v >> 4)
d += int2char(15 & v)
if e == 1:
d += int2char(c << 2)
return d
def rsa_encode(j_rsakey, string):
rsa_key = f"-----BEGIN PUBLIC KEY-----\n{j_rsakey}\n-----END PUBLIC KEY-----"
pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(rsa_key.encode())
result = b64tohex((base64.b64encode(rsa.encrypt(f'{string}'.encode(), pubkey))).decode())
return result
def calculate_md5_sign(params):
return hashlib.md5('&'.join(sorted(params.split('&'))).encode('utf-8')).hexdigest()
def login(username, password):
#https://m.cloud.189.cn/login2014.jsp?redirectURL=https://m.cloud.189.cn/zhuanti/2021/shakeLottery/index.html
url=""
urlToken="https://m.cloud.189.cn/udb/udb_login.jsp?pageId=1&pageKey=default&clientType=wap&redirectURL=https://m.cloud.189.cn/zhuanti/2021/shakeLottery/index.html"
s = requests.Session()
r = s.get(urlToken)
pattern = r"https?://[^\s'\"]+"# 匹配以http或https开头的url
match = re.search(pattern, r.text)# 在文本中搜索匹配
if match:# 如果找到匹配
url = match.group()# 获取匹配的字符串
print(url)# 打印url
else:# 如果没有找到匹配
print("没有找到url")
r = s.get(url)
# print(r.text)
pattern = r"<a id=\"j-tab-login-link\"[^>]*href=\"([^\"]+)\""# 匹配id为j-tab-login-link的a标签,并捕获href引号内的内容
match = re.search(pattern, r.text)# 在文本中搜索匹配
if match:# 如果找到匹配
href = match.group(1)# 获取捕获的内容
print("href:" + href)# 打印href链接
else:# 如果没有找到匹配
print("没有找到href链接")
r = s.get(href)
captchaToken = re.findall(r"captchaToken' value='(.+?)'", r.text)
lt = re.findall(r'lt = "(.+?)"', r.text)
returnUrl = re.findall(r"returnUrl= '(.+?)'", r.text)
paramId = re.findall(r'paramId = "(.+?)"', r.text)
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', r.text, re.M)
s.headers.update({"lt": lt})
username = rsa_encode(j_rsakey, username)
password = rsa_encode(j_rsakey, password)
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0',
'Referer': 'https://open.e.189.cn/',
}
data = {
"appKey": "cloud",
"accountType": '01',
"userName": f"{{RSA}}{username}",
"password": f"{{RSA}}{password}",
"validateCode": "",
"captchaToken": captchaToken,
"returnUrl": returnUrl,
"mailSuffix": "@189.cn",
"paramId": paramId
}
r = s.post(url, data=data, headers=headers, timeout=5)
if (r.json()['result'] == 0):
print(r.json()['msg'])
else:
print(r.json()['msg'])
redirect_url = r.json()['toUrl']
r = s.get(redirect_url)
return s
def main():
s=login(username, password)
rand = str(round(time.time() * 1000))
surl = f'https://api.cloud.189.cn/mkt/userSign.action?rand={rand}&clientType=TELEANDROID&version=8.6.3&model=SM-G930K'
url = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN&activityId=ACT_SIGNIN'
url2 = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN_PHOTOS&activityId=ACT_SIGNIN'
url3 = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_2022_FLDFS_KJ&activityId=ACT_SIGNIN'
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; SM-G930K Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 Ecloud/8.6.3 Android/22 clientId/355325117317828 clientModel/SM-G930K imsi/460071114317824 clientChannelId/qq proVersion/1.0.6',
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1",
"Host": "m.cloud.189.cn",
"Accept-Encoding": "gzip, deflate",
}
response = s.get(surl, headers=headers)
netdiskBonus = response.json()['netdiskBonus']
if (response.json()['isSign'] == "false"):
print(f"未签到,签到获得{netdiskBonus}M空间")
res1 = f"未签到,签到获得{netdiskBonus}M空间"
else:
print(f"已经签到过了,签到获得{netdiskBonus}M空间")
res1 = f"已经签到过了,签到获得{netdiskBonus}M空间"
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; SM-G930K Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 Ecloud/8.6.3 Android/22 clientId/355325117317828 clientModel/SM-G930K imsi/460071114317824 clientChannelId/qq proVersion/1.0.6',
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1",
"Host": "m.cloud.189.cn",
"Accept-Encoding": "gzip, deflate",
}
response = s.get(url, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res2 = ""
else:
description = response.json()['description']
print(f"抽奖获得{description}")
res2 = f"抽奖获得{description}"
time.sleep(random.randint(5, 10))
response = s.get(url2, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res3 = ""
else:
description = response.json()['prizeName']
print(f"抽奖获得{description}")
res3 = f"抽奖获得{description}"
time.sleep(random.randint(5, 10))
response = s.get(url3, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res4 = ""
else:
description = response.json()['prizeName']
print(f"链接3抽奖获得{description}")
res4 = f"链接3抽奖获得{description}"
if ddtoken.strip():
_ = ddtoken.strip()
# requests.get(f"https://push.xuthus.cc/send/{_}?c=func compute: {res1}, {res2}, {res3}")
# data = {"msgtype": "markdown", "markdown": { "title":f"sing189","text":f"hk1:sing189 \n> {res1} \n>{res2}{res3}{res4}"}}
# requests.post(f"https://oapi.dingtalk.com/robot/send?access_token={_}", json=data,)
timestamp = str(round(time.time() * 1000))
secret_enc = ddsecret.encode('utf-8')
string_to_sign = '{}\n{}'.format(timestamp, ddsecret)
string_to_sign_enc = string_to_sign.encode('utf-8')
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
url = f'https://oapi.dingtalk.com/robot/send'
params={"access_token":ddtoken,"timestamp":timestamp,"sign":sign}
headers = {"Content-Type": "application/json;charset=utf-8"}
data = {"msgtype": "markdown",
"markdown": {"title": f"sing189", "text": f"sing189 \n> {res1} \n>{res2}{res3}{res4}"}}
response = requests.post(
url=url, data=json.dumps(data), headers=headers, timeout=15,params=params
).json()
if not response["errcode"]:
print("钉钉机器人 推送成功!")
else:
print("钉钉机器人 推送失败!")
def lambda_handler(event, context):# aws default
main()
def main_handler(event, context):# tencent default
main()
def handler(event, context):# aliyun default
main()
if __name__ == "__main__":
# time.sleep(random.randint(5, 30))
main()
改了多账号
import timeimport re
import json
import base64
import hashlib
# from urllib import parse
import urllib.parse,hmac
import rsa
import requests
import random
BI_RM = list("0123456789abcdefghijklmnopqrstuvwxyz")
B64MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
s = requests.Session()
accounts = [
{"username": "", "password": ""},
{"username": "", "password": ""},
{"username": "", "password": ""},
]
#填入pushplus token
pushplus_token = ""
# 钉钉机器人token 申请key 并设置密钥
ddtoken = ""
ddsecret = ""
# xuthuskey = "27a...........................7b"
if not ddtoken:
print("第36行的ddtoken 为空,签到结果将不会通过钉钉发送")
def int2char(a):
return BI_RM
def b64tohex(a):
d = ""
e = 0
c = 0
for i in range(len(a)):
if list(a) != "=":
v = B64MAP.index(list(a))
if 0 == e:
e = 1
d += int2char(v >> 2)
c = 3 & v
elif 1 == e:
e = 2
d += int2char(c << 2 | v >> 4)
c = 15 & v
elif 2 == e:
e = 3
d += int2char(c)
d += int2char(v >> 2)
c = 3 & v
else:
e = 0
d += int2char(c << 2 | v >> 4)
d += int2char(15 & v)
if e == 1:
d += int2char(c << 2)
return d
def rsa_encode(j_rsakey, string):
rsa_key = f"-----BEGIN PUBLIC KEY-----\n{j_rsakey}\n-----END PUBLIC KEY-----"
pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(rsa_key.encode())
result = b64tohex((base64.b64encode(rsa.encrypt(f'{string}'.encode(), pubkey))).decode())
return result
def calculate_md5_sign(params):
return hashlib.md5('&'.join(sorted(params.split('&'))).encode('utf-8')).hexdigest()
def login(username, password):
#https://m.cloud.189.cn/login2014.jsp?redirectURL=https://m.cloud.189.cn/zhuanti/2021/shakeLottery/index.html
url=""
urlToken="https://m.cloud.189.cn/udb/udb_login.jsp?pageId=1&pageKey=default&clientType=wap&redirectURL=https://m.cloud.189.cn/zhuanti/2021/shakeLottery/index.html"
s = requests.Session()
r = s.get(urlToken)
pattern = r"https?://[^\s'\"]+"# 匹配以http或https开头的url
match = re.search(pattern, r.text)# 在文本中搜索匹配
if match:# 如果找到匹配
url = match.group()# 获取匹配的字符串
# print(url)# 打印url
else:# 如果没有找到匹配
print("没有找到url")
r = s.get(url)
# print(r.text)
pattern = r"<a id=\"j-tab-login-link\"[^>]*href=\"([^\"]+)\""# 匹配id为j-tab-login-link的a标签,并捕获href引号内的内容
match = re.search(pattern, r.text)# 在文本中搜索匹配
if match:# 如果找到匹配
href = match.group(1)# 获取捕获的内容
# print("href:" + href)# 打印href链接
else:# 如果没有找到匹配
print("没有找到href链接")
r = s.get(href)
captchaToken = re.findall(r"captchaToken' value='(.+?)'", r.text)
lt = re.findall(r'lt = "(.+?)"', r.text)
returnUrl = re.findall(r"returnUrl= '(.+?)'", r.text)
paramId = re.findall(r'paramId = "(.+?)"', r.text)
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', r.text, re.M)
s.headers.update({"lt": lt})
username = rsa_encode(j_rsakey, username)
password = rsa_encode(j_rsakey, password)
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0',
'Referer': 'https://open.e.189.cn/',
}
data = {
"appKey": "cloud",
"accountType": '01',
"userName": f"{{RSA}}{username}",
"password": f"{{RSA}}{password}",
"validateCode": "",
"captchaToken": captchaToken,
"returnUrl": returnUrl,
"mailSuffix": "@189.cn",
"paramId": paramId
}
r = s.post(url, data=data, headers=headers, timeout=5)
if (r.json()['result'] == 0):
print(r.json()['msg'])
else:
print(r.json()['msg'])
redirect_url = r.json()['toUrl']
r = s.get(redirect_url)
return s
def main():
for account in accounts:
username = account["username"]
password = account["password"]
s = login(username, password)
if s is not None:
rand = str(round(time.time() * 1000))
surl = f'https://api.cloud.189.cn/mkt/userSign.action?rand={rand}&clientType=TELEANDROID&version=8.6.3&model=SM-G930K'
url = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN&activityId=ACT_SIGNIN'
url2 = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN_PHOTOS&activityId=ACT_SIGNIN'
url3 = f'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_2022_FLDFS_KJ&activityId=ACT_SIGNIN'
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; SM-G930K Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 Ecloud/8.6.3 Android/22 clientId/355325117317828 clientModel/SM-G930K imsi/460071114317824 clientChannelId/qq proVersion/1.0.6',
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1",
"Host": "m.cloud.189.cn",
"Accept-Encoding": "gzip, deflate",
}
response = s.get(surl, headers=headers)
netdiskBonus = response.json()['netdiskBonus']
if (response.json()['isSign'] == "false"):
print(f"未签到,签到获得{netdiskBonus}M空间")
res1 = f"未签到,签到获得{netdiskBonus}M空间"
else:
print(f"已经签到过了,签到获得{netdiskBonus}M空间")
res1 = f"已经签到过了,签到获得{netdiskBonus}M空间"
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; SM-G930K Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36 Ecloud/8.6.3 Android/22 clientId/355325117317828 clientModel/SM-G930K imsi/460071114317824 clientChannelId/qq proVersion/1.0.6',
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1",
"Host": "m.cloud.189.cn",
"Accept-Encoding": "gzip, deflate",
}
response = s.get(url, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res2 = ""
else:
description = response.json()['description']
print(f"抽奖获得{description}")
res2 = f"抽奖获得{description}"
time.sleep(random.randint(5, 10))
response = s.get(url2, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res3 = ""
else:
description = response.json()['prizeName']
print(f"抽奖获得{description}")
res3 = f"抽奖获得{description}"
time.sleep(random.randint(5, 10))
response = s.get(url3, headers=headers)
if ("errorCode" in response.text):
print(response.text)
res4 = ""
else:
description = response.json()['prizeName']
print(f"链接3抽奖获得{description}")
res4 = f"链接3抽奖获得{description}"
if ddtoken.strip():
_ = ddtoken.strip()
timestamp = str(round(time.time() * 1000))
secret_enc = ddsecret.encode('utf-8')
string_to_sign = '{}\n{}'.format(timestamp, ddsecret)
string_to_sign_enc = string_to_sign.encode('utf-8')
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
url = f'https://oapi.dingtalk.com/robot/send?access_token={ddtoken}×tamp={timestamp}&sign={sign}'
headers = {"Content-Type": "application/json;charset=utf-8"}
data = {
"msgtype": "markdown",
"markdown": {
"title": f"sing189",
"text": f"sing189 \n> {res1} \n>{res2}{res3}{res4}"
}
}
response = requests.post(
url=url, data=json.dumps(data), headers=headers, timeout=15
).json()
if not response["errcode"]:
print("钉钉机器人 推送成功!")
else:
print("钉钉机器人 推送失败!")
if pushplus_token:
title = '天翼云盘签到'
url = 'http://www.pushplus.plus/send'
data = {
"token": pushplus_token,
"title": title,
"content": f'{username}\n{res1}\n{res2}\n{res3}\n{res4}\n',
}
body = json.dumps(data).encode(encoding='utf-8')
headers = {'Content-Type': 'application/json'}
requests.post(url, data=body, headers=headers)
def lambda_handler(event, context):# aws default
main()
def main_handler(event, context):# tencent default
main()
def handler(event, context):# aliyun default
main()
if __name__ == "__main__":
# time.sleep(random.randint(5, 30))
main() 本帖最后由 bake 于 2024-8-15 15:26 编辑
panyang199044 发表于 2024-8-15 14:51
钉钉推送失败的原因朋友帮我找到了,非常感谢他,
是这里少了一个值,加上 , params=params就好了,
确实是漏了这个,原本是拼在url后面的,但是timestamp会被编辑器过滤成错误的代码 本帖最后由 bake 于 2024-4-23 11:27 编辑
需要多账号的看原帖评论区 https://www.52pojie.cn/thread-1784111-1-1.html
加上延迟就可以time.sleep(random.randint(5, 10)) cenoser795 发表于 2024-4-23 12:06
感谢楼主
请问
天翼云盘是不是必须得有电信的手机号才行啊?
不需要,常年使用联通手机号登录天翼云盘 本帖最后由 传闻中的喜哥哥 于 2024-4-24 08:38 编辑
空间是有了但是这日志是什么情况
登录信息?
钉钉推送失败的原因朋友帮我找到了,非常感谢他,
是这里少了一个值,加上 , params=params就好了, 好东西,感谢分享 好东西,感谢分享 感谢楼主
请问
天翼云盘是不是必须得有电信的手机号才行啊? 能否出个教程??不会使用 感谢分享👍👍👍👍 谢谢楼主分享!收藏备用! cenoser795 发表于 2024-4-23 12:06
感谢楼主
请问
天翼云盘是不是必须得有电信的手机号才行啊?
其他号码也可以 lsmh 发表于 2024-4-23 12:14
能否出个教程??不会使用
论坛内搜索一下云函数或者青龙面板