2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2025-01-22 13:51:10 +08:00

对于原神签到加入geetest绕验证码方法以及延迟修正

This commit is contained in:
Ctrlcvs 2022-10-14 10:02:45 +08:00
parent 7118ecf5a1
commit 8b39d7e3ec
3 changed files with 85 additions and 55 deletions

View File

@ -191,6 +191,10 @@ export default class miHoYoApi {
query: `login_ticket=${data.loginTicket}&token_types=3&uid=${data.loginUid}`,
types: 'stoken'
},
validate: {
url: `https://api.geetest.com/ajax.php`,
query: `gt=${data?.gt}&challenge=${data?.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`
},
cloudLogin: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`,
types: 'cloud'
@ -202,7 +206,9 @@ export default class miHoYoApi {
},
cloudGamer: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/ackNotification`,
body: {id:data.reward_id},
body: {
id: data.reward_id
},
types: 'cloud'
},
cloudGet: {
@ -325,12 +331,11 @@ export default class miHoYoApi {
}
if (this.isOs) {
let os_Header = {
'x-rpc-app_version':'2.9.0',
app_version: '2.9.0',
// User_Agent: `Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBSOversea/2.9.0`,
'x-rpc-app_version': '2.18.1',
app_version: '2.18.1',
client_type: '2',
'x-rpc-client_type': '2',
Origin: 'https://webstatic-sea.hoyolab.com',
Origin: 'https://app.hoyolab.com',
X_Requested_With: 'com.mihoyo.hoyolab',
Referer: 'https://app.hoyolab.com',
Host: 'api-os-takumi.mihoyo.com',

View File

@ -16,7 +16,8 @@ export async function randomSleepAsync(end) {
export function randomString(length, os = false) {
let randomStr = '';
for (let i = 0; i < length; i++) {
randomStr += _.sample(os?'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':'abcdefghijklmnopqrstuvwxyz0123456789');
randomStr += _.sample(os ? '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' :
'abcdefghijklmnopqrstuvwxyz0123456789');
}
return randomStr;
}
@ -24,10 +25,15 @@ export function randomString(length,os=false) {
export async function redisGet(userId, type = 'bbs') {
await redis.get(`xiaoyao:${type}:${userId}`);
}
export async function redisSet(userId,type='bbs',data){
export async function redisSet(userId="all", type = 'bbs', data, time=0) {
var time = moment(Date.now()).add('days', 1).format('YYYY-MM-DD 00:00:00')
var new_date = (new Date(time).getTime() - new Date().getTime()) / 1000 //获取隔天凌晨的时间差
await redis.set(`xiaoyao:${type}:${userId}`,JSON.stringify(data),{EX:parseInt(new_date)});
if (time!==0) {
new_date = time
}
await redis.set(`xiaoyao:${type}:${userId}`, JSON.stringify(data), {
EX: parseInt(new_date)
});
}
/**
* 发送私聊消息仅给好友发送
@ -97,10 +103,13 @@ export async function getCookieMap(cookie) {
return cookieMap || {};
}
export default {
sleepAsync,getServer,
sleepAsync,
getServer,
randomSleepAsync,
replyMake,
randomString,redisGet,redisSet,
randomString,
redisGet,
redisSet,
relpyPrivate,
getCookieMap
}

View File

@ -110,29 +110,46 @@ export default class user {
if (res?.data?.is_sign) {
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
} else {
for (let i = 0; i < 2; i++) { //循环请求
let signTime = await redis.get(`xiaoyao:sign`)
if (signTime) {
//有数据的时候不得行必须出去
if (!mysTask) {
message += "${item.nickname}-${item.game_uid}:验证码失败请等待6分钟后重试或者手动上米游社签到~";
break;
} else {
await utils.sleepAsync(60000 * 6) //等6分钟再说
//ps你要是觉得改有加高过的概率就改吧随便你反正到时候黑IP的不是我
}
}
res = await this.getData("sign", data)
if (res?.data?.gt) { //去除geetest
// let validate = await geetest(res.data)
// if (validate) {
// let header = {}
// header["x-rpc-challenge"] = res["data"]["challenge"]
// header["x-rpc-validate"] = validate
// header["x-rpc-seccode"] = `${validate}|jordan`
// data.headers = header
// res = await this.getData("sign", data)
// if (!res?.data?.gt) {
// message += `${item.nickname}-${item.game_uid}:验证码签到成功~`
// } else {
await utils.sleepAsync(2000)
if (res?.data?.gt) { //进行3次验证码访问签到加高通过概率
let validate = await this.geetest(res.data)
if (validate) {
let header = {}
header["x-rpc-challenge"] = res["data"]["challenge"]
header["x-rpc-validate"] = validate
header["x-rpc-seccode"] = `${validate}|jordan`
data.headers = header
res = await this.getData("sign", data)
if (!res?.data?.gt) {
message += `${item.nickname}-${item.game_uid}:验证码签到成功~\n`
break;
} else {
item.is_sign = false;
message += `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
// }
// }
message +=
`${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
}
}
} else {
item.total_sign_day++;
message +=
`${item.nickname}-${item.game_uid}${res.message=="OK"?"签到成功":res.message}\n`
}
}
await utils.sleepAsync(2000)
}
//获取签到信息和奖励信息
const SignInfo = await this.getData("home", data)
if (SignInfo) {
@ -344,7 +361,6 @@ export default class user {
// let ck=`${dir}${qq*1}.yaml`
// let cklis=fs.readFileSync(ck, 'utf-8')
// cklist=YAML.parse(cklis)
// console.log(cklist)
// }else{
// cklist=NoteCookie[qq*1]
// }
@ -539,6 +555,10 @@ export default class user {
if (res?.data?.validate) {
let validate = res?.data?.validate
return validate
} else if (res?.data?.result !== "slide") {
await redis.set(`xiaoyao:sign`, 1, { //写入缓存 过不了了
EX: 60 * 6 //等6分钟后再给用指令 避免ddos
});
}
return ""
}
@ -623,10 +643,6 @@ export default class user {
loginUid,
loginTicket
})
// this.getData("bbsStoken", {
// loginUid,
// loginTicket
// })
if (res?.data) {
datalist[e.uid] = {
stuid: map?.get("account_id"),