-
Notifications
You must be signed in to change notification settings - Fork 2
/
ele_check_ck.js
184 lines (158 loc) · 6.11 KB
/
ele_check_ck.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
* @kolikow
* 变量:elmck: 必填,账号cookie
* cron: 0 9,18 * * *
* 每天1-2次即可
* elmck: 'unb=xxx;cookie2=xxxUSERID=xx;SID=xxx;wxUid=xx;'
* export appToken='AT_xxx' #wxpusher的appToken
* export myUid='UID_xxx' #自己的uid,接收通知
* export tunnel='elm.xxx.xyz' #掉线重新登录地址
*/
const $ = new Env('饿了么CK检测');
const {
getEnvsByName,
DisableCk,
EnableCk,
updateEnv,
updateEnv11,
getEnvByUserId
} = require("./ql");
const {
wait,
checkCk,
validateCarmeWithType,
invalidCookieNotify,
getUserInfo,
runOne,
getCookieMap
} = require("./common.js");
const _0x11f78e = require("moment");
function _0x543ec4(_0x3fdeea, _0x4dabab) {
return Math.floor(Math.random() * (_0x4dabab - _0x3fdeea + 1) + _0x3fdeea);
}
function _0x389941(_0x1daaab) {
let _0x59299c = "";
for (let [_0x7cf76, _0x5050e8] of _0x1daaab) {
_0x59299c += _0x7cf76 + "=" + _0x5050e8 + ";";
}
return _0x59299c;
}
async function _0x179175(data, context, options) {
let responseData = await runOne(context, options);
if (responseData) {
if (responseData.code === 3000) {
let parsedData = JSON.parse(responseData.returnValue.data);
const cookies = parsedData.cookies;
let cookie2 = null;
let unb = null;
for (const cookie of cookies) {
const cookie2Match = cookie.match(/cookie2=([^;]+)/);
if (cookie2Match) {
cookie2 = cookie2Match[1];
}
const unbMatch = cookie.match(/unb=([^;]+)/);
if (unbMatch) {
unb = unbMatch[1];
}
if (cookie2 && unb) {
break;
}
}
const expiryTimestamp = parsedData.expires;
const expiryDate = _0x11f78e(expiryTimestamp * 1000).format("YYYY-MM-DD HH:mm:ss");
let cookieMap = getCookieMap(context);
let extraMap = JSON.parse(responseData.returnValue.extMap.eleExt);
for (let item of extraMap) {
if (item.name === "SID") {
break;
}
}
let updatedContext = await runOne(context, cookieMap.get("SID"));
if (!updatedContext) {
return;
}
cookieMap.set('cookie2', cookie2);
let updatedEnvironment = _0x389941(cookieMap);
if (data.id) {
await updateEnv11(updatedEnvironment, data.id, data.remarks);
} else {
await updateEnv(updatedEnvironment, data._id, data.remarks);
}
let userID = cookieMap.get("USERID");
let userEnvironment = await getEnvByUserId(userID);
let successMessage = "刷新成功: " + expiryDate;
console.log(successMessage);
return successMessage;
} else {
if (responseData.message) {
console.log(responseData.message);
} else {
console.log(response.ret[0]);
}
return null;
}
}
}
(async function _0x1f3fe2() {
const aleo = process.env.ELE_CARME;
await validateCarmeWithType(aleo, 1);
const pragati = await getEnvsByName("elmck");
for (let mackala = 0; mackala < pragati.length; mackala++) {
let athel = pragati[mackala].value;
if (!athel) {
console.log(" ❌无效用户信息, 请重新获取ck");
} else {
try {
var houda = 0;
if (pragati[mackala]._id) {
houda = pragati[mackala]._id;
}
if (pragati[mackala].id) {
houda = pragati[mackala].id;
}
athel = athel.replace(/\s/g, "");
let lavante = await checkCk(athel, mackala);
if (!lavante) {
let deshaune = await _0x179175(pragati[mackala], athel);
if (deshaune && deshaune.indexOf("刷新成功") !== -1) {
await EnableCk(houda);
console.log("第", mackala + 1, "账号正常😁\n");
} else {
const lakeyah = await DisableCk(houda);
if (lakeyah.code === 200) {
console.log("第", mackala + 1, "账号失效!已🈲用");
} else {
console.log("第", mackala + 1, "账号失效!请重新登录!!!😭");
}
await invalidCookieNotify(athel, pragati[mackala].remarks);
}
} else {
let amirr = await getUserInfo(athel);
if (!amirr.encryptMobile) {
let rudolphe = await _0x179175(pragati[mackala], athel);
if (rudolphe && rudolphe.indexOf("刷新成功") !== -1) {
await EnableCk(houda);
console.log("第", mackala + 1, "账号正常😁\n");
} else {
const jericca = await DisableCk(houda);
if (jericca.code === 200) {
console.log("第", mackala + 1, "账号失效!已🈲用");
} else {
console.log("第", mackala + 1, "账号失效!请重新登录!!!😭");
}
}
await invalidCookieNotify(athel, pragati[mackala].remarks);
} else {
await _0x179175(pragati[mackala], athel, getCookieMap(athel).get("SID"));
await EnableCk(houda);
console.log("第", mackala + 1, "账号正常🎉🎉\n");
}
}
} catch (hannelore) {
console.log(hannelore);
}
}
await wait(_0x543ec4(1, 3));
}
process.exit(0);
}());