1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
:source https://github.com/MayoBlueSky/My-Actions/blob/master/function/cloud189/checkin.py |
4
|
|
|
cron: 30 9 * * * |
5
|
|
|
new Env('天翼云盘'); |
6
|
|
|
""" |
7
|
|
|
|
8
|
|
|
import base64 |
9
|
|
|
import re |
10
|
|
|
import time |
11
|
|
|
|
12
|
|
|
import requests |
13
|
|
|
import rsa |
14
|
|
|
|
15
|
|
|
from notify_mtr import send |
16
|
|
|
from utils import get_data |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
class Cloud189: |
20
|
|
|
def __init__(self, check_items): |
21
|
|
|
self.check_items = check_items |
22
|
|
|
self.b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" |
23
|
|
|
|
24
|
|
|
@staticmethod |
25
|
|
|
def int2char(a): |
26
|
|
|
return list("0123456789abcdefghijklmnopqrstuvwxyz")[a] |
27
|
|
|
|
28
|
|
|
def b64tohex(self, a): |
29
|
|
|
d = "" |
30
|
|
|
e = 0 |
31
|
|
|
c = 0 |
32
|
|
|
for i in range(len(a)): |
33
|
|
|
if list(a)[i] != "=": |
34
|
|
|
v = self.b64map.index(list(a)[i]) |
35
|
|
|
if e == 0: |
36
|
|
|
e = 1 |
37
|
|
|
d += self.int2char(v >> 2) |
38
|
|
|
c = 3 & v |
39
|
|
|
elif e == 1: |
40
|
|
|
e = 2 |
41
|
|
|
d += self.int2char(c << 2 | v >> 4) |
42
|
|
|
c = 15 & v |
43
|
|
|
elif e == 2: |
44
|
|
|
e = 3 |
45
|
|
|
d += self.int2char(c) |
46
|
|
|
d += self.int2char(v >> 2) |
47
|
|
|
c = 3 & v |
48
|
|
|
else: |
49
|
|
|
e = 0 |
50
|
|
|
d += self.int2char(c << 2 | v >> 4) |
51
|
|
|
d += self.int2char(15 & v) |
52
|
|
|
if e == 1: |
53
|
|
|
d += self.int2char(c << 2) |
54
|
|
|
return d |
55
|
|
|
|
56
|
|
|
def rsa_encode(self, j_rsakey, string): |
57
|
|
|
rsa_key = f"-----BEGIN PUBLIC KEY-----\n{j_rsakey}\n-----END PUBLIC KEY-----" |
58
|
|
|
pubkey = rsa.PublicKey.load_pkcs1_openssl_pem(rsa_key.encode()) |
59
|
|
|
return self.b64tohex( |
60
|
|
|
(base64.b64encode(rsa.encrypt(f"{string}".encode(), pubkey))).decode() |
61
|
|
|
) |
62
|
|
|
|
63
|
|
|
def login(self, session, username, password): |
64
|
|
|
url = ( |
65
|
|
|
"https://cloud.189.cn/api/portal/loginUrl.action?" |
66
|
|
|
"redirectURL=https://cloud.189.cn/web/redirect.html" |
67
|
|
|
) |
68
|
|
|
res = session.get(url).text |
69
|
|
|
captchatoken = re.findall(r"captchaToken' value='(.+?)'", res)[0] |
70
|
|
|
lt = re.findall(r'lt = "(.+?)"', res)[0] |
71
|
|
|
returnurl = re.findall(r"returnUrl = '(.+?)'", res)[0] |
72
|
|
|
paramid = re.findall(r'paramId = "(.+?)"', res)[0] |
73
|
|
|
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', res, re.M)[0] |
74
|
|
|
|
75
|
|
|
session.headers.update({"lt": lt}) |
76
|
|
|
username = self.rsa_encode(j_rsakey, username) |
77
|
|
|
password = self.rsa_encode(j_rsakey, password) |
78
|
|
|
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do" |
79
|
|
|
headers = { |
80
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) " |
81
|
|
|
"Gecko/20100101 Firefox/76.0", |
82
|
|
|
"Referer": "https://open.e.189.cn/", |
83
|
|
|
} |
84
|
|
|
data = { |
85
|
|
|
"appKey": "cloud", |
86
|
|
|
"accountType": "01", |
87
|
|
|
"userName": f"{{RSA}}{username}", |
88
|
|
|
"password": f"{{RSA}}{password}", |
89
|
|
|
"validateCode": "", |
90
|
|
|
"captchaToken": captchatoken, |
91
|
|
|
"returnUrl": returnurl, |
92
|
|
|
"mailSuffix": "@189.cn", |
93
|
|
|
"paramId": paramid, |
94
|
|
|
} |
95
|
|
|
res = session.post(url, data=data, headers=headers, timeout=5).json() |
96
|
|
|
if res["result"] != 0: |
97
|
|
|
return "登陆状态: " + res["msg"] |
98
|
|
|
redirect_url = res["toUrl"] |
99
|
|
|
session.get(redirect_url) |
100
|
|
|
return True |
101
|
|
|
|
102
|
|
|
@staticmethod |
103
|
|
|
def sign(session): |
104
|
|
|
rand = round(time.time() * 1000) |
105
|
|
|
surl = ( |
106
|
|
|
f"https://api.cloud.189.cn/mkt/userSign.action?" |
107
|
|
|
f"rand={rand}&clientType=TELEANDROID&version=8.6.3&model=SM-G930K" |
108
|
|
|
) |
109
|
|
|
url = ( |
110
|
|
|
"https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?" |
111
|
|
|
"taskId=TASK_SIGNIN&activityId=ACT_SIGNIN" |
112
|
|
|
) |
113
|
|
|
url2 = ( |
114
|
|
|
"https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?" |
115
|
|
|
"taskId=TASK_SIGNIN_PHOTOS&activityId=ACT_SIGNIN" |
116
|
|
|
) |
117
|
|
|
headers = { |
118
|
|
|
"User-Agent": "Mozilla/5.0 (Linux; Android 5.1.1; SM-G930K Build/NRD90M; wv) " |
119
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 " |
120
|
|
|
"Chrome/74.0.3729.136 Mobile Safari/537.36 Ecloud/8.6.3 Android/22 " |
121
|
|
|
"clientId/355325117317828 clientModel/SM-G930K " |
122
|
|
|
"imsi/460071114317824 clientChannelId/qq proVersion/1.0.6", |
123
|
|
|
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1", |
124
|
|
|
"Host": "m.cloud.189.cn", |
125
|
|
|
"Accept-Encoding": "gzip, deflate", |
126
|
|
|
} |
127
|
|
|
response = session.get(surl, headers=headers) |
128
|
|
|
netdiskbonus = response.json().get("netdiskBonus") |
129
|
|
|
if response.json().get("isSign") == "false": |
130
|
|
|
msg = f"签到结果: 未签到,签到获得 {netdiskbonus}M 空间" |
131
|
|
|
else: |
132
|
|
|
msg = f"签到结果: 已经签到过了,签到获得 {netdiskbonus}M 空间" |
133
|
|
|
|
134
|
|
|
response = session.get(url, headers=headers) |
135
|
|
|
if "errorCode" in response.text: |
136
|
|
|
msg += f"\n第一次抽奖: {response.json().get('errorCode')}" |
137
|
|
|
else: |
138
|
|
|
description = response.json().get("description", "") |
139
|
|
|
if description in ["1", 1]: |
140
|
|
|
description = "50M 空间" |
141
|
|
|
msg += f"\n第一次抽奖: 获得 {description}" |
142
|
|
|
|
143
|
|
|
response = session.get(url2, headers=headers) |
144
|
|
|
if "errorCode" in response.text: |
145
|
|
|
msg += f"\n第二次抽奖: {response.json().get('errorCode')}" |
146
|
|
|
else: |
147
|
|
|
description = response.json().get("description", "") |
148
|
|
|
if description in ["1", 1]: |
149
|
|
|
description = "50M 空间" |
150
|
|
|
msg += f"\n第二次抽奖: 获得 {description}" |
151
|
|
|
return msg |
152
|
|
|
|
153
|
|
|
def main(self): |
154
|
|
|
msg_all = "" |
155
|
|
|
for check_item in self.check_items: |
156
|
|
|
phone = check_item.get("phone") |
157
|
|
|
password = check_item.get("password") |
158
|
|
|
session = requests.Session() |
159
|
|
|
flag = self.login(session, phone, password) |
160
|
|
|
sign_msg = self.sign(session) if flag is True else flag |
161
|
|
|
msg = f"帐号信息: *******{phone[-4:]}\n{sign_msg}" |
162
|
|
|
msg_all += msg + "\n\n" |
163
|
|
|
return msg_all |
164
|
|
|
|
165
|
|
|
|
166
|
|
|
if __name__ == "__main__": |
167
|
|
|
_data = get_data() |
168
|
|
|
_check_items = _data.get("CLOUD189", []) |
169
|
|
|
result = Cloud189(check_items=_check_items).main() |
170
|
|
|
send("天翼云盘", result) |
171
|
|
|
|