From 86c5e030fc3755be4c8cac05b8d78b9843440bac Mon Sep 17 00:00:00 2001 From: smallfawn <860562056@qq.com> Date: Sun, 16 Feb 2025 19:12:09 +0800 Subject: [PATCH] 1 --- anmuxi.py | 295 ------------------------------------------- backup/bjev.js | 2 +- backup/hezj.js | 2 +- wxapp/anmuxi.js | 326 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 328 insertions(+), 297 deletions(-) delete mode 100644 anmuxi.py create mode 100644 wxapp/anmuxi.js diff --git a/anmuxi.py b/anmuxi.py deleted file mode 100644 index e4eece4..0000000 --- a/anmuxi.py +++ /dev/null @@ -1,295 +0,0 @@ - -# !/usr/bin/python3 -# -- coding: utf-8 -- -# cron "30 9 * * *" script-path=xxx.py,tag=匹配cron用 -# const $ = new Env('安慕希小程序') -import json -import os -import random -import time -from datetime import datetime, time as times -import requests -from requests.packages.urllib3.exceptions import InsecureRequestWarning -# 禁用安全请求警告 -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.access_token = split_info[0] - 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 - # print(self.access_token) - self.UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309080f) XWEB/8555' - # if ENV_NAME == 'YL_ZXBQL': - # appid = "wx06af0ef532292cd3" - # scene = "1037" - # scene = "1037" - self.headers = { - 'Host': 'amxshop.yili.com', - 'accesstoken': self.access_token, - 'scene': '1302', - 'xweb_xhr': '1', - 'user-agent': self.UA, - 'content-type': 'application/x-www-form-urlencoded', - 'accept': '*/*', - 'sec-fetch-site': 'cross-site', - 'sec-fetch-mode': 'cors', - 'sec-fetch-dest': 'empty', - 'referer': 'https://servicewechat.com/wxf2a6206f7e2fd712/664/page-frame.html', - 'accept-language': 'zh-CN,zh;q=0.9', - } - self.s = requests.session() - self.s.verify = False - self.baseUrl = 'https://amxshop.yili.com/api/' - - - def make_request(self, url, method='post', headers={}, data={}, params=None): - if headers == {}: - headers = self.headers - try: - if method.lower() == 'get': - response = self.s.get(url, headers=headers, verify=False, params=params) - elif method.lower() == 'post': - response = self.s.post(url, headers=headers, json=data, params=params, verify=False) - else: - raise ValueError("不支持的请求方法❌: " + method) - return response.json() - except requests.exceptions.RequestException as e: - print("请求异常❌:", e) - except ValueError as e: - print("值错误或不支持的请求方法❌:", e) - except Exception as e: - print("发生了未知错误❌:", e) - - def get_user_info(self): - act_name = '获取用户信息' - Log(f'\n====== {act_name} ======') - url = f"{self.baseUrl}user/getUser" - response = self.make_request(url,method='get') - if response.get('code', -1) == 200: - print(f'{act_name}成功!✅') - data = response.get('data',{}) - user = data.get('user',{}) - user_id = user.get('id') - user_name = user.get('name') - mobilePhone = user.get('mobilePhone') - myCode = user.get('myCode') - - mobile = mobilePhone[:3] + "*" * 4 + mobilePhone[7:] - Log(f">用户名:{user_name}\n>手机号:{mobile}") - - return True - elif not response: - print(f">账号 {self.index}: ck过期 请重新抓取 access-token") - return False - else: - print(response) - return False - - def get_Point(self,END=False): - act_name = '获取积分信息' - if not END:Log(f'\n====== {act_name} ======') - url = f"{self.baseUrl}user/score" - response = self.make_request(url,method='get') - if response.get('code', -1) == 200: - data = response.get('data', '') - print(f'{act_name}成功!✅') - if END: - Log(f'执行后积分:【{data}】') - else: - Log(f'当前积分:【{data}】') - return True - else: - print(response) - return False - - def daily_sign(self): - act_name = '签到' - Log(f'\n====== {act_name} ======') - url = f"{self.baseUrl}user/daily/sign?exParams=false" - response = self.make_request(url,method='get') - if response.get('code', -1) == 200: - data = response.get('data',{}) - point = data.get('dailySign', {}).get('bonusPoint', '') - print(f'{act_name}成功!✅') - Log(f'获得积分:【{point}】') - return True - else: - print(response) - return False - - def get_sign_status(self): - act_name = '获取签到信息' - Log(f'\n====== {act_name} ======') - url = f"{self.baseUrl}user/sign/status" - response = self.make_request(url,method='get') - if response.get('code', -1) == 200: - data = response.get('data',{}) - signed = data.get('signed','') - signDays = data.get('signDays','') - print(f'{act_name}成功!✅') - Log(f'今日:【{"已签到" if signed else "未签到"}】') - print(f'累计签到:【{signDays}】天') - if not signed: - self.daily_sign() - return True - else: - print(response) - return False - - - def main(self): - Log(f"\n开始执行第{self.index}个账号--------------->>>>>") - if self.get_user_info(): - # random_delay() - self.get_Point() - random_delay() - self.get_sign_status() - random_delay() - self.get_Point(True) - # self.daily_sign() - - self.sendMsg() - return True - else: - self.sendMsg() - return False - - def sendMsg(self): - if self.send_UID: - push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME) - print(push_res) - - -def random_delay(min_delay=1, max_delay=5): - """ - 在min_delay和max_delay之间产生一个随机的延时时间,然后暂停执行。 - 参数: - min_delay (int/float): 最小延时时间(秒) - max_delay (int/float): 最大延时时间(秒) - """ - delay = random.uniform(min_delay, max_delay) - print(f">本次随机延迟:【{delay:.2f}】 秒.....") - time.sleep(delay) - - -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, amxCode - import CHERWIN_TOOLS - ENV, APP_INFO, TIPS, TIPS_HTML, amxCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version) - - -if __name__ == '__main__': - APP_NAME = '安慕希小程序' - ENV_NAME = 'AMX' - CK_URL = 'amxshop.yili.com请求头' - CK_NAME = 'accesstoken' - CK_EX = 'wTUhu5IlL9uQDRelKgMRbao2bxii+O8+4FffOnxxxxxxx' - print(f''' -✨✨✨ {APP_NAME}脚本✨✨✨ -✨ 功能: - 积分签到 -✨ 抓包步骤: - 打开{APP_NAME} - 授权登陆 - 打开抓包工具 - 找{CK_URL}{CK_NAME} -参数示例:{CK_EX} -✨ ✨✨wxpusher一对一推送功能, - ✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送 - ✨需要在{ENV_NAME}变量最后添加@wxpusher的UID -✨ 设置青龙变量: -export {ENV_NAME}='{CK_NAME}参数值'多账号#或&分割 -export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启 -✨ ✨ 注意:抓完CK没事儿别打开小程序,重新打开小程序请重新抓包 -✨ 推荐cron:5 7,11,15,20 * * * -''') - local_script_name = os.path.basename(__file__) - local_version = '2024.05.23' - if IS_DEV: - import_Tools() - else: - if os.path.isfile('amx.py'): - import_Tools() - else: - if down_file('amx.py', 'amx.py'): - print('脚本检测完成') - import_Tools() - else: - print( - '脚本检测失败') - 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): - run_result = RUN(infos, index).main() - if not run_result: continue - if send: send(f'{APP_NAME}挂机通知', send_msg + TIPS_HTML) diff --git a/backup/bjev.js b/backup/bjev.js index 1966b2f..cab7e48 100644 --- a/backup/bjev.js +++ b/backup/bjev.js @@ -9,7 +9,7 @@ */ const $ = new Env("北京汽车"); -const notify = $.isNode() ? require('./sendNotify') : ''; +const notify = $.isNode() ? require('../sendNotify') : ''; let ckName = "bjevAuth"; let envSplitor = ["@", "\n"]; //多账号分隔符 let strSplitor = "&"; //多变量分隔符 diff --git a/backup/hezj.js b/backup/hezj.js index e98b9f9..21e0bcc 100644 --- a/backup/hezj.js +++ b/backup/hezj.js @@ -280,7 +280,7 @@ async function SendMsg(message) { if (!message) return; if (Notify > 0) { if ($.isNode()) { - var notify = require("./sendNotify"); + var notify = require("../sendNotify"); await notify.sendNotify($.name, message) } else { $.msg($.name, '', message) diff --git a/wxapp/anmuxi.js b/wxapp/anmuxi.js new file mode 100644 index 0000000..a3f30e5 --- /dev/null +++ b/wxapp/anmuxi.js @@ -0,0 +1,326 @@ +/* +------------------------------------------ +@Author: sm +@Date: 2024.06.07 19:15 +@Description: 测试 +------------------------------------------ +#Notice: + 安慕希小程序 变量名anmuxi + 抓wx-amxshop.msxapi.digitalyili.com/api headers中accessToken值 多账户&分隔 +⚠️【免责声明】 +------------------------------------------ +1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。 +2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。 +3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。 +4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。 +5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。 +6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。 +7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。 +*/ + +const $ = new Env("安慕希小程序"); +let ckName = `anmuxi`; +const strSplitor = "#"; +const envSplitor = ["&", "\n"]; +const notify = $.isNode() ? require("./sendNotify") : ""; +const axios = require("axios"); +const defaultUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.31(0x18001e31) NetType/WIFI Language/zh_CN miniProgram" + +class Public { + async request(options) { + return await axios.request(options); + } +} +class Task extends Public { + constructor(env) { + + super(); + this.index = $.userIdx++ + let user = env.split("#"); + this.token = user[0]; + this.signed = true + + } + + async daily_sign() { + let options = { + method: "GET", + + url: `https://wx-amxshop.msxapi.digitalyili.com/api/user/daily/sign?exParams=false`, + headers: { + "accept": "*/*", + "accept-language": "zh-CN,zh;q=0.9", + "accesstoken": "" + this.token, + "content-type": "application/x-www-form-urlencoded", + "scene": "1256", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "cross-site", + "xweb_xhr": "1" + } + } + try { + let { data: res } = await this.request(options); + if (res.code == 200) { + $.log(`签到成功 获得【${res.data.dailySign.bonusPoints}】分`) + } else { + $.log(`签到失败`) + console.log(res); + + } + } catch (e) { + console.log(`签到失败`) + } + } + async daily_sign_status() { + let options = { + method: "GET", + + url: `https://wx-amxshop.msxapi.digitalyili.com/api/user/sign/status`, + headers: { + "accept": "*/*", + "accept-language": "zh-CN,zh;q=0.9", + "accesstoken": "" + this.token, + "content-type": "application/x-www-form-urlencoded", + "scene": "1256", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "cross-site", + "xweb_xhr": "1" + } + } + try { + let { data: res } = await this.request(options); + if (res.code == 200) { + if (res.data.signed == false) { + this.signed = false + $.log(`已签到 【${res.data.signDays}】天 检测到今日未签到`) + } else { + $.log(`已签到 【${res.data.signDays}】天 检测到今日已签到`) + this.signed = true + } + + } else { + $.log(`获取签到状态失败`) + console.log(res); + + } + } catch (e) { + console.log(`签到失败`) + } + } + async user_score() { + let options = { + method: "GET", + + url: `https://wx-amxshop.msxapi.digitalyili.com/api/user/score`, + headers: { + "accept": "*/*", + "accept-language": "zh-CN,zh;q=0.9", + "accesstoken": "" + this.token, + "content-type": "application/x-www-form-urlencoded", + "scene": "1256", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "cross-site", + "xweb_xhr": "1" + } + } + try { + let { data: res } = await this.request(options); + if (res.code == 200) { + $.log(`当前积分【${res.data}】天`) + } else { + $.log(`获取积分失败`) + console.log(res); + + } + } catch (e) { + console.log(`签到失败`) + } + } + + async run() { + await this.user_score(); + + await this.daily_sign_status(); + if (this.signed == false) { + await this.daily_sign(); + } + + + + } +} + + +!(async () => { + await getNotice() + $.checkEnv(ckName); + + for (let user of $.userList) { + // + + await new Task(user).run(); + + } + + +})() + .catch((e) => console.log(e)) + .finally(() => $.done()); + +async function getNotice() { + let options = { + url: `https://gitee.com/smallfawn/Note/raw/main/Notice.json`, + headers: { + "User-Agent": defaultUserAgent, + } + } + let { data: res } = await new Public().request(options); + return res +} + + +// prettier-ignore +function Env(t, s) { + return new (class { + constructor(t, s) { + this.userIdx = 1; + this.userList = []; + this.userCount = 0; + this.name = t; + this.notifyStr = []; + this.logSeparator = "\n"; + this.startTime = new Date().getTime(); + Object.assign(this, s); + this.log(`\ud83d\udd14${this.name},\u5f00\u59cb!`); + } + checkEnv(ckName) { + let userCookie = (this.isNode() ? process.env[ckName] : "") || ""; + this.userList = userCookie.split(envSplitor.find((o) => userCookie.includes(o)) || "&").filter((n) => n); + this.userCount = this.userList.length; + this.log(`共找到${this.userCount}个账号`); + } + async sendMsg() { + this.log("==============📣Center 通知📣==============") + let message = this.notifyStr.join(this.logSeparator); + if (this.isNode()) { + + await notify.sendNotify(this.name, message); + } else { + + } + } + isNode() { + return "undefined" != typeof module && !!module.exports; + } + + queryStr(options) { + return Object.entries(options) + .map( + ([key, value]) => + `${key}=${typeof value === "object" ? JSON.stringify(value) : value + }` + ) + .join("&"); + } + getURLParams(url) { + const params = {}; + const queryString = url.split("?")[1]; + if (queryString) { + const paramPairs = queryString.split("&"); + paramPairs.forEach((pair) => { + const [key, value] = pair.split("="); + params[key] = value; + }); + } + return params; + } + isJSONString(str) { + try { + return JSON.parse(str) && typeof JSON.parse(str) === "object"; + } catch (e) { + return false; + } + } + isJson(obj) { + var isjson = + typeof obj == "object" && + Object.prototype.toString.call(obj).toLowerCase() == + "[object object]" && + !obj.length; + return isjson; + } + + randomNumber(length) { + const characters = "0123456789"; + return Array.from( + { length }, + () => characters[Math.floor(Math.random() * characters.length)] + ).join(""); + } + randomString(length) { + const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; + return Array.from( + { length }, + () => characters[Math.floor(Math.random() * characters.length)] + ).join(""); + } + uuid() { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( + /[xy]/g, + function (c) { + var r = (Math.random() * 16) | 0, + v = c == "x" ? r : (r & 0x3) | 0x8; + return v.toString(16); + } + ); + } + time(t) { + let s = { + "M+": new Date().getMonth() + 1, + "d+": new Date().getDate(), + "H+": new Date().getHours(), + "m+": new Date().getMinutes(), + "s+": new Date().getSeconds(), + "q+": Math.floor((new Date().getMonth() + 3) / 3), + S: new Date().getMilliseconds(), + }; + /(y+)/.test(t) && + (t = t.replace( + RegExp.$1, + (new Date().getFullYear() + "").substr(4 - RegExp.$1.length) + )); + for (let e in s) { + new RegExp("(" + e + ")").test(t) && + (t = t.replace( + RegExp.$1, + 1 == RegExp.$1.length + ? s[e] + : ("00" + s[e]).substr(("" + s[e]).length) + )); + } + return t; + } + + log(content) { + this.notifyStr.push(content) + console.log(content) + } + wait(t) { + return new Promise((s) => setTimeout(s, t)); + } + done(t = {}) { + this.sendMsg(); + const s = new Date().getTime(), + e = (s - this.startTime) / 1e3; + this.log( + `\ud83d\udd14${this.name},\u7ed3\u675f!\ud83d\udd5b ${e}\u79d2` + ); + if (this.isNode()) { + process.exit(1); + } + } + })(t, s); +} \ No newline at end of file