重构结构

This commit is contained in:
limoruirui
2022-08-27 11:32:29 +08:00
parent 3cc4a67d38
commit 48f9205f25
18 changed files with 222 additions and 106882 deletions

32
777.js

File diff suppressed because one or more lines are too long

0
JS/.gitkeep Normal file
View File

View File

@@ -126,18 +126,6 @@ class Txsp_vipRed:
self.head = findall(r"\"head\":\"(.*?)\"", data)[0] self.head = findall(r"\"head\":\"(.*?)\"", data)[0]
self.nickname = findall(r"\"nick\":\"(.*?)\"", data)[0] self.nickname = findall(r"\"nick\":\"(.*?)\"", data)[0]
"""碰了别人的则上报别人的次数+1 用于计数别人的蛋有没有碰完 暂时未使用 后续观察情况再说"""
def laisee_id_success(self, laisee_id):
url = "https://api.ruirui.fun/txsp/laisee_id_success"
body = {
"laisee_id": laisee_id
}
try:
post(url, json=body)
except:
self.print_now("上报失败")
def get_laisee_id(self): def get_laisee_id(self):
url = "https://api.ruirui.fun/txsp/get_laisee_id" url = "https://api.ruirui.fun/txsp/get_laisee_id"
try: try:

View File

@@ -23,7 +23,7 @@ cookie = ""
iqiyi_dfp = "" iqiyi_dfp = ""
from time import sleep, time from time import sleep, time
from random import randint, choice from random import randint, choice
from json import dumps, loads from json import dumps
from hashlib import md5 as md5Encode from hashlib import md5 as md5Encode
from string import digits, ascii_lowercase, ascii_uppercase from string import digits, ascii_lowercase, ascii_uppercase
from sys import exit, stdout from sys import exit, stdout
@@ -201,6 +201,7 @@ class Iqiyi:
self.uid = data['data']['userinfo']['pru'] self.uid = data['data']['userinfo']['pru']
else: else:
self.print_now("请求api失败 最大可能是cookie失效了 也可能是网络问题") self.print_now("请求api失败 最大可能是cookie失效了 也可能是网络问题")
self.tgpush("爱奇艺每日任务: 请求api失败 最大可能是cookie失效了 也可能是网络问题")
exit(0) exit(0)
def get_watch_time(self): def get_watch_time(self):

View File

@@ -1,90 +0,0 @@
# 本脚本是一个半成品 不可以直接使用 请先确认自己能抓到自己签到链接再折腾,避免浪费自己时间 签到链接格式如下 抓这个格式的就行 注意的是在正式发post包之前会有一个options预检包 这里面的链接应该也是能用的 ck过期则签到链接过期 理论上是三个月吧
# url = 'https://community.iqiyi.com/openApi/task/execute?agentType=1&agentversion=1&appKey=basic_pcw&authCookie=xxx&qyid=xxx&sign=xxx&task_code=natural_month_sign&timestamp=xxx&typeCode=point&userId=xxx'
# 本来前天就弄好了 不过一直在思考可行方案 不知道发什么形式的好 增加获取签到链接的api的最有效的 但也是争议性最大的 我服务器也承担被攻击风险 想来想去还是决定按现在这个方案走 自己抓
# 使用方式 直接下raw文件或者在自己机器上新建一个同名文件复制粘贴内容进去都可以 测试python3版本在3.6.x-3.8.x都可用 其它自测
# 本来不太想发的 sign逆向虽然弄出来了 但不确定开源出来会不会吃票 固定签到链接虽然能签到 但是后续会怎么样不能保证,请自行斟酌是否使用
# ck填写规则 只填写P00001的value值 如(P00001=xxx;的话 只填写xxx 不要P00001=) 会操作的话 库里有爱奇艺扫码获取P00001的脚本或者直接抓包软件抓
# 只写了tg推送 推送信息写在 24 25行处 若是能访问tg的机器会走tg原生接口 否则走饭袋api推送(参考温佬wenmoux的) 因为自己平常都是用tg推送 本来想加一个以前写过的pushplus 不过找不到代码放在哪里了 所以还是算了
# 本项目使用了第三方库requests 如果没安装报错请按报错信息执行其它库均为py原生库
# 本人不使用青龙 但是青龙原理也是一样 单独下raw脚本 然后改脚本内容 不支持环境变量
# 后续大概可能应该也许不会更新什么了,医学生大五忙毕业了 最多加个上传ck自动获取签到链接的api 不过毕竟上传ck这种东西很敏感 而且我api服务器也可能会面临风险 所以可能也不弄 大家能抓到就用不会抓就等其它大佬更新一个更可行的方案
# 1.21更新 增加了一个上传ck获取自己号签到链接的api 默认为关闭状态 开启请在 29 行填open 上传ck有风险 有能力请自行抓包
# 本脚本仅供交流,请仔细斟酌得失再行使用,用户行为均与作者无关
try:
from requests import post, get
except:
print("你还没有安装requests库请执行pip3 install requests安装后再执行本脚本")
from json import dumps
from hashlib import md5
from random import choice
from string import digits, ascii_lowercase
from base64 import b64decode
ck = ''
bot_token = ''
user_id = ''
url = ''
# 以下变量若设置为 open 则本脚本会将ck上传给api获取你自己的签到url 将打印出来的url填入 25 行的url里即可不用抓签到链接的包
mode = '' #默认为空,为正常执行签到 填入 open 执行脚本可获取签到链接 获取保存好之后请删除 open 否则不会进行签到任务
def main():
data = {
"natural_month_sign" : {
"taskCode" : "iQIYI_mofhr",
"agentType" : 1,
"agentversion" : 1,
"authCookie" : ck,
"qyid" : md5Encode(uuid(16)),
"verticalCode" : "iQIYI"
}
}
headers = {
'User-Agent': 'Mozilla/5.0 (iPad; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 IqiyiApp/iqiyi IqiyiVersion/12.11.5 IqiyiPlatform/2_22_221 WebVersion/QYWebContainer QYStyleModel/(dark)',
'Content-Type':'application/json'
}
data = post(url, headers=headers, data=dumps(data)).json()
print(data)
if data['code'] == 'A00000':
try:
tgpush('今日签到成功或者已经签到了')
except:
print('你还没有填写tg推送信息或者网络问题')
return '签到成功'
else:
return '签到失败,原因可能是签到接口又又又又改了'
def md5Encode(str):
m = md5(str.encode(encoding='utf-8'))
return m.hexdigest()
def uuid(num):
str = ''
for i in range(num):
str += choice(digits + ascii_lowercase)
return str
def tgpush(content):
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {'chat_id': str(user_id), 'text': content, 'disable_web_page_preview': 'true'}
try:
req = post(url, headers=headers, data=data, timeout=10)
except:
print('推送失败,请检查网络问题')
def tgpush2(content):
url = f"https://telegram_proxy.lulafun.workers.dev/bot{bot_token}/sendMessage?parse_mode=Markdown&text={content}&chat_id={user_id}"
try:
req = get(url, timeout=30)
except:
print('推送失败')
def getUrl():
headers = {'Content-Type':'application/json'}
data = {"ck":ck}
return post(str(b64decode('aHR0cHM6Ly9zZXJ2aWNlLTA4aWlldTF3LTEzMDgxNDY3MTguZ3ouYXBpZ3cudGVuY2VudGNzLmNvbS9yZWxlYXNlL2dldHVybA==').decode()), headers=headers, data=dumps(data), timeout=20).json()['s']
if __name__ == '__main__':
if mode == 'open':
print(getUrl())
else:
main()

0
logs/.gitkeep Normal file
View File

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
requests
pycryptodome

File diff suppressed because one or more lines are too long

49
tools/aes_encrypt.py Normal file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/python3
# -- coding: utf-8 --
# -------------------------------
# @Author : github@limoruirui https://github.com/limoruirui
# @Time : 2022/8/22 18:13
# -------------------------------
"""
aes加密解密工具 目前仅支持ECB/CBC 块长度均为128位 padding只支持pkcs7/zero_padding(aes中没有pkcs5 能用的pkcs5其实是执行的pkcs7) 后续有需要再加
pycryptdemo限制 同一个aes加密对象不能即加密又解密 所以当加密和解密都需要执行时 需要重新new一个对象增加额外开销
-- A cipher object is stateful: once you have encrypted a message , you cannot encrypt (or decrypt) another message using the same object. 
"""
from Crypto.Cipher import AES
from binascii import b2a_hex, a2b_hex
from base64 import b64encode, b64decode
class AES_Ctypt:
def __init__(self, key, iv=None, mode="ECB"):
if len(key) % 16 != 0:
key = key + (AES.block_size - len(key) % AES.block_size) * chr(0)
self.key = key.encode("utf-8")
if mode == "ECB":
self.mode = AES.MODE_ECB
elif mode == "CBC":
self.mode = AES.MODE_CBC
else:
print("您选择的加密方式错误")
if iv is None:
self.cipher = AES.new(self.key, self.mode)
else:
if isinstance(iv, str):
self.cipher = AES.new(self.key, self.mode, iv.encode("utf-8"))
else:
print("偏移量不为字符串")
def encrypt(self, data, padding="pkcs7", b64=False):
bs = AES.block_size
pkcs7_padding = lambda s: s + (bs - len(s.encode()) % bs) * chr(bs - len(s.encode()) % bs)
zero_padding = lambda s: s + (bs - len(s) % bs) * chr(0)
pad = pkcs7_padding if padding=="pkcs7" else zero_padding
data = self.cipher.encrypt(pad(data).encode("utf8"))
encrypt_data = b64encode(data) if b64 else b2a_hex(data) # 输出hex或者base64
return encrypt_data.decode('utf8')
def decrypt(self, data, b64=False):
data = b64decode(data) if b64 else a2b_hex(data)
decrypt_data = self.cipher.decrypt(data).decode()
# 去掉padding
# pkcs7_unpadding = lambda s: s.replace(s[-1], "")
# zero_unpadding = lambda s: s.replace(chr(0), "")
# unpadding = pkcs7_unpadding if padding=="pkcs7" else zero_unpadding
unpadding = lambda s: s.replace(s[-1], "")
return unpadding(decrypt_data)

View File

@@ -7,6 +7,7 @@ from random import random
from hashlib import md5 from hashlib import md5
from time import sleep from time import sleep
from os import remove from os import remove
qrShowType = '本地展示' # 可选择 本地展示 tg推送 #默认本地展示 适合本地有图形界面的机器使用 tg推送则不需要图形界面,但需要考虑网络问题 qrShowType = '本地展示' # 可选择 本地展示 tg推送 #默认本地展示 适合本地有图形界面的机器使用 tg推送则不需要图形界面,但需要考虑网络问题
if qrShowType == '本地展示': if qrShowType == '本地展示':
try: try:
@@ -16,6 +17,8 @@ if qrShowType == '本地展示':
else: else:
botToken = '' botToken = ''
user_id = '' user_id = ''
def tgpush(content): def tgpush(content):
url = f"https://api.telegram.org/bot{botToken}/sendPhoto" url = f"https://api.telegram.org/bot{botToken}/sendPhoto"
headers = {'Content-Type': 'application/x-www-form-urlencoded'} headers = {'Content-Type': 'application/x-www-form-urlencoded'}
@@ -24,6 +27,8 @@ def tgpush(content):
req = post(url, headers=headers, data=data, timeout=20) req = post(url, headers=headers, data=data, timeout=20)
except: except:
print('推送失败') print('推送失败')
def getToken(): def getToken():
url = 'https://passport.iqiyi.com/apis/qrcode/gen_login_token.action' url = 'https://passport.iqiyi.com/apis/qrcode/gen_login_token.action'
headers = { headers = {
@@ -40,6 +45,8 @@ def getToken():
'surl': 1 'surl': 1
} }
return post(url, headers=headers, data=data).json()['data']['token'] return post(url, headers=headers, data=data).json()['data']['token']
def qrcode(token): def qrcode(token):
url = f'https://qrcode.iqiyipic.com/login/?data=https%3A%2F%2Fpassport.iqiyi.com%2Fapis%2Fqrcode%2Ftoken_login.action%3Ftoken%3D{token}&property=0&salt={md5Encode(f"35f4223bb8f6c8638dc91d94e9b16f5https%3A%2F%2Fpassport.iqiyi.com%2Fapis%2Fqrcode%2Ftoken_login.action%3Ftoken%3D{token}")}&width=162&_={random()}' url = f'https://qrcode.iqiyipic.com/login/?data=https%3A%2F%2Fpassport.iqiyi.com%2Fapis%2Fqrcode%2Ftoken_login.action%3Ftoken%3D{token}&property=0&salt={md5Encode(f"35f4223bb8f6c8638dc91d94e9b16f5https%3A%2F%2Fpassport.iqiyi.com%2Fapis%2Fqrcode%2Ftoken_login.action%3Ftoken%3D{token}")}&width=162&_={random()}'
if qrShowType == 'tg推送': if qrShowType == 'tg推送':
@@ -52,6 +59,8 @@ def qrcode(token):
with open('登录二维码.png', 'wb') as f: with open('登录二维码.png', 'wb') as f:
f.write(req.content) f.write(req.content)
image.open('登录二维码.png').show() image.open('登录二维码.png').show()
def login(token): def login(token):
url = 'https://passport.iqiyi.com/apis/qrcode/is_token_login.action' url = 'https://passport.iqiyi.com/apis/qrcode/is_token_login.action'
headers = { headers = {
@@ -84,12 +93,18 @@ def login(token):
except: except:
print('当前为tg推送,未生成本地图片,无需删除') print('当前为tg推送,未生成本地图片,无需删除')
return '本次扫码未成功,可能是二维码失效或者未知原因' return '本次扫码未成功,可能是二维码失效或者未知原因'
def start(): def start():
token = getToken() token = getToken()
qrcode(token) qrcode(token)
print(login(token)) print(login(token))
def md5Encode(str): def md5Encode(str):
m = md5(str.encode(encoding='utf-8')) m = md5(str.encode(encoding='utf-8'))
return m.hexdigest() return m.hexdigest()
if __name__ == '__main__': if __name__ == '__main__':
start() start()

23
tools/rsa_encrypt.py Normal file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/python3
# -- coding: utf-8 --
# -------------------------------
# @Author : github@limoruirui https://github.com/limoruirui
# @Time : 2022/8/23 13:05
# -------------------------------
from Crypto.PublicKey.RSA import importKey
from Crypto.Cipher import PKCS1_v1_5
from base64 import b64encode
class RSA_Encrypt:
def __init__(self, key):
if isinstance(key, str):
# 若提供的rsa公钥不为pem格式 则先将hex转化为pem格式
self.key = bytes.fromhex(key) if "PUBLIC KEY" not in key else key.encode()
else:
print("提供的公钥格式不正确")
def Encrypt(self, data, b64=False):
pub_key = importKey(self.key)
cipher = PKCS1_v1_5.new(pub_key)
rsa_text = cipher.encrypt(data.encode("utf8"))
rsa_text = b64encode(rsa_text).decode() if b64 else rsa_text.hex()
return rsa_text

44
tools/send_msg.py Normal file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/python3
# -- coding: utf-8 --
# -------------------------------
# @Author : github@limoruirui https://github.com/limoruirui
# @Time : 2022/8/23 23:31
# -------------------------------
from requests import post
from json import dumps
from tool import get_environ
tg_userId = get_environ("TG_USER_ID")
tgbot_token = get_environ("TG_BOT_TOKEN")
tg_push_api = get_environ("TG_API_HOST")
pushplus_token = get_environ("PUSH_PLUS_TOKEN")
def tgpush(title, content):
url = f"https://api.telegram.org/bot{tgbot_token}/sendMessage"
if tg_push_api != "":
url = f"https://{tg_push_api}/bot{tgbot_token}/sendMessage"
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {'chat_id': str(tg_userId), 'text': f"{title}\n{content}", 'disable_web_page_preview': 'true'}
try:
post(url, headers=headers, data=data, timeout=10)
except:
print('推送失败')
def pushplus(title, content):
url = "http://www.pushplus.plus/send"
headers = {
"Content-Type": "application/json"
}
data = {
"token": pushplus_token,
"title": title,
"content": content
}
try:
post(url, headers=headers, data=dumps(data))
except:
print('推送失败')
def push(self, title, content):
if pushplus_token != "":
self.pushplus(title, content)
if tgbot_token != "" and tg_userId != "":
self.tgpush(title, content)

77
tools/tool.py Normal file
View File

@@ -0,0 +1,77 @@
#!/usr/bin/python3
# -- coding: utf-8 --
# -------------------------------
# @Author : github@limoruirui https://github.com/limoruirui
# @Time : 2022/8/22 17:56
# -------------------------------
"""
封装一些工具
"""
from hashlib import md5 as md5Encode, sha1
from hmac import new
from random import choice, randint
from string import digits, ascii_lowercase, ascii_uppercase
from time import sleep, time
from datetime import datetime, timedelta
from sys import stdout
from os import environ
from json import load
# 生成随机字符串
def uuid(num, upper=False):
str = ''
if upper:
for i in range(num):
str += choice(digits + ascii_lowercase + ascii_uppercase)
else:
for i in range(num):
str += choice(digits + ascii_lowercase)
return str
# 修改print方法 避免某些环境下python执行print 不会去刷新缓存区导致信息第一时间不及时输出
def print_now(content):
print(content)
stdout.flush()
def get_ua():
with open("../user_agent.json", "rb") as f:
ua_list = load(f)["Chrome"]
ua = choice(ua_list)
return ua
# 随机休眠时长 若为0时区 TimeZone为真
def random_sleep(min_time=300, max_time=5400, TimeZone=True):
random_time = randint(min_time, max_time)
print_now(f"随机等待{random_time}")
sleep(random_time)
now_time = (datetime.now() + timedelta(hours=8)).__format__("%Y-%m-%d %H:%M:%S")
if TimeZone:
now_time = (datetime.now()).__format__("%Y-%m-%d %H:%M:%S")
print_now(f"等待结束.开始执行 现在时间是------{now_time} ------------")
def timestamp(short=False):
if short:
return int(round(time()))
return int(round(time() * 1000))
# md5
def md5(str):
m = md5Encode(str.encode('utf8'))
return m.hexdigest()
# hmac sha1
def hmac_sha1(data, key):
hmac_code = new(key.encode(), data.encode(), sha1)
return hmac_code.hexdigest()
# 封装读取环境变量的方法
def get_environ(key, default=""):
return environ.get(key) if environ.get(key) else default

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff