forked from yuxian158/check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_cloud189.py
155 lines (140 loc) · 6.05 KB
/
ck_cloud189.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
# -*- coding: utf-8 -*-
# 21 9 * * *
import base64
import json
import os
import re
import time
import requests
import rsa
from getENV import getENv
from checksendNotify import send
class Cloud189CheckIn:
def __init__(self, check_item: dict):
self.check_item = check_item
self.b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
@staticmethod
def int2char(a):
return list("0123456789abcdefghijklmnopqrstuvwxyz")[a]
def b64tohex(self, a):
d = ""
e = 0
c = 0
for i in range(len(a)):
if list(a)[i] != "=":
v = self.b64map.index(list(a)[i])
if 0 == e:
e = 1
d += self.int2char(v >> 2)
c = 3 & v
elif 1 == e:
e = 2
d += self.int2char(c << 2 | v >> 4)
c = 15 & v
elif 2 == e:
e = 3
d += self.int2char(c)
d += self.int2char(v >> 2)
c = 3 & v
else:
e = 0
d += self.int2char(c << 2 | v >> 4)
d += self.int2char(15 & v)
if e == 1:
d += self.int2char(c << 2)
return d
def rsa_encode(self, 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 = self.b64tohex((base64.b64encode(rsa.encrypt(f"{string}".encode(), pubkey))).decode())
return result
def login(self, session, username, password):
url = "https://cloud.189.cn/udb/udb_login.jsp?pageId=1&redirectURL=/main.action"
r = session.get(url=url)
captchatoken = re.findall(r"captchaToken' value='(.+?)'", r.text)[0]
lt = re.findall(r'lt = "(.+?)"', r.text)[0]
returnurl = re.findall(r"returnUrl = '(.+?)'", r.text)[0]
paramid = re.findall(r'paramId = "(.+?)"', r.text)[0]
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', r.text, re.M)[0]
session.headers.update({"lt": lt})
username = self.rsa_encode(j_rsakey, username)
password = self.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 = session.post(url, data=data, headers=headers, timeout=5)
if r.json()["result"] == 0:
redirect_url = r.json()["toUrl"]
session.get(url=redirect_url)
return True
else:
return "登陆状态: " + r.json()["msg"]
@staticmethod
def sign(session):
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 = "https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN&activityId=ACT_SIGNIN"
url2 = "https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN_PHOTOS&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 = session.get(url=surl, headers=headers)
netdiskbonus = response.json().get("netdiskBonus")
if response.json().get("isSign") == "false":
msg = f"签到结果: 未签到,签到获得 {netdiskbonus}M 空间"
else:
msg = f"签到结果: 已经签到过了,签到获得 {netdiskbonus}M 空间"
response = session.get(url=url, headers=headers)
if "errorCode" in response.text:
msg += f"\n第一次抽奖: {response.json().get('errorCode')}"
else:
description = response.json().get("description", "")
if description in ["1", 1]:
description = "50M空间"
msg += f"\n第一次抽奖: 获得{description}"
response = session.get(url=url2, headers=headers)
if "errorCode" in response.text:
msg += f"\n第二次抽奖: {response.json().get('errorCode')}"
else:
description = response.json().get("description", "")
if description in ["1", 1]:
description = "50M空间"
msg += f"\n第二次抽奖: 获得{description}"
return msg
def main(self):
cloud189_phone = self.check_item.get("cloud189_phone")
cloud189_password = self.check_item.get("cloud189_password")
session = requests.Session()
flag = self.login(session=session, username=cloud189_phone, password=cloud189_password)
if flag is True:
sign_msg = self.sign(session=session)
else:
sign_msg = flag
msg = f"帐号信息: {cloud189_phone}\n{sign_msg}"
return msg
def start():
getENv()
with open("/ql/config/check.json", "r", encoding="utf-8") as f:
datas = json.loads(f.read())
_check_item = datas.get("CLOUD189_ACCOUNT_LIST", [])[0]
res = Cloud189CheckIn(check_item=_check_item).main()
print(res)
send('天翼网盘', res)
if __name__ == "__main__":
start()