mirror of
https://github.com/blusunny/qinglong.git
synced 2025-12-21 01:04:37 +08:00
287 lines
11 KiB
Python
287 lines
11 KiB
Python
# !/usr/bin/python3
|
||
# -- coding: utf-8 --
|
||
# -------------------------------
|
||
# const $ = new Env('天翼云盘签到');
|
||
|
||
import base64
|
||
import hashlib
|
||
import os
|
||
import re
|
||
import time
|
||
import requests
|
||
import rsa
|
||
from os import path
|
||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||
|
||
# import CHERWIN_TOOLS
|
||
# 禁用安全请求警告
|
||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||
IS_DEV = False
|
||
if os.path.isfile('DEV_ENV.py'):
|
||
import DEV_ENV
|
||
IS_DEV = True
|
||
if os.path.isfile('notify.py'):
|
||
from notify import send
|
||
print("加载通知服务成功!")
|
||
else:
|
||
print("加载通知服务失败!")
|
||
send_msg = ''
|
||
one_msg=''
|
||
def Log(cont=''):
|
||
global send_msg,one_msg
|
||
print(cont)
|
||
if cont:
|
||
one_msg += f'{cont}\n'
|
||
send_msg += f'{cont}\n'
|
||
|
||
class RUN:
|
||
def __init__(self,info,index):
|
||
global one_msg
|
||
one_msg = ''
|
||
split_info = info.split('@')
|
||
self.userid = split_info[0]
|
||
self.pwd = split_info[1]
|
||
len_split_info = len(split_info)
|
||
last_info = split_info[len_split_info - 1]
|
||
self.send_UID = None
|
||
if len_split_info > 0 and "UID_" in last_info:
|
||
print('检测到设置了UID')
|
||
print(last_info)
|
||
self.send_UID = last_info
|
||
self.index = index + 1
|
||
|
||
self.b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||
self.UA = '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'
|
||
self.headers = {
|
||
'User-Agent': self.UA,
|
||
"Referer": "https://m.cloud.189.cn/zhuanti/2016/sign/index.jsp?albumBackupOpened=1",
|
||
"Host": "m.cloud.189.cn",
|
||
"Accept-Encoding": "gzip, deflate",
|
||
}
|
||
|
||
@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 e == 0:
|
||
e = 1
|
||
d += self.int2char(v >> 2)
|
||
c = 3 & v
|
||
elif e == 1:
|
||
e = 2
|
||
d += self.int2char(c << 2 | v >> 4)
|
||
c = 15 & v
|
||
elif e == 2:
|
||
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())
|
||
return self.b64tohex(
|
||
(base64.b64encode(rsa.encrypt(f"{string}".encode(), pubkey))).decode()
|
||
)
|
||
|
||
def login(self):
|
||
# 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"
|
||
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) # 获取捕获的内容
|
||
r = s.get(href)
|
||
# print("href:" + href) # 打印href链接
|
||
else: # 如果没有找到匹配
|
||
print("没有找到href链接")
|
||
exit()
|
||
|
||
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]
|
||
s.headers.update({"lt": lt})
|
||
|
||
username = self.rsa_encode(j_rsakey, self.userid)
|
||
password = self.rsa_encode(j_rsakey, self.pwd)
|
||
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
||
headers = {
|
||
'User-Agent': self.UA,
|
||
'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):
|
||
Log('登陆成功!')
|
||
print(r.json()['msg'])
|
||
else:
|
||
Log('登陆失败!')
|
||
print(r.json()['msg'])
|
||
redirect_url = r.json()['toUrl']
|
||
r = s.get(redirect_url)
|
||
if r.status_code == 200:
|
||
return r
|
||
else:
|
||
return False
|
||
|
||
def signIn(self):
|
||
Log('>>>>>>签到')
|
||
rand = str(round(time.time() * 1000))
|
||
# print(rand)
|
||
surl = f'https://api.cloud.189.cn/mkt/userSign.action?rand={rand}&clientType=TELEANDROID&version=8.6.3&model=SM-G930K'
|
||
|
||
response = s.get(surl, headers=self.headers)
|
||
netdiskBonus = response.json()['netdiskBonus']
|
||
if (response.json().get('isSign','false') == "false"):
|
||
Log(f"未签到,签到获得{netdiskBonus}M空间\n")
|
||
else:
|
||
Log(f"已经签到过了,签到获得{netdiskBonus}M空间\n")
|
||
|
||
def lottery(self):
|
||
Log('>>>>>>抽奖')
|
||
url_list = ['https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN&activityId=ACT_SIGNIN',
|
||
'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_SIGNIN_PHOTOS&activityId=ACT_SIGNIN',
|
||
'https://m.cloud.189.cn/v2/drawPrizeMarketDetails.action?taskId=TASK_2022_FLDFS_KJ&activityId=ACT_SIGNIN']
|
||
for index, urls in enumerate(url_list):
|
||
response = s.get(urls, headers=self.headers)
|
||
if ("errorCode" in response.text):
|
||
Log(f"链接{index + 1}抽奖失败")
|
||
print(response.text)
|
||
else:
|
||
description = response.json()['prizeName']
|
||
Log(f"链接{index + 1}抽奖获得{description}\n")
|
||
|
||
def main(self):
|
||
Log(f"\n开始执行第{self.index}个账号【{self.userid[-4:]}】--------------->>>>>")
|
||
if not self.login():
|
||
print(f'\n第{self.index}个账号【{self.userid[-4:]}登陆失败!')
|
||
return False
|
||
self.signIn()
|
||
self.lottery()
|
||
self.sendMsg()
|
||
return True
|
||
|
||
def sendMsg(self):
|
||
if self.send_UID:
|
||
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME)
|
||
print(push_res)
|
||
|
||
|
||
def down_file(filename, file_url):
|
||
print(f'开始下载:{filename},下载地址:{file_url}')
|
||
try:
|
||
response = requests.get(file_url, verify=False, timeout=10)
|
||
response.raise_for_status()
|
||
with open(filename + '.tmp', 'wb') as f:
|
||
f.write(response.content)
|
||
print(f'【{filename}】下载完成!')
|
||
|
||
# 检查临时文件是否存在
|
||
temp_filename = filename + '.tmp'
|
||
if os.path.exists(temp_filename):
|
||
# 删除原有文件
|
||
if os.path.exists(filename):
|
||
os.remove(filename)
|
||
# 重命名临时文件
|
||
os.rename(temp_filename, filename)
|
||
print(f'【{filename}】重命名成功!')
|
||
return True
|
||
else:
|
||
print(f'【{filename}】临时文件不存在!')
|
||
return False
|
||
except Exception as e:
|
||
print(f'【{filename}】下载失败:{str(e)}')
|
||
return False
|
||
|
||
def import_Tools():
|
||
global CHERWIN_TOOLS,ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
|
||
import CHERWIN_TOOLS
|
||
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
|
||
|
||
if __name__ == '__main__':
|
||
APP_NAME = '天翼云盘'
|
||
ENV_NAME = 'TYYP'
|
||
CK_NAME = '手机号@密码'
|
||
print(f'''
|
||
✨✨✨ {APP_NAME}签到抽奖✨✨✨
|
||
✨ 功能:
|
||
签到
|
||
抽奖
|
||
参数示例:18888888888@123456
|
||
✨ 设置青龙变量:
|
||
export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割
|
||
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
|
||
✨ 推荐cron:0 9 * * *
|
||
✨✨✨ @Author CHERWIN✨✨✨
|
||
''')
|
||
local_script_name = os.path.basename(__file__)
|
||
local_version = '2024.05.15'
|
||
if IS_DEV:
|
||
import_Tools()
|
||
else:
|
||
if os.path.isfile('CHERWIN_TOOLS.py'):
|
||
import_Tools()
|
||
else:
|
||
if down_file('CHERWIN_TOOLS.py', 'https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py'):
|
||
print('脚本依赖下载完成请重新运行脚本')
|
||
import_Tools()
|
||
else:
|
||
print(
|
||
'脚本依赖下载失败,请到https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/CHERWIN_TOOLS.py下载最新版本依赖')
|
||
exit()
|
||
print(TIPS)
|
||
token = ''
|
||
token = ENV if ENV else token
|
||
if not token:
|
||
print(f"未填写{ENV_NAME}变量\n青龙可在环境变量设置 {ENV_NAME} 或者在本脚本文件上方将{CK_NAME}填入token =''")
|
||
exit()
|
||
tokens = CHERWIN_TOOLS.ENV_SPLIT(token)
|
||
# print(tokens)
|
||
if len(tokens) > 0:
|
||
print(f"\n>>>>>>>>>>共获取到{len(tokens)}个账号<<<<<<<<<<")
|
||
access_token = []
|
||
for index, infos in enumerate(tokens):
|
||
s = requests.session()
|
||
s.verify=False
|
||
run_result = RUN(infos, index).main()
|
||
if not run_result: continue
|
||
if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML)
|