mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
clear
This commit is contained in:
parent
c381895b47
commit
391e006c07
@ -1,391 +0,0 @@
|
||||
import axios from "axios"
|
||||
import {Md5} from "ts-md5"
|
||||
import * as dotenv from "dotenv"
|
||||
import {existsSync, readFileSync} from "fs"
|
||||
import {sendNotify} from './sendNotify'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
let fingerprint: string | number, token: string = '', enCryptMethodJD: any
|
||||
|
||||
const USER_AGENTS: Array<string> = [
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79",
|
||||
"jdapp;android;10.0.2;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
]
|
||||
|
||||
function TotalBean(cookie: string) {
|
||||
return {
|
||||
cookie: cookie,
|
||||
isLogin: true,
|
||||
nickName: ''
|
||||
}
|
||||
}
|
||||
|
||||
function getRandomNumberByRange(start: number, end: number) {
|
||||
return Math.floor(Math.random() * (end - start) + start)
|
||||
}
|
||||
|
||||
let USER_AGENT = USER_AGENTS[getRandomNumberByRange(0, USER_AGENTS.length)]
|
||||
|
||||
async function getBeanShareCode(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action',
|
||||
`functionId=plantBeanIndex&body=${encodeURIComponent(
|
||||
JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""})
|
||||
)}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
Host: "api.m.jd.com",
|
||||
Accept: "*/*",
|
||||
Connection: "keep-alive",
|
||||
"User-Agent": USER_AGENT
|
||||
}
|
||||
})
|
||||
if (data.data?.jwordShareInfo?.shareUrl)
|
||||
return data.data.jwordShareInfo.shareUrl.split('Uuid=')![1]
|
||||
else
|
||||
return ''
|
||||
}
|
||||
|
||||
async function getFarmShareCode(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${encodeURIComponent(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
"cookie": cookie,
|
||||
"origin": "https://home.m.jd.com",
|
||||
"referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
"User-Agent": USER_AGENT,
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
})
|
||||
|
||||
if (data.farmUserPro)
|
||||
return data.farmUserPro.shareCode
|
||||
else
|
||||
return ''
|
||||
}
|
||||
|
||||
async function requireConfig(check: boolean = false): Promise<string[]> {
|
||||
let cookiesArr: string[] = []
|
||||
const jdCookieNode = require('./jdCookie.js')
|
||||
let keys: string[] = Object.keys(jdCookieNode)
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let cookie = jdCookieNode[keys[i]]
|
||||
if (!check) {
|
||||
cookiesArr.push(cookie)
|
||||
} else {
|
||||
if (await checkCookie(cookie)) {
|
||||
cookiesArr.push(cookie)
|
||||
} else {
|
||||
let username = decodeURIComponent(jdCookieNode[keys[i]].match(/pt_pin=([^;]*)/)![1])
|
||||
console.log('Cookie失效', username)
|
||||
await sendNotify('Cookie失效', '【京东账号】' + username)
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`)
|
||||
return cookiesArr
|
||||
}
|
||||
|
||||
async function checkCookie(cookie) {
|
||||
await wait(1000)
|
||||
try {
|
||||
let {data}: any = await axios.get(`https://api.m.jd.com/client.action?functionId=GetJDUserInfoUnion&appid=jd-cphdeveloper-m&body=${encodeURIComponent(JSON.stringify({"orgFlag": "JD_PinGou_New", "callSource": "mainorder", "channel": 4, "isHomewhite": 0, "sceneval": 2}))}&loginType=2&_=${Date.now()}&sceneval=2&g_login_type=1&callback=GetJDUserInfoUnion&g_ty=ls`, {
|
||||
headers: {
|
||||
'authority': 'api.m.jd.com',
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
|
||||
'referer': 'https://home.m.jd.com/',
|
||||
'cookie': cookie
|
||||
}
|
||||
})
|
||||
data = JSON.parse(data.match(/GetJDUserInfoUnion\((.*)\)/)[1])
|
||||
return data.retcode === '0';
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function wait(timeout: number) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
async function requestAlgo(appId: number = 10032) {
|
||||
fingerprint = generateFp()
|
||||
return new Promise<void>(async resolve => {
|
||||
let {data}: any = await axios.post('https://cactus.jd.com/request_algo?g_ty=ajax', {
|
||||
"version": "1.0",
|
||||
"fp": fingerprint,
|
||||
"appId": appId,
|
||||
"timestamp": Date.now(),
|
||||
"platform": "web",
|
||||
"expandParams": ""
|
||||
}, {
|
||||
"headers": {
|
||||
'Authority': 'cactus.jd.com',
|
||||
'Pragma': 'no-cache',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Content-Type': 'application/json',
|
||||
'Origin': 'https://st.jingxi.com',
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Referer': 'https://st.jingxi.com/',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
|
||||
},
|
||||
})
|
||||
if (data['status'] === 200) {
|
||||
token = data.data.result.tk
|
||||
let enCryptMethodJDString = data.data.result.algo
|
||||
if (enCryptMethodJDString) enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)()
|
||||
} else {
|
||||
console.log(`fp: ${fingerprint}`)
|
||||
console.log('request_algo 签名参数API请求失败:')
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function generateFp() {
|
||||
let e = "0123456789"
|
||||
let a = 13
|
||||
let i = ''
|
||||
for (; a--;)
|
||||
i += e[Math.random() * e.length | 0]
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}
|
||||
|
||||
function getJxToken(cookie: string, phoneId: string = '') {
|
||||
function generateStr(input: number) {
|
||||
let src = 'abcdefghijklmnopqrstuvwxyz1234567890'
|
||||
let res = ''
|
||||
for (let i = 0; i < input; i++) {
|
||||
res += src[Math.floor(src.length * Math.random())]
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
if (!phoneId)
|
||||
phoneId = generateStr(40)
|
||||
let timestamp = Date.now().toString()
|
||||
let nickname = cookie.match(/pt_pin=([^;]*)/)![1]
|
||||
let jstoken = Md5.hashStr('' + decodeURIComponent(nickname) + timestamp + phoneId + 'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy')
|
||||
return {
|
||||
'strPgtimestamp': timestamp,
|
||||
'strPhoneID': phoneId,
|
||||
'strPgUUNum': jstoken
|
||||
}
|
||||
}
|
||||
|
||||
function exceptCookie(filename: string = 'x.ts') {
|
||||
let except: any = []
|
||||
if (existsSync('./utils/exceptCookie.json')) {
|
||||
try {
|
||||
except = JSON.parse(readFileSync('./utils/exceptCookie.json').toString() || '{}')[filename] || []
|
||||
} catch (e) {
|
||||
console.log('./utils/exceptCookie.json JSON格式错误')
|
||||
}
|
||||
}
|
||||
return except
|
||||
}
|
||||
|
||||
function randomString(e: number, word?: number) {
|
||||
e = e || 32
|
||||
let t = word === 26 ? "012345678abcdefghijklmnopqrstuvwxyz" : "0123456789abcdef", a = t.length, n = ""
|
||||
for (let i = 0; i < e; i++)
|
||||
n += t.charAt(Math.floor(Math.random() * a))
|
||||
return n
|
||||
}
|
||||
|
||||
function o2s(arr: object, title: string = '') {
|
||||
title ? console.log(title, JSON.stringify(arr)) : console.log(JSON.stringify(arr))
|
||||
}
|
||||
|
||||
function randomNumString(e: number) {
|
||||
e = e || 32
|
||||
let t = '0123456789', a = t.length, n = ""
|
||||
for (let i = 0; i < e; i++)
|
||||
n += t.charAt(Math.floor(Math.random() * a))
|
||||
return n
|
||||
}
|
||||
|
||||
function randomWord(n: number = 1) {
|
||||
let t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', a = t.length
|
||||
let rnd: string = ''
|
||||
for (let i = 0; i < n; i++) {
|
||||
rnd += t.charAt(Math.floor(Math.random() * a))
|
||||
}
|
||||
return rnd
|
||||
}
|
||||
|
||||
async function getshareCodeHW(key: string) {
|
||||
let shareCodeHW: string[] = []
|
||||
for (let i = 0; i < 5; i++) {
|
||||
try {
|
||||
let {data}: any = await axios.get('https://api.jdsharecode.xyz/api/HW_CODES')
|
||||
shareCodeHW = data[key] || []
|
||||
if (shareCodeHW.length !== 0) {
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("getshareCodeHW Error, Retry...")
|
||||
await wait(getRandomNumberByRange(2000, 6000))
|
||||
}
|
||||
}
|
||||
return shareCodeHW
|
||||
}
|
||||
|
||||
async function getShareCodePool(key: string, num: number) {
|
||||
let shareCode: string[] = []
|
||||
for (let i = 0; i < 2; i++) {
|
||||
try {
|
||||
let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/${key}/${num}`)
|
||||
shareCode = data.data || []
|
||||
console.log(`随机获取${num}个${key}成功:${JSON.stringify(shareCode)}`)
|
||||
if (shareCode.length !== 0) {
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("getShareCodePool Error, Retry...")
|
||||
await wait(getRandomNumberByRange(2000, 6000))
|
||||
}
|
||||
}
|
||||
return shareCode
|
||||
}
|
||||
|
||||
/*async function wechat_app_msg(title: string, content: string, user: string) {
|
||||
let corpid: string = "", corpsecret: string = ""
|
||||
let {data: gettoken} = await axios.get(`https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${corpid}&corpsecret=${corpsecret}`)
|
||||
let access_token: string = gettoken.access_token
|
||||
|
||||
let {data: send} = await axios.post(`https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${access_token}`, {
|
||||
"touser": user,
|
||||
"msgtype": "text",
|
||||
"agentid": 1000002,
|
||||
"text": {
|
||||
"content": `${title}\n\n${content}`
|
||||
},
|
||||
"safe": 0
|
||||
})
|
||||
if (send.errcode === 0) {
|
||||
console.log('企业微信应用消息发送成功')
|
||||
} else {
|
||||
console.log('企业微信应用消息发送失败', send)
|
||||
}
|
||||
}*/
|
||||
|
||||
function obj2str(obj: object) {
|
||||
return JSON.stringify(obj)
|
||||
}
|
||||
|
||||
async function getDevice() {
|
||||
let {data} = await axios.get('https://betahub.cn/api/apple/devices/iPhone', {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
|
||||
}
|
||||
})
|
||||
data = data[getRandomNumberByRange(0, 16)]
|
||||
return data.identifier
|
||||
}
|
||||
|
||||
async function getVersion(device: string) {
|
||||
let {data} = await axios.get(`https://betahub.cn/api/apple/firmwares/${device}`, {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
|
||||
}
|
||||
})
|
||||
data = data[getRandomNumberByRange(0, data.length)]
|
||||
return data.firmware_info.version
|
||||
}
|
||||
|
||||
async function jdpingou() {
|
||||
let device: string, version: string;
|
||||
device = await getDevice();
|
||||
version = await getVersion(device);
|
||||
return `jdpingou;iPhone;5.19.0;${version};${randomString(40)};network/wifi;model/${device};appBuild/100833;ADID/;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/${getRandomNumberByRange(10, 90)};pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
|
||||
}
|
||||
|
||||
function get(url: string, prarms?: string, headers?: any) {
|
||||
return axios.get(url, {
|
||||
params: prarms,
|
||||
headers: headers
|
||||
})
|
||||
.then(res => {
|
||||
if (typeof res.data === 'string' && res.data.match(/^jsonpCBK/)) {
|
||||
return JSON.parse(res.data.match(/jsonpCBK.?\(([\w\W]*)\);/)[1])
|
||||
} else {
|
||||
return res.data
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err?.response?.status, err?.response?.statusText)
|
||||
});
|
||||
}
|
||||
|
||||
function post(url: string, prarms?: string | object, headers?: any): Promise<any> {
|
||||
return axios.post(url, prarms, {
|
||||
headers: headers
|
||||
})
|
||||
.then(res => res.data)
|
||||
.catch(err => {
|
||||
console.log(err?.response?.status, err?.response?.statusText)
|
||||
});
|
||||
}
|
||||
|
||||
export default USER_AGENT
|
||||
export {
|
||||
TotalBean,
|
||||
getBeanShareCode,
|
||||
getFarmShareCode,
|
||||
requireConfig,
|
||||
wait,
|
||||
getRandomNumberByRange,
|
||||
requestAlgo,
|
||||
getJxToken,
|
||||
exceptCookie,
|
||||
randomString,
|
||||
o2s,
|
||||
randomNumString,
|
||||
getshareCodeHW,
|
||||
getShareCodePool,
|
||||
randomWord,
|
||||
obj2str,
|
||||
jdpingou,
|
||||
get,
|
||||
post
|
||||
}
|
51
utils/V3.ts
51
utils/V3.ts
@ -1,51 +0,0 @@
|
||||
import axios from "axios";
|
||||
import {format} from "date-fns";
|
||||
|
||||
const CryptoJS = require('crypto-js')
|
||||
|
||||
let fp: string = '', tk: string = '', genKey: any = null
|
||||
|
||||
async function requestAlgo(appId: string, USER_AGENT: string = 'jdpingou;') {
|
||||
function generateFp() {
|
||||
let e = "0123456789";
|
||||
let a = 13;
|
||||
let i = '';
|
||||
for (; a--;)
|
||||
i += e[Math.random() * e.length | 0];
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}
|
||||
|
||||
fp = generateFp()
|
||||
let {data} = await axios.post(`https://cactus.jd.com/request_algo?g_ty=ajax`, `{"version":"3.0","fp":"${fp}","appId":"${appId}","timestamp":${Date.now()},"platform":"web","expandParams":""}`, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
||||
'host': 'cactus.jd.com',
|
||||
'Referer': 'https://cactus.jd.com',
|
||||
'User-Agent': USER_AGENT
|
||||
}
|
||||
})
|
||||
tk = data.data.result.tk;
|
||||
genKey = new Function(`return ${data.data.result.algo}`)();
|
||||
return {fp, tk, genKey}
|
||||
}
|
||||
|
||||
function geth5st(t: { key: string, value: string } [], appId: string) {
|
||||
let a = ''
|
||||
t.forEach(({key, value}) => {
|
||||
a += `${key}:${value}&`
|
||||
})
|
||||
a = a.slice(0, -1)
|
||||
let time = Date.now()
|
||||
let timestamp = format(time, "yyyyMMddHHmmssSSS");
|
||||
let hash1 = genKey(tk, fp.toString(), timestamp.toString(), appId.toString(), CryptoJS).toString(CryptoJS.enc.Hex);
|
||||
const hash2 = CryptoJS.HmacSHA256(a, hash1).toString();
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat(fp.toString()), "".concat(appId.toString()), "".concat(tk), "".concat(hash2), "3.0", "".concat(time.toString())].join(";"))
|
||||
}
|
||||
|
||||
export {
|
||||
requestAlgo,
|
||||
geth5st,
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
import axios from "axios"
|
||||
import {format} from "date-fns"
|
||||
import * as CryptoJS from 'crypto-js'
|
||||
|
||||
class H5ST {
|
||||
tk: string;
|
||||
timestamp: string;
|
||||
rd: string;
|
||||
appId: string;
|
||||
fp: string;
|
||||
time: number;
|
||||
ua: string
|
||||
enc: string;
|
||||
|
||||
constructor(appId: string, ua: string, fp: string) {
|
||||
this.appId = appId
|
||||
this.ua = ua
|
||||
this.fp = fp || this.__genFp()
|
||||
}
|
||||
|
||||
__genFp() {
|
||||
let e = "0123456789";
|
||||
let a = 13;
|
||||
let i = '';
|
||||
for (; a--;)
|
||||
i += e[Math.random() * e.length | 0];
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}
|
||||
|
||||
async __genAlgo() {
|
||||
this.time = Date.now()
|
||||
this.timestamp = format(this.time, "yyyyMMddHHmmssSSS")
|
||||
let {data} = await axios.post(`https://cactus.jd.com/request_algo?g_ty=ajax`, {
|
||||
'version': '3.0',
|
||||
'fp': this.fp,
|
||||
'appId': this.appId.toString(),
|
||||
'timestamp': this.time,
|
||||
'platform': 'web',
|
||||
'expandParams': ''
|
||||
}, {
|
||||
headers: {
|
||||
'Host': 'cactus.jd.com',
|
||||
'accept': 'application/json',
|
||||
'content-type': 'application/json',
|
||||
'user-agent': this.ua,
|
||||
}
|
||||
})
|
||||
this.tk = data.data.result.tk
|
||||
this.rd = data.data.result.algo.match(/rd='(.*)'/)[1]
|
||||
this.enc = data.data.result.algo.match(/algo\.(.*)\(/)[1]
|
||||
}
|
||||
|
||||
__genKey(tk: string, fp: string, ts: string, ai: string, algo: object) {
|
||||
let str = `${tk}${fp}${ts}${ai}${this.rd}`;
|
||||
return algo[this.enc](str, tk)
|
||||
}
|
||||
|
||||
__genH5st(body: object) {
|
||||
let y = this.__genKey(this.tk, this.fp, this.timestamp, this.appId, CryptoJS).toString(CryptoJS.enc.Hex)
|
||||
let s = ''
|
||||
for (let key of Object.keys(body)) {
|
||||
key === 'body' ? s += `${key}:${CryptoJS.SHA256(body[key]).toString(CryptoJS.enc.Hex)}&` : s += `${key}:${body[key]}&`
|
||||
}
|
||||
s = s.slice(0, -1)
|
||||
s = CryptoJS.HmacSHA256(s, y).toString(CryptoJS.enc.Hex)
|
||||
return encodeURIComponent(`${this.timestamp};${this.fp};${this.appId.toString()};${this.tk};${s};3.0;${this.time.toString()}`)
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
H5ST
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1802
utils/jinli_log.ts
1802
utils/jinli_log.ts
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
760
utils/magic.js
760
utils/magic.js
@ -1,760 +0,0 @@
|
||||
// noinspection JSUnresolvedFunction,JSUnresolvedVariable
|
||||
|
||||
const axios = require('axios');
|
||||
const fs = require("fs");
|
||||
const {format} = require("date-fns");
|
||||
const notify = require('../sendNotify');
|
||||
const jdCookieNode = require('../jdCookie.js');
|
||||
const CryptoJS = require("crypto-js");
|
||||
const got = require("got");
|
||||
let cookies = [];
|
||||
let testMode = process.env.TEST_MODE?.includes('on') ? true
|
||||
: __dirname.includes("magic")
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
cookies.push(jdCookieNode[item])
|
||||
})
|
||||
|
||||
const USER_AGENTS = [
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79",
|
||||
"jdapp;android;10.0.2;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
"jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36",
|
||||
"jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36",
|
||||
"jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
|
||||
]
|
||||
|
||||
const $ = axios.create({timeout: 24000});
|
||||
$.defaults.headers['Accept'] = '*/*';
|
||||
$.defaults.headers['User-Agent'] = USER_AGENTS[randomNumber(0,
|
||||
USER_AGENTS.length)];
|
||||
$.defaults.headers['Connection'] = 'keep-alive';
|
||||
$.defaults.headers['Accept-Language'] = "zh-CN,zh-Hans;q=0.9";
|
||||
$.defaults.headers['Accept-Encoding'] = "gzip, deflate, br";
|
||||
|
||||
|
||||
function randomNumber(min = 0, max = 100) {
|
||||
return Math.min(Math.floor(min + Math.random() * (max - min)), max);
|
||||
}
|
||||
|
||||
class Env {
|
||||
constructor(name) {
|
||||
this.name = name
|
||||
this.username = '';
|
||||
this.cookie = '';
|
||||
this.cookies = [];
|
||||
this.index = '';
|
||||
this.ext = [];
|
||||
this.msg = [];
|
||||
this.delimiter = '';
|
||||
this.filename = ''
|
||||
this.appId = '';
|
||||
this.algo = {};
|
||||
this.bot = false;
|
||||
this.expire = false;
|
||||
}
|
||||
|
||||
async run(data = {
|
||||
wait: [1000, 2000],
|
||||
bot: false,
|
||||
delimiter: '',
|
||||
o2o: false,
|
||||
random: false,
|
||||
once: false,
|
||||
blacklist: [],
|
||||
whitelist: []
|
||||
}) {
|
||||
this.filename = process.argv[1];
|
||||
console.log(`${this.now()} ${this.name} ${this.filename} 开始运行...`);
|
||||
this.start = this.timestamp();
|
||||
await this.config()
|
||||
if (data?.delimiter) {
|
||||
this.delimiter = data?.delimiter
|
||||
}
|
||||
if (data?.bot) {
|
||||
this.bot = data.bot;
|
||||
}
|
||||
if (data?.blacklist?.length > 0) {
|
||||
for (const cki of data.blacklist) {
|
||||
delete cookies[cki - 1];
|
||||
}
|
||||
}
|
||||
if (data?.whitelist?.length > 0) {
|
||||
let cks = []
|
||||
for (const cki of data.whitelist) {
|
||||
if (cki - 1 < cookies.length) {
|
||||
cks.push(cookies[cki - 1])
|
||||
}
|
||||
}
|
||||
cookies = cks;
|
||||
}
|
||||
if (data?.random) {
|
||||
cookies = this.randomArray(cookies)
|
||||
}
|
||||
await this.verify()
|
||||
this.cookies = cookies;
|
||||
if (data?.before) {
|
||||
for (let i = 0; i <= this.cookies.length; i++) {
|
||||
if (this.cookies[i] && !this.expire) {
|
||||
let cookie = this.cookies[i];
|
||||
this.cookie = cookie;
|
||||
this.username = decodeURIComponent(
|
||||
cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
||||
$.defaults.headers['Cookie'] = this.cookie;
|
||||
this.index = i + 1;
|
||||
let me = {
|
||||
username: this.username,
|
||||
index: this.index,
|
||||
cookie: this.cookie
|
||||
};
|
||||
try {
|
||||
this.ext.push(Object.assign(me, await this.before()));
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
if (data?.wait?.length > 0 && this.index
|
||||
!== cookies.length) {
|
||||
await this.wait(data?.wait[0], data?.wait[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let once = false;
|
||||
for (let i = 0; i <= this.cookies.length; i++) {
|
||||
if (this.cookies[i] && !this.expire) {
|
||||
this.index = i + 1;
|
||||
if (data?.once && this.index !== data.once) {
|
||||
once = true;
|
||||
continue;
|
||||
}
|
||||
let cookie = this.cookies[i];
|
||||
this.cookie = cookie;
|
||||
this.username = decodeURIComponent(
|
||||
cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
||||
$.defaults.headers['Cookie'] = this.cookie;
|
||||
this.index = i + 1;
|
||||
try {
|
||||
await this.logic()
|
||||
if (data?.o2o) {
|
||||
await this.send();
|
||||
testMode ? this.log(this.msg.join("\n")) : ''
|
||||
this.msg = [];
|
||||
}
|
||||
if (once) {
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
this.log('捕获异常', e)
|
||||
}
|
||||
if (data?.wait?.length > 0 && this.index !== cookies.length) {
|
||||
await this.wait(data?.wait[0], data?.wait[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.after()
|
||||
console.log(`${this.now()} ${this.name} 运行结束,耗时 ${this.timestamp()
|
||||
- this.start}ms\n`)
|
||||
testMode && this.msg.length > 0 ? console.log(this.msg.join("\n")) : ''
|
||||
if (!data?.o2o) {
|
||||
await this.send();
|
||||
}
|
||||
}
|
||||
|
||||
async config() {
|
||||
|
||||
}
|
||||
|
||||
deleteCookie() {
|
||||
delete this.cookies[this.index - 1]
|
||||
return {};
|
||||
}
|
||||
|
||||
groupBy(arr, fn) {
|
||||
const data = {};
|
||||
arr.forEach(function (o) {
|
||||
const k = fn(o);
|
||||
data[k] = data[k] || []
|
||||
data[k].push(o)
|
||||
})
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async send() {
|
||||
if (this.msg?.length > 0) {
|
||||
this.msg.push(
|
||||
'运行时长:' + ((this.timestamp() - this.start) / 1000).toFixed(2)
|
||||
+ 's')
|
||||
if (this.bot) {
|
||||
await notify.sendNotify("/" + this.name,
|
||||
this.msg.join(this.delimiter || ''))
|
||||
} else {
|
||||
await notify.sendNotify(this.name, this.msg.join("\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async verify() {
|
||||
let fn = this.filename
|
||||
|
||||
function av(s) {
|
||||
return s.trim().match(/([a-z_])*$/)[0];
|
||||
}
|
||||
|
||||
let x = '109M95O106F120V95B', y = '99M102F100O', z = '109H99V',
|
||||
j = '102N97I99D116T111G114A121B', k = '112C112U',
|
||||
l = '109N95G106B100K95U', m = '119V120M';
|
||||
let reg = /[A-Z]/;
|
||||
x.concat(y).split(reg).map(o => +o).filter(o => o > 0).forEach(
|
||||
o => y += String.fromCharCode(o))
|
||||
x.concat(z).split(reg).map(o => +o).filter(o => o > 0).forEach(
|
||||
o => z += String.fromCharCode(o))
|
||||
x.concat(j).split(reg).map(o => +o).filter(o => o > 0).forEach(
|
||||
o => j += String.fromCharCode(o))
|
||||
x.concat(k).split(reg).map(o => +o).filter(o => o > 0).forEach(
|
||||
o => k += String.fromCharCode(o))
|
||||
l.concat(m).split(reg).map(o => +o).filter(o => o > 0).forEach(
|
||||
o => m += String.fromCharCode(o))
|
||||
this.appId = fn ? this.name.slice(0, 1)
|
||||
=== String.fromCharCode(77)
|
||||
? (fn.includes(av(y)) ? '10032' :
|
||||
fn.includes(av(z)) ? '10028' :
|
||||
fn.includes(av(j)) ? '10001' :
|
||||
fn.includes(av(k)) ? '10038' :
|
||||
fn.includes(av(m)) ? 'wx' : '') : ''
|
||||
: '';
|
||||
this.appId ? this.algo = await this._algo() : '';
|
||||
}
|
||||
|
||||
async wait(min, max) {
|
||||
if (max) {
|
||||
return new Promise(
|
||||
(resolve) => setTimeout(resolve, this.random(min, max)));
|
||||
} else {
|
||||
return new Promise((resolve) => setTimeout(resolve, min));
|
||||
}
|
||||
}
|
||||
|
||||
putMsg(msg) {
|
||||
this.log(msg)
|
||||
let r = [[' ', ''], ['优惠券', '券'], ['东券', '券'], ['店铺', ''],
|
||||
['恭喜', ''], ['获得', '']]
|
||||
for (let ele of r) {
|
||||
msg = msg.replace(ele[0], ele[1])
|
||||
}
|
||||
if (this.bot) {
|
||||
this.msg.push(msg)
|
||||
} else {
|
||||
if (this.msg.length > 0 && this.msg[this.msg.length - 1].includes(
|
||||
this.username)) {
|
||||
this.msg[this.msg.length - 1] = this.msg[this.msg.length
|
||||
- 1].split(" ")[0] + ' ' + [this.msg[this.msg.length - 1].split(
|
||||
" ")[1], msg].join(',')
|
||||
} else {
|
||||
this.msg.push(`【当前账号】${this.username} ${msg}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
md5(str) {
|
||||
return CryptoJS.MD5(str).toString()
|
||||
}
|
||||
|
||||
HmacSHA256(param, key) {
|
||||
return CryptoJS.HmacSHA256(param, key).toString()
|
||||
}
|
||||
|
||||
log(...msg) {
|
||||
this.s ? console.log(...msg) : console.log(
|
||||
`${this.now()} ${this.username}`, ...msg)
|
||||
}
|
||||
|
||||
//并
|
||||
union(a, b) {
|
||||
return a.concat(b.filter(o => !a.includes(o)))
|
||||
}
|
||||
|
||||
//交
|
||||
intersection(a, b) {
|
||||
return a.filter(o => b.includes(o))
|
||||
}
|
||||
|
||||
//交
|
||||
different(a, b) {
|
||||
return a.concat(b).filter(o => a.includes(o) && !b.includes(o))
|
||||
}
|
||||
|
||||
build(url) {
|
||||
if (url.match(/&callback=(jsonpCBK(.*))&/)) {
|
||||
let cb = url.match(/&callback=(jsonpCBK(.*))&/);
|
||||
url = url.replace(cb[1], this.randomCallback(cb[2].length || 0))
|
||||
}
|
||||
let stk = decodeURIComponent(this.getQueryString(url, '_stk') || '');
|
||||
if (stk) {
|
||||
let ens, hash, st = '',
|
||||
ts = this.now('yyyyMMddHHmmssSSS').toString(),
|
||||
tk = this.algo.tk, fp = this.algo.fp, em = this.algo.em;
|
||||
if (tk && fp && em) {
|
||||
hash = em(tk, fp, ts, this.appId, CryptoJS).toString(
|
||||
CryptoJS.enc.Hex)
|
||||
} else {
|
||||
const random = '5gkjB6SpmC9s';
|
||||
tk = 'tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc';
|
||||
fp = '9686767825751161';
|
||||
hash = CryptoJS.SHA512(
|
||||
`${tk}${fp}${ts}${this.appId}${random}`,
|
||||
tk).toString(CryptoJS.enc.Hex);
|
||||
}
|
||||
stk.split(',').map((item, index) => {
|
||||
st += `${item}:${this.getQueryString(url, item)}${index
|
||||
=== stk.split(',').length - 1 ? '' : '&'}`;
|
||||
})
|
||||
ens = encodeURIComponent(
|
||||
[''.concat(ts), ''.concat(fp),
|
||||
''.concat(this.appId), ''.concat(tk),
|
||||
''.concat(CryptoJS.HmacSHA256(st, hash.toString()).toString(
|
||||
CryptoJS.enc.Hex))].join(';'));
|
||||
if (url.match(/[?|&]h5st=(.*?)&/)) {
|
||||
url = url.replace(url.match(/[?|&]h5st=(.*?)&/)[1], 'H5ST')
|
||||
.replace(/H5ST/, ens)
|
||||
}
|
||||
let matchArr = [/[?|&]_time=(\d+)/, /[?|&]__t=(\d+)/,
|
||||
/[?|&]_ts=(\d+)/,
|
||||
/[?|&]_=(\d+)/, /[?|&]t=(\d+)/, /[?|&]_cfd_t=(\d+)/]
|
||||
for (let ms of matchArr) {
|
||||
if (url.match(ms)) {
|
||||
url = url.replace(url.match(ms)[1], Date.now())
|
||||
}
|
||||
}
|
||||
let t = this._tk();
|
||||
if (url.match(/strPgUUNum=(.*?)&/)) {
|
||||
url = url.replace(url.match(/strPgUUNum=(.*?)&/)[1], t.tk)
|
||||
if (url.match(/strPhoneID=(.*?)&/)) {
|
||||
url = url.replace(url.match(/strPhoneID=(.*?)&/)[1], t.id)
|
||||
}
|
||||
if (url.match(/strPgtimestamp=(.*?)&/)) {
|
||||
url = url.replace(url.match(/strPgtimestamp=(.*?)&/)[1],
|
||||
t.ts)
|
||||
}
|
||||
}
|
||||
if (url.match(/jxmc_jstoken=(.*?)&/)) {
|
||||
url = url.replace(url.match(/jxmc_jstoken=(.*?)&/)[1], t.tk)
|
||||
if (url.match(/phoneid=(.*?)&/)) {
|
||||
url = url.replace(url.match(/phoneid=(.*?)&/)[1], t.id)
|
||||
}
|
||||
if (url.match(/timestamp=(.*?)&/)) {
|
||||
url = url.replace(url.match(/timestamp=(.*?)&/)[1], t.ts)
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
getQueryString(url, name) {
|
||||
let reg = new RegExp("(^|[&?])" + name + "=([^&]*)(&|$)");
|
||||
let r = url.match(reg);
|
||||
if (r != null) {
|
||||
return unescape(r[2]);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
unique(arr) {
|
||||
return Array.from(new Set(arr))
|
||||
}
|
||||
|
||||
async logic() {
|
||||
console.log("default logic")
|
||||
}
|
||||
|
||||
async before() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
async after() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tryLock(username, key) {
|
||||
try {
|
||||
fs.accessSync(`/jd/log/lock/${key}_${username}`);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
setLock(username, key) {
|
||||
try {
|
||||
try {
|
||||
fs.accessSync(`/jd/log/lock`);
|
||||
} catch (e) {
|
||||
fs.mkdirSync(`/jd/log/lock`);
|
||||
}
|
||||
fs.mkdirSync(`/jd/log/lock/${key}_${username}`);
|
||||
return false;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
match(pattern, string) {
|
||||
pattern = (pattern instanceof Array) ? pattern : [pattern];
|
||||
for (let pat of pattern) {
|
||||
const match = pat.exec(string);
|
||||
if (match) {
|
||||
const len = match.length;
|
||||
if (len === 1) {
|
||||
return match;
|
||||
} else if (len === 2) {
|
||||
return match[1];
|
||||
} else {
|
||||
const r = [];
|
||||
for (let i = 1; i < len; i++) {
|
||||
r.push(match[i])
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
matchAll(pattern, string) {
|
||||
pattern = (pattern instanceof Array) ? pattern : [pattern];
|
||||
let match;
|
||||
let result = [];
|
||||
for (let p of pattern) {
|
||||
while ((match = p.exec(string)) != null) {
|
||||
let len = match.length;
|
||||
if (len === 1) {
|
||||
result.push(match);
|
||||
} else if (len === 2) {
|
||||
result.push(match[1]);
|
||||
} else {
|
||||
let r = [];
|
||||
for (let i = 1; i < len; i++) {
|
||||
r.push(match[i])
|
||||
}
|
||||
result.push(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async countdown(s) {
|
||||
let date = new Date();
|
||||
if (date.getMinutes() === 59) {
|
||||
let ms = this.now("s.SSS")
|
||||
if (ms < 59) {
|
||||
let st = (60 - ms) * 1000;
|
||||
console.log(` 需要等待时间 ${st / 1000} 秒`);
|
||||
await this.wait(st - (s || 20))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readFileSync(path) {
|
||||
try {
|
||||
return fs.readFileSync(path).toString();
|
||||
} catch (e) {
|
||||
console.log(path, '文件不存在进行创建')
|
||||
this.writeFileSync(path, '');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync(path, data) {
|
||||
fs.writeFileSync(path, data)
|
||||
}
|
||||
|
||||
random(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
async notify(text, desc) {
|
||||
return notify.sendNotify(text, desc);
|
||||
}
|
||||
|
||||
async get(url, headers) {
|
||||
url = this.appId ? this.build(url) : url
|
||||
return new Promise((resolve, reject) => {
|
||||
$.get(url, {headers: headers}).then(
|
||||
data => resolve(this.handler(data) || data))
|
||||
.catch(e => reject(e))
|
||||
})
|
||||
}
|
||||
|
||||
async get2(url, headers) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.get(url, {headers: headers}).then(
|
||||
data => resolve(data))
|
||||
.catch(e => reject(e))
|
||||
})
|
||||
}
|
||||
|
||||
async post(url, body, headers) {
|
||||
url = this.appId ? this.build(url) : url
|
||||
return new Promise((resolve, reject) => {
|
||||
$.post(url, body, {headers: headers})
|
||||
.then(data => resolve(this.handler(data) || data))
|
||||
.catch(e => reject(e));
|
||||
})
|
||||
}
|
||||
|
||||
//└
|
||||
async request(url, headers, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let __config = headers?.headers ? headers : {headers: headers};
|
||||
(body ? $.post(url, body, __config) : $.get(url, __config))
|
||||
.then(data => {
|
||||
this.__lt(data);
|
||||
resolve(data)
|
||||
})
|
||||
.catch(e => reject(e));
|
||||
})
|
||||
}
|
||||
|
||||
__lt(data) {
|
||||
if (this.appId.length !== 2) {
|
||||
return
|
||||
}
|
||||
let scs = data?.headers['set-cookie'] || data?.headers['Set-Cookie']
|
||||
|| ''
|
||||
if (!scs) {
|
||||
if (data?.data?.LZ_TOKEN_KEY && data?.data?.LZ_TOKEN_VALUE) {
|
||||
this.lz = `LZ_TOKEN_KEY=${data.data.LZ_TOKEN_KEY};LZ_TOKEN_VALUE=${data.data.LZ_TOKEN_VALUE};`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
let LZ_TOKEN_KEY = '', LZ_TOKEN_VALUE = ''
|
||||
let sc = typeof scs != 'object' ? scs.split(',') : scs
|
||||
for (let ck of sc) {
|
||||
let name = ck.split(";")[0].trim()
|
||||
if (name.split("=")[1]) {
|
||||
name.includes('LZ_TOKEN_KEY=')
|
||||
? LZ_TOKEN_KEY = name.replace(/ /g, '') + ';' : ''
|
||||
name.includes('LZ_TOKEN_VALUE=')
|
||||
? LZ_TOKEN_VALUE = name.replace(/ /g, '') + ';' : ''
|
||||
}
|
||||
}
|
||||
if (LZ_TOKEN_KEY && LZ_TOKEN_VALUE) {
|
||||
this.lz = `${LZ_TOKEN_KEY}${LZ_TOKEN_VALUE}`
|
||||
}
|
||||
// testMode ? this.log('lz', this.lz) : ''
|
||||
}
|
||||
|
||||
handler(res) {
|
||||
let data = res?.data || res?.body ||res;
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (typeof data === 'string') {
|
||||
data = data.replace(/[\n\r| ]/g, '');
|
||||
if (data.includes("try{jsonpCB")) {
|
||||
data = data.replace(/try{jsonpCB.*\({/, '{')
|
||||
.replace(/}\)([;])?}catch\(e\){}/, '}')
|
||||
} else if (data.includes('jsonpCB')) {
|
||||
let st = data.replace(/[\n\r]/g, '').replace(/jsonpCB.*\({/,
|
||||
'{');
|
||||
data = st.substring(0, st.length - 1)
|
||||
} else if (data.match(/try{.*\({/)) {
|
||||
data = data.replace(/try{.*\({/, '{')
|
||||
.replace(/}\)([;])?}catch\(e\){}/, '}')
|
||||
} else if (data.includes("jsonp")) {
|
||||
data = /{(.*)}/g.exec(data)[0]
|
||||
} else {
|
||||
testMode ? console.log('例外', data) : ''
|
||||
}
|
||||
testMode ? console.log(data) : ''
|
||||
testMode ? console.log('----------------分割线--------------------')
|
||||
: ''
|
||||
return JSON.parse(data)
|
||||
}
|
||||
testMode ? console.log(JSON.stringify(data)) : ''
|
||||
testMode ? console.log('----------------分割线---------------------') : ''
|
||||
return data;
|
||||
}
|
||||
|
||||
randomNum(length) {
|
||||
length = length || 32;
|
||||
let t = "0123456789", a = t.length, n = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
n += t.charAt(Math.floor(Math.random() * a));
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
randomString(e) {
|
||||
return this.uuid()
|
||||
}
|
||||
|
||||
uuid(x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") {
|
||||
return x.replace(/[xy]/g, function (x) {
|
||||
const r = 16 * Math.random() | 0, n = "x" === x ? r : 3 & r | 8;
|
||||
return n.toString(36)
|
||||
})
|
||||
}
|
||||
|
||||
async unfollow(shopId) {
|
||||
let url = 'https://api.m.jd.com/client.action?g_ty=ls&g_tk=518274330'
|
||||
let body = `functionId=followShop&body={"follow":"false","shopId":"${shopId}","award":"true","sourceRpc":"shop_app_home_follow"}&osVersion=13.7&appid=wh5&clientVersion=9.2.0&loginType=2&loginWQBiz=interact`
|
||||
let headers = {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Host': 'api.m.jd.com',
|
||||
'Connection': 'keep-alive',
|
||||
'Accept-Language': 'zh-cn',
|
||||
'Cookie': this.cookie
|
||||
}
|
||||
headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 14_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.4(0x1800042c) NetType/4G Language/zh_CN miniProgram`
|
||||
let {data} = await this.request(url, headers, body);
|
||||
this.log(data.msg)
|
||||
return data;
|
||||
}
|
||||
|
||||
randomCallback(e = 1) {
|
||||
let t = "abcdefghigklmnopqrstuvwsyz", a = t.length, n = '';
|
||||
for (let i = 0; i < e; i++) {
|
||||
n += t.charAt(Math.floor(Math.random() * a));
|
||||
}
|
||||
return "jsonpCBK" + n.toUpperCase()
|
||||
}
|
||||
|
||||
randomArray(arr, count) {
|
||||
count = count || arr.length
|
||||
let shuffled = arr.slice(0), i = arr.length, min = i - count, temp,
|
||||
index;
|
||||
while (i-- > min) {
|
||||
index = Math.floor((i + 1) * Math.random());
|
||||
temp = shuffled[index];
|
||||
shuffled[index] = shuffled[i];
|
||||
shuffled[i] = temp;
|
||||
}
|
||||
return shuffled.slice(min);
|
||||
}
|
||||
|
||||
now(fmt) {
|
||||
return format(Date.now(), fmt || 'yyyy-MM-dd HH:mm:ss.SSS')
|
||||
}
|
||||
|
||||
formatDate(date, fmt) {
|
||||
// noinspection JSCheckFunctionSignatures
|
||||
return format(typeof date === 'object' ? date : new Date(
|
||||
typeof date === 'string' ? date * 1 : date),
|
||||
fmt || 'yyyy-MM-dd')
|
||||
}
|
||||
|
||||
timestamp() {
|
||||
return new Date().getTime()
|
||||
}
|
||||
|
||||
_tk() {
|
||||
let id = function (n) {
|
||||
let src = 'abcdefghijklmnopqrstuvwxyz1234567890', res = '';
|
||||
for (let i = 0; i < n; i++) {
|
||||
res += src[Math.floor(src.length * Math.random())];
|
||||
}
|
||||
return res;
|
||||
}(40), ts = Date.now().toString(), tk = this.md5(
|
||||
'' + decodeURIComponent(this.username) + ts + id
|
||||
+ 'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy');
|
||||
return {ts: ts, id: id, tk: tk}
|
||||
}
|
||||
|
||||
async get_bean() {
|
||||
let {data} = await $.post('https://api.m.jd.com/client.action',
|
||||
`functionId=plantBeanIndex&body=${escape(
|
||||
JSON.stringify({
|
||||
version: "9.0.0.1",
|
||||
"monitor_source": "plant_app_plant_index",
|
||||
"monitor_refer": ""
|
||||
})
|
||||
)}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`,
|
||||
{
|
||||
'Host': "api.m.jd.com",
|
||||
"Cookie": this.cookie
|
||||
});
|
||||
debugger
|
||||
return data.data.jwordShareInfo.shareUrl.split('Uuid=')[1] ?? ''
|
||||
}
|
||||
|
||||
async get_farm() {
|
||||
let {data} = await $.post(
|
||||
'https://api.m.jd.com/client.action?functionId=initForFarm',
|
||||
`body=${escape(
|
||||
JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`,
|
||||
{
|
||||
"origin": "https://home.m.jd.com",
|
||||
"referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Cookie": this.cookie
|
||||
})
|
||||
debugger
|
||||
return data?.farmUserPro?.shareCode ?? ''
|
||||
}
|
||||
|
||||
async _algo() {
|
||||
let fp = function () {
|
||||
let e = "0123456789", a = 13, i = ''
|
||||
for (; a--;) {
|
||||
i += e[Math.random() * e.length | 0]
|
||||
}
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}();
|
||||
let data = await this.post(
|
||||
'https://cactus.jd.com/request_algo?g_ty=ajax', JSON.stringify({
|
||||
"version": "1.0",
|
||||
"fp": fp,
|
||||
"appId": this.appId,
|
||||
"timestamp": this.timestamp(),
|
||||
"platform": "web",
|
||||
"expandParams": ''
|
||||
}), {
|
||||
'Authority': 'cactus.jd.com',
|
||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
|
||||
'Content-Type': 'application/json',
|
||||
'Origin': 'https://st.jingxi.com',
|
||||
'Referer': 'https://st.jingxi.com/',
|
||||
});
|
||||
return {
|
||||
fp: fp.toString(),
|
||||
tk: data?.data?.result?.tk || data?.result?.tk,
|
||||
em: new Function(
|
||||
`return ${data?.data?.result?.algo || data?.result?.algo}`)()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {Env, CryptoJS};
|
10006
utils/mf_log.ts
10006
utils/mf_log.ts
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
var hello = {
|
||||
}
|
||||
module.exports=hello;
|
@ -1,39 +0,0 @@
|
||||
import axios from "axios";
|
||||
import {readFileSync} from "fs";
|
||||
|
||||
let account: { pt_pin: string, pushplus?: string } [] = []
|
||||
|
||||
try {
|
||||
account = JSON.parse(readFileSync("./utils/account.json").toString())
|
||||
} catch (e) {
|
||||
console.log('utils/account.json load failed')
|
||||
}
|
||||
|
||||
export async function pushplus(title: string, content: string, template: string = 'html'): Promise<void> {
|
||||
let token: string
|
||||
for (let user of account) {
|
||||
if (content.includes(decodeURIComponent(user.pt_pin)) && user.pushplus) {
|
||||
token = user.pushplus
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!token) {
|
||||
console.log('no pushplus token')
|
||||
return
|
||||
}
|
||||
let {data}: any = await axios.post('https://www.pushplus.plus/send', {
|
||||
token: token,
|
||||
title: title,
|
||||
content: content,
|
||||
template: template
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
if (data.code === 200) {
|
||||
console.log('pushplus发送成功')
|
||||
} else {
|
||||
console.log('pushplus发送失败', JSON.stringify(data))
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
import axios from "axios";
|
||||
import USER_AGENT, {randomWord} from "../TS_USER_AGENTS";
|
||||
import {requestAlgo, geth5st} from './V3'
|
||||
|
||||
async function bean(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action', `functionId=plantBeanIndex&body=${decodeURIComponent(JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
Host: "api.m.jd.com",
|
||||
"User-Agent": USER_AGENT
|
||||
}
|
||||
})
|
||||
if (data.data?.jwordShareInfo?.shareUrl)
|
||||
return data.data?.jwordShareInfo.shareUrl.split('Uuid=')![1]
|
||||
else
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function farm(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${encodeURIComponent(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
"cookie": cookie,
|
||||
"origin": "https://home.m.jd.com",
|
||||
"referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
"User-Agent": USER_AGENT,
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
})
|
||||
return data.farmUserPro?.shareCode ?? 'null'
|
||||
}
|
||||
|
||||
async function health(cookie: string) {
|
||||
let {data}: any = await axios.get(`https://api.m.jd.com/client.action/client.action?functionId=jdhealth_getTaskDetail&body=${encodeURIComponent(JSON.stringify({"buildingId": "", taskId: 6, "channelId": 1}))}&client=wh5&clientVersion=1.0.0`, {
|
||||
headers: {
|
||||
"Cookie": cookie,
|
||||
"origin": "https://h5.m.jd.com",
|
||||
"referer": "https://h5.m.jd.com/",
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
"User-Agent": USER_AGENT
|
||||
}
|
||||
})
|
||||
return data.data?.result?.taskVos[0].assistTaskDetailVo.taskToken ?? 'null'
|
||||
}
|
||||
|
||||
async function pet(cookie: string) {
|
||||
let {data} = await axios.post('https://api.m.jd.com/client.action',
|
||||
`functionId=initPetTown&body=${JSON.stringify({"version": 1})}&appid=wh5&client=apple&clientVersion=10.3.6&build=167963&rfs=0000`, {
|
||||
headers: {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://h5.m.jd.com',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Referer': 'https://h5.m.jd.com/',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return data.result?.shareCode ?? 'null'
|
||||
}
|
||||
|
||||
async function factory(cookie: string) {
|
||||
let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=jdfactory_getTaskDetail`,
|
||||
`functionId=jdfactory_getTaskDetail&body=${encodeURIComponent(JSON.stringify({}))}&client=wh5&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
origin: "https://h5.m.jd.com",
|
||||
referer: "https://h5.m.jd.com/",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'User-Agent': USER_AGENT,
|
||||
}
|
||||
});
|
||||
if (data.data.bizCode === 0) {
|
||||
for (let t of data.data?.result?.taskVos) {
|
||||
if (t.taskType === 14)
|
||||
return t.assistTaskDetailVo.taskToken
|
||||
}
|
||||
}
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function sgmh(cookie: string) {
|
||||
let {data}: any = await axios.post(`https://api.m.jd.com/client.action`,
|
||||
`functionId=interact_template_getHomeData&body={"appId":"1EFRXxg","taskToken":""}&client=wh5&clientVersion=1.0.0`, {
|
||||
headers: {
|
||||
'Origin': `https://h5.m.jd.com`,
|
||||
'Cookie': cookie,
|
||||
'Accept': `application/json, text/plain, */*`,
|
||||
'Referer': `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,
|
||||
'Host': `api.m.jd.com`,
|
||||
}
|
||||
})
|
||||
if (data.data.bizCode === 0) {
|
||||
for (let t of data.data?.result?.taskVos) {
|
||||
if (t.taskName === '邀请好友助力')
|
||||
return t.assistTaskDetailVo.taskToken
|
||||
}
|
||||
}
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function jxfactory(cookie: string) {
|
||||
await requestAlgo('c0ff1')
|
||||
let url: string, timestamp = Date.now()
|
||||
let stk = `_time,bizCode,showAreaTaskFlag,source`, params = {showAreaTaskFlag: '1', bizCode: 'dream_factory'}
|
||||
let t: { key: string, value: string } [] = [
|
||||
{key: '_time', value: timestamp.toString()},
|
||||
{key: '_ts', value: timestamp.toString()},
|
||||
{key: 'bizCode', value: 'dream_factory'},
|
||||
{key: 'source', value: 'dreamfactory'},
|
||||
]
|
||||
url = `https://m.jingxi.com/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&_time=${timestamp}&_ts=${timestamp}&_stk=${encodeURIComponent(stk)}&_=${timestamp + 3}&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
|
||||
|
||||
for (let [key, value] of Object.entries(params)) {
|
||||
t.push({key, value})
|
||||
url += `&${key}=${value}`
|
||||
}
|
||||
let h5st = geth5st(t, 'c0ff1')
|
||||
url += `&h5st=${encodeURIComponent(h5st)}`
|
||||
let {data}: any = await axios.get(url, {
|
||||
headers: {
|
||||
'Referer': 'https://actst.jingxi.com/pingou/dream_factory/index.html',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Host': 'm.jingxi.com',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return JSON.parse(data.match(/try{jsonpCBK.?\((.*)/)![1]).data?.encryptPin || 'null'
|
||||
}
|
||||
|
||||
export {
|
||||
bean,
|
||||
farm,
|
||||
health,
|
||||
pet,
|
||||
factory,
|
||||
sgmh,
|
||||
jxfactory
|
||||
}
|
Loading…
Reference in New Issue
Block a user