├── README.md ├── common.js ├── ele_2048.js ├── ele_assest.js ├── ele_chd.py ├── ele_check_ck新.js ├── ele_cycg.js ├── ele_elge.js ├── ele_femf.js ├── ele_fruit.py ├── ele_hctmm.js ├── ele_helper.js ├── ele_llk.js ├── ele_lyb.js ├── ele_mhxy.js ├── ele_mst.js ├── ele_sqqd.js ├── ele_sskz.js ├── ele_tjcs.js ├── ele_xydb.js ├── elm_elecoupon.py ├── elm_tyt.py ├── gy.py ├── kpbl.py ├── lgqs.py ├── lyb.py ├── notify.py ├── ql.js ├── ql1.js ├── rsa_encrypt.js ├── sendNotify.js ├── sendNotify1.js └── tcs.py /README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ele_chd.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import os 3 | import re 4 | import time 5 | import requests 6 | from urllib.parse import urlencode, quote 7 | 8 | host = 'https://acs.m.goofish.com' 9 | 10 | ck = '' 11 | 12 | 13 | import json 14 | import random 15 | import string 16 | 17 | 18 | def generate_random_string(length=50): 19 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 20 | 21 | 22 | def reorder_ck(s: str) -> str: 23 | order = ["cookie2", "sgcookie", "unb", "USERID", "SID", "token", "utdid", "deviceId", "umt"] 24 | cookies = s.split(';') 25 | cookie_dict = {} 26 | for cookie in cookies: 27 | key_value = cookie.split('=', 1) 28 | if len(key_value) == 2: 29 | key, value = key_value 30 | cookie_dict[key.strip()] = value.strip() 31 | reordered_cookies = [] 32 | for key in order: 33 | if key in cookie_dict: 34 | reordered_cookies.append(f"{key}={cookie_dict[key]}") 35 | return ';'.join(reordered_cookies) + ';' 36 | 37 | 38 | def get_ck_usid(ck1): 39 | key_value_pairs = ck1.split(";") 40 | for pair in key_value_pairs: 41 | key, value = pair.split("=") 42 | if key == "USERID": 43 | return value 44 | else: 45 | return '账号' 46 | 47 | 48 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 49 | """ 50 | 合并带_m_h5_tk 51 | """ 52 | txt = cookie_str.replace(" ", "") 53 | txt = txt.replace("chushi;", "") 54 | if txt[-1] != ';': 55 | txt += ';' 56 | cookie_parts = txt.split(';')[:-1] 57 | updated = False 58 | for i, part in enumerate(cookie_parts): 59 | key_value = part.split('=') 60 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 61 | cookie_parts[i] = tk_cookie 62 | updated = True 63 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 64 | cookie_parts[i] = enc_cookie 65 | updated = True 66 | 67 | if updated: 68 | return ';'.join(cookie_parts) + ';' 69 | else: 70 | return txt + tk_cookie + ';' + enc_cookie + ';' 71 | 72 | 73 | def tq(cookie_string): 74 | """ 75 | 获取_m_h5_tk 76 | """ 77 | if not cookie_string: 78 | return '-1' 79 | cookie_pairs = cookie_string.split(';') 80 | for pair in cookie_pairs: 81 | key_value = pair.split('=') 82 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 83 | return key_value[1] 84 | return '-1' 85 | 86 | 87 | def tq1(txt): 88 | """ 89 | 拆分cookie 90 | """ 91 | try: 92 | txt = txt.replace(" ", "") 93 | if txt[-1] != ';': 94 | txt += ';' 95 | pairs = txt.split(";")[:-1] 96 | ck_json = {} 97 | for pair in pairs: 98 | key, value = pair.split("=", 1) 99 | ck_json[key] = value 100 | return ck_json 101 | except Exception as e: 102 | print(f'❎Cookie解析错误: {e}') 103 | return {} 104 | 105 | 106 | def md5(text): 107 | """ 108 | md5加密 109 | """ 110 | hash_md5 = hashlib.md5() 111 | hash_md5.update(text.encode()) 112 | return hash_md5.hexdigest() 113 | 114 | 115 | def check_cookie(cookie): 116 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 117 | headers = { 118 | "Cookie": cookie, 119 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 120 | } 121 | 122 | try: 123 | response = requests.get(url, headers=headers) 124 | if response.status_code == 200: 125 | cookie_jar = response.cookies 126 | token = cookie_jar.get('_m_h5_tk', '') 127 | token_cookie = "_m_h5_tk=" + token 128 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 129 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 130 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 131 | return cookie 132 | else: 133 | return None 134 | except Exception as e: 135 | print("解析ck错误") 136 | return None 137 | 138 | 139 | class TYT: 140 | def __init__(self, cki): 141 | self.name = None 142 | self.ck = cki 143 | self.cki = tq1(cki) 144 | self.uid = self.cki.get("unb") 145 | self.sid = self.cki.get("cookie2") 146 | self.name1 = get_ck_usid(cki) 147 | if self.name1 is None: 148 | raise ValueError("❎获取USERID失败,跳过该账号") 149 | 150 | def req(self, api, data, v="1.0"): 151 | try: 152 | ck3 = check_cookie(self.ck) 153 | headers = { 154 | "authority": "shopping.ele.me", 155 | "accept": "application/json", 156 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 157 | "cache-control": "no-cache", 158 | "content-type": "application/x-www-form-urlencoded", 159 | "cookie": ck3, 160 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 161 | } 162 | timestamp = int(time.time() * 1000) 163 | data_str = json.dumps(data) 164 | token = tq(ck3) 165 | token_part = token.split("_")[0] 166 | 167 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 168 | sign = md5(sign_str) 169 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json" 170 | data1 = urlencode({'data': data_str}) 171 | r = requests.post(url, headers=headers, data=data1) 172 | if r: 173 | return r 174 | else: 175 | return None 176 | except Exception as e: 177 | return None 178 | 179 | def main(self): 180 | try: 181 | if self.login(): 182 | return self.task() 183 | except Exception as e: 184 | print(f'❎登录失败: {e}') 185 | return False 186 | 187 | def login(self): 188 | amount = 0 189 | api1 = 'mtop.alsc.user.detail.query' 190 | data1 = {} 191 | try: 192 | res1 = self.req(api1, data1, "1.0") 193 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 194 | self.name = res1.json()["data"]["encryptMobile"] 195 | api = 'mtop.alibaba.svip.langrisser.query' 196 | data = { 197 | "lgrsRequestItems": "[{\"backup\":false,\"count\":1,\"data\":{\"needHead\":true,\"month\":\"\"},\"resId\":\"867018\"}]", 198 | "latitude": 30.59858, "longitude": 105.756336} 199 | try: 200 | res = self.req(api, data, "1.0") 201 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 202 | uu = res.json()['data']['data']['867018']['data'] 203 | for yyy in uu: 204 | if 'peaCount' in yyy: 205 | amount = yyy['peaCount'] 206 | print(f'[{self.name}] ✅登录成功,吃货豆----[{amount}]') 207 | return True 208 | else: 209 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 210 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 211 | return False 212 | else: 213 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 214 | return False 215 | except Exception as e: 216 | print(f"[{self.name1}] ❎登录失败: {e}") 217 | return False 218 | else: 219 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 220 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 221 | return False 222 | else: 223 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 224 | return False 225 | except Exception as e: 226 | print(f"[{self.name1}] ❎登录失败: {e}") 227 | return False 228 | 229 | def task(self): 230 | try: 231 | api = 'mtop.alibaba.svip.langrisser.query' 232 | data = {"callSource": "biz_card_main", "lgrsRequestItems": "[{\"resId\":\"224166\",\"data\":{}}]", 233 | "extra": "{\"source\":\"mtop\"}", "longitude": "105.75325090438128", 234 | "latitude": "30.597472842782736"} 235 | res = self.req(api, data, "1.0") 236 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 237 | for yyyy in res.json()['data']['data']['224166']['data']: 238 | if yyyy['rewardStatus'] == 'TODO': 239 | api1 = 'mtop.alibaba.svip.langrisser.act' 240 | data1 = { 241 | "extra": "{\"missionDefId\":" + str(yyyy[ 242 | 'distinctId']) + ",\"missionCollectionId\":36,\"missionType\":\"SIMPLESIGNIN\",\"source\":\"mtop\",\"asac\":\"2A21119A45TTVAEXP40N7N\",\"missionXId\":\"" + 243 | yyyy['missionXId'] + "\"}", 244 | "resId": "223166", "callSource": "biz_code_main", "source": "mtop", 245 | "longitude": "105.75325090438128", "latitude": "30.597472842782736"} 246 | res = self.req(api1, data1, "1.0") 247 | res1 = res.json() 248 | if 'extend' in res1['data'] and 'value' in res1['data']['extend'] and res1['ret'][ 249 | 0] == 'SUCCESS::调用成功': 250 | print(f"[{self.name}] [{yyyy['showTitle']}]✅领取成功,获得{res1['data']['extend']['value']}个吃货豆") 251 | else: 252 | if 'msgInfo' in res1['data']: 253 | print(f"[{self.name}] [{yyyy['showTitle']}]❌领取失败,原因:{res1['data']['msgInfo']}") 254 | else: 255 | print(f'[{self.name}] [{yyyy["showTitle"]}]❌领取失败{res.text}') 256 | if 'pageStageTime' in yyyy: 257 | api2 = 'mtop.ele.biz.growth.task.event.pageview' 258 | data2 = {"collectionId": "36", "missionId": yyyy['distinctId'], "actionCode": "PAGEVIEW", 259 | "pageFrom": yyyy['pageSpm'], 260 | "viewTime": "15", "bizScene": "svip", "accountPlan": "HAVANA_COMMON", "sync": "true"} 261 | res2 = self.req(api2, data2, "1.1") 262 | if res2.json()['ret'][0] == 'SUCCESS::调用成功': 263 | print(f"[{self.name}] [{yyyy['showTitle']}]✅领取成功") 264 | else: 265 | print(f'[{self.name}] [{yyyy["showTitle"]}]❌领取失败,原因:{res2.json()["ret"][0]}') 266 | except Exception as e: 267 | print(f"[{self.name}] ❌领取失败: {e}") 268 | 269 | 270 | if __name__ == '__main__': 271 | if 'elmck' in os.environ: 272 | cookie = os.environ.get('elmck') 273 | else: 274 | print("环境变量中不存在[elmck],启用本地变量模式") 275 | cookie = ck 276 | if cookie == "": 277 | print("本地变量为空,请设置其中一个变量后再运行") 278 | exit(-1) 279 | cookies = cookie.split("&") 280 | print(f"饿了么共获取到 {len(cookies)} 个账号") 281 | for i, ck in enumerate(cookies): 282 | ck = reorder_ck(ck) 283 | print(f"======开始第{i + 1}个账号======") 284 | TYT(ck).main() 285 | print("2s后进行下一个账号") 286 | time.sleep(2) 287 | -------------------------------------------------------------------------------- /ele_check_ck新.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 变量:elmck: 必填,账号cookie,短信登录面板项目地址:https://github.com/funaihui/eleWeb 3 | * 定时随意,每天跑一遍就可以 4 | * cron: 7 17 * * * 5 | */ 6 | 7 | const { 8 | getEnvsByName, 9 | DisableCk, 10 | EnableCk, 11 | updateEnv, 12 | updateEnv11, 13 | getEnvByUserId 14 | } = require("./ql"); 15 | 16 | const { 17 | wait, 18 | checkCk, 19 | validateCarmeWithType, 20 | invalidCookieNotify, 21 | getUserInfo, 22 | runOne, 23 | getCookieMap 24 | } = require("./common.js"); 25 | 26 | const _0x11f78e = require("moment"); 27 | 28 | function _0x543ec4(_0x3fdeea, _0x4dabab) { 29 | return Math.floor(Math.random() * (_0x4dabab - _0x3fdeea + 1) + _0x3fdeea); 30 | } 31 | 32 | function _0x389941(_0x1daaab) { 33 | let _0x59299c = ""; 34 | 35 | for (let [_0x7cf76, _0x5050e8] of _0x1daaab) { 36 | _0x59299c += _0x7cf76 + "=" + _0x5050e8 + ";"; 37 | } 38 | 39 | return _0x59299c; 40 | } 41 | 42 | async function _0x179175(data, context, options) { 43 | let responseData = await runOne(context, options); 44 | 45 | if (responseData) { 46 | if (responseData.code === 3000) { 47 | let parsedData = JSON.parse(responseData.returnValue.data); 48 | const cookies = parsedData.cookies; 49 | let cookie2 = null; 50 | let unb = null; 51 | for (const cookie of cookies) { 52 | const cookie2Match = cookie.match(/cookie2=([^;]+)/); 53 | if (cookie2Match) { 54 | cookie2 = cookie2Match[1]; 55 | } 56 | const unbMatch = cookie.match(/unb=([^;]+)/); 57 | if (unbMatch) { 58 | unb = unbMatch[1]; 59 | } 60 | if (cookie2 && unb) { 61 | break; 62 | } 63 | } 64 | 65 | const expiryTimestamp = parsedData.expires; 66 | const expiryDate = _0x11f78e(expiryTimestamp * 1000).format("YYYY-MM-DD HH:mm:ss"); 67 | 68 | let cookieMap = getCookieMap(context); 69 | let extraMap = JSON.parse(responseData.returnValue.extMap.eleExt); 70 | 71 | for (let item of extraMap) { 72 | if (item.name === "SID") { 73 | break; 74 | } 75 | } 76 | 77 | let updatedContext = await runOne(context, cookieMap.get("SID")); 78 | 79 | if (!updatedContext) { 80 | return; 81 | } 82 | 83 | cookieMap.set('cookie2', cookie2); 84 | 85 | let updatedEnvironment = _0x389941(cookieMap); 86 | 87 | if (data.id) { 88 | await updateEnv11(updatedEnvironment, data.id, data.remarks); 89 | } else { 90 | await updateEnv(updatedEnvironment, data._id, data.remarks); 91 | } 92 | 93 | let userID = cookieMap.get("USERID"); 94 | let userEnvironment = await getEnvByUserId(userID); 95 | 96 | 97 | 98 | let successMessage = "刷新成功: " + expiryDate; 99 | 100 | console.log(successMessage); 101 | return successMessage; 102 | } else { 103 | if (responseData.message) { 104 | console.log(responseData.message); 105 | } else { 106 | console.log(response.ret[0]); 107 | } 108 | 109 | return null; 110 | } 111 | } 112 | } 113 | 114 | 115 | 116 | (async function _0x1f3fe2() { 117 | const aleo = process.env.ELE_CARME; 118 | await validateCarmeWithType(aleo, 1); 119 | const pragati = await getEnvsByName("elmck"); 120 | for (let mackala = 0; mackala < pragati.length; mackala++) { 121 | let athel = pragati[mackala].value; 122 | if (!athel) { 123 | console.log(" ❌无效用户信息, 请重新获取ck"); 124 | } else { 125 | try { 126 | var houda = 0; 127 | if (pragati[mackala]._id) { 128 | houda = pragati[mackala]._id; 129 | } 130 | if (pragati[mackala].id) { 131 | houda = pragati[mackala].id; 132 | } 133 | athel = athel.replace(/\s/g, ""); 134 | let lavante = await checkCk(athel, mackala); 135 | if (!lavante) { 136 | let deshaune = await _0x179175(pragati[mackala], athel); 137 | if (deshaune && deshaune.indexOf("刷新成功") !== -1) { 138 | await EnableCk(houda); 139 | console.log("第", mackala + 1, "账号正常😁\n"); 140 | } else { 141 | const lakeyah = await DisableCk(houda); 142 | if (lakeyah.code === 200) { 143 | console.log("第", mackala + 1, "账号失效!已🈲用"); 144 | } else { 145 | console.log("第", mackala + 1, "账号失效!请重新登录!!!😭"); 146 | } 147 | await invalidCookieNotify(athel, pragati[mackala].remarks); 148 | } 149 | } else { 150 | let amirr = await getUserInfo(athel); 151 | if (!amirr.encryptMobile) { 152 | let rudolphe = await _0x179175(pragati[mackala], athel); 153 | if (rudolphe && rudolphe.indexOf("刷新成功") !== -1) { 154 | await EnableCk(houda); 155 | console.log("第", mackala + 1, "账号正常😁\n"); 156 | } else { 157 | const jericca = await DisableCk(houda); 158 | if (jericca.code === 200) { 159 | console.log("第", mackala + 1, "账号失效!已🈲用"); 160 | } else { 161 | console.log("第", mackala + 1, "账号失效!请重新登录!!!😭"); 162 | } 163 | } 164 | await invalidCookieNotify(athel, pragati[mackala].remarks); 165 | } else { 166 | await _0x179175(pragati[mackala], athel, getCookieMap(athel).get("SID")); 167 | await EnableCk(houda); 168 | console.log("第", mackala + 1, "账号正常🎉🎉\n"); 169 | } 170 | } 171 | } catch (hannelore) { 172 | console.log(hannelore); 173 | } 174 | } 175 | await wait(_0x543ec4(1, 3)); 176 | } 177 | process.exit(0); 178 | }()); 179 | 180 | -------------------------------------------------------------------------------- /ele_femf.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 变量:elmck: 必填,账号cookie,短信登录面板项目地址:https://github.com/funaihui/eleWeb 3 | * 定时随意,每天跑一遍就可以 4 | * cron: 7 17 * * * 5 | */ 6 | const $ = new Env('饿了么福尔魔方'); 7 | const qs = require("qs"); 8 | const request = require("request"); 9 | 10 | const { 11 | sign: getSign, 12 | getCookies, 13 | getToken, 14 | getUserInfo, 15 | "checkCk": checkCk, 16 | wait, 17 | } = require("./common.js"); 18 | 19 | function updateCookie(tkCookie, encCookie, cookieStr) { 20 | let txt = cookieStr.replace(/\s/g, ''); 21 | txt = txt.replace(/chushi;/g, ''); 22 | if (!txt.endsWith(';')) { 23 | txt += ';'; 24 | } 25 | 26 | let cookieParts = txt.split(';').slice(0, -1); 27 | let updated = false; 28 | 29 | for (let i = 0; i < cookieParts.length; i++) { 30 | let keyValuePair = cookieParts[i].split('='); 31 | let key = keyValuePair[0].trim(); 32 | if (key === "_m_h5_tk" || key === " _m_h5_tk") { 33 | cookieParts[i] = tkCookie; 34 | updated = true; 35 | } else if (key === "_m_h5_tk_enc" || key === " _m_h5_tk_enc") { 36 | cookieParts[i] = encCookie; 37 | updated = true; 38 | } 39 | } 40 | 41 | if (updated) { 42 | return cookieParts.join(';') + ';'; 43 | } else { 44 | return txt + tkCookie + ';' + encCookie + ';'; 45 | } 46 | } 47 | 48 | async function playChefGame(cookie) { 49 | const t = Date.now(); 50 | const body = JSON.stringify({ 51 | "bizScene": "MAGIC_CUBE", 52 | "latitude": "0", 53 | "longitude": "0", 54 | "bizCode": "MAGIC_CUBE", 55 | "actId": "20230802212526123181213864", 56 | "collectionId": "20230802212526148986536967", 57 | "componentId": "20230803112141370370827352", 58 | "extParams": "{\"actId\":\"20230802212526123181213864\",\"bizType\":\"MAGIC_CUBE\",\"desc\":\"魔方消消乐\"}", 59 | "requestId": "20230802212526123181213864"+t, 60 | "asac": "2A22C0239QW1FOL3UUQY7U" 61 | }) 62 | const api = 'mtop.koubei.interactioncenter.platform.right.lottery' 63 | const { data } = await h5Request(body, "12574478", "shopping.ele.me", api, cookie) 64 | 65 | if (Object.keys(data.data).length === 0) { 66 | return false 67 | } else if (data.data.sendStatus === "SUCCESS") { 68 | const amount = data.data.sendRightList[0].discountInfo.amount; 69 | if (amount === 1) { 70 | console.log("福尔魔方闯关成功。获得:" + amount + " 乐园币"); 71 | return false 72 | } else { 73 | console.log("福尔魔方闯关成功。获得:" + amount + " 乐园币"); 74 | return true 75 | } 76 | } else { 77 | console.log(data.data.errorMsg) 78 | return false 79 | } 80 | } 81 | 82 | // 161274962374%40eleme_android_11.12.88" 83 | async function h5Request(dataObj, appkey, host, api, cookie, extraHeader = {}, ttid = '161274962374%40eleme_android_11.12.88') { 84 | const t = new Date().getTime(); 85 | const tk = getToken(cookie) 86 | const stk = tk.split("_")[0]; 87 | const sign = await getSign(`${stk}&${t}&${appkey}&${dataObj}`) 88 | const parm = "jsv=2.6.1&appKey=" + appkey + "&t=" + t + "&sign=" + sign + "&api=" + api + "&v=1.0&ecode=1&type=json&valueType=string&needLogin=true&LoginRequest=true&dataType=jsonp&ttid=" + ttid; 89 | const header = { 90 | 'content-type': 'application/x-www-form-urlencoded', 91 | 'Connection': 'keep-alive', 92 | 'Cookie': cookie + ';', 93 | 'user-agent': 'Mozilla/5.0 (WindOws NT 10.0; WOW64) AppLeWebKit/537.36 (KHTML, like Gecko) chrome/86.0.4240.198 Safari/537.36', 94 | 'accept': 'application/json', 95 | "Origin": "https://tb.ele.me", 96 | 'referer': "https://servicewechat.com/wxece3a9a4c82f58c9/626/page-frame.html", 97 | 'accept-language': 'zh-CN,zh;q=0.9', 98 | } 99 | Object.assign(header, extraHeader) 100 | const options = { 101 | url: "https://" + host + "/h5/" + api + "/1.0/?" + parm, 102 | method: "POST", 103 | headers: header, 104 | body: "data="+dataObj 105 | } 106 | 107 | return new Promise(callback => { 108 | request(options, async (error, response, body) => { 109 | if (!error && response.statusCode === 200) { 110 | const responseBody = JSON.parse(body); 111 | if (responseBody.ret[0].includes('令牌')) { 112 | const setCookieHeader = JSON.stringify(response.headers["set-cookie"]); 113 | const newToken = /_m_h5_tk=(\S*);/.exec(setCookieHeader)[1]; 114 | const newTokenEnc = /_m_h5_tk_enc=(\S*);/.exec(setCookieHeader)[1]; 115 | cookie = updateCookie(` _m_h5_tk=${newToken.split(";")[0]}`, ` _m_h5_tk_enc=${newTokenEnc.split(";")[0]}`, cookie); 116 | callback(await h5Request(dataObj, appkey, host, api, cookie)) 117 | // await playChefGame(cookie) 118 | } else { 119 | callback(responseBody); 120 | } 121 | } else { 122 | console.log(error || body); 123 | callback(); 124 | } 125 | }); 126 | }) 127 | } 128 | 129 | 130 | async function start() { 131 | const _0x2f100c = getCookies(); 132 | for (let _0x28bb82 = 0; _0x28bb82 < _0x2f100c["length"]; _0x28bb82++) { 133 | const _0x10e68c = _0x2f100c[_0x28bb82]; 134 | if (!_0x10e68c) { 135 | console["log"](" ❌无效用户信息, 请重新获取ck"); 136 | } else { 137 | try { 138 | let _0x3b7f88 = await checkCk(_0x10e68c, _0x28bb82); 139 | if (!_0x3b7f88) { 140 | continue; 141 | } 142 | let _0x2d55f7 = await getUserInfo(_0x3b7f88); 143 | if (!_0x2d55f7.encryptMobile) { 144 | console["log"]('第', _0x28bb82 + 1, "账号失效!请重新登录!!!😭"); 145 | continue; 146 | } 147 | const _0x5cb41f = _0x2d55f7["localId"]; 148 | console["log"]("******开始【饿了么账号", _0x28bb82 + 1, '】', _0x2d55f7.encryptMobile, "*********"); 149 | await playChefGame(_0x3b7f88); 150 | console["log"]("防止黑号延时5-10秒"); 151 | await wait(getRandom(5, 10)); 152 | } catch (_0x2a2515) { 153 | console["log"](_0x2a2515); 154 | } 155 | } 156 | } 157 | process["exit"](0); 158 | } 159 | start(); 160 | 161 | function getRandom(_0x452fcd, _0x5adc25) { 162 | return Math["floor"](Math["random"]() * (_0x5adc25 - _0x452fcd + 1) + _0x452fcd); 163 | } 164 | // prettier-ignore 165 | function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } 166 | -------------------------------------------------------------------------------- /ele_helper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 变量:elmck: 必填,账号cookie,短信登录面板项目地址:https://github.com/funaihui/eleWeb 3 | * 定时随意,每天跑一遍就可以 4 | * cron: 7 17 * * * 5 | */ 6 | const { 7 | sign, 8 | getToken, 9 | wait, 10 | checkCk, 11 | validateCarmeWithType, 12 | User_Agent, 13 | getCookies, 14 | checkCarmeCount, 15 | getUserInfo, 16 | tryCatchPromise 17 | } = require("./common.js"); 18 | 19 | const request = require("request"); 20 | 21 | const GAME_TYEP = 2; 22 | let CookieEles = getCookies(); 23 | const kami = process.env.ELE_CARME; 24 | 25 | async function fridensHelper(_0x44fa34, _0x3ca75c) { 26 | _0x44fa34 = await checkCk(_0x44fa34); 27 | const _0x51fd6d = { 28 | "content-type": "application/x-www-form-urlencoded;charset=UTF-8", 29 | Cookie: _0x44fa34, 30 | "User-Agent": User_Agent 31 | }; 32 | 33 | const _0x9900e7 = new Date().getTime(); 34 | 35 | const _0x4ae8f4 = 12574478; 36 | const _0x5f17d6 = { 37 | sceneCode: "RECOMMEND_SUPPORT", 38 | params: "{\"ownerId\":\"" + _0x3ca75c + "\",\"fromOfficialAccount\":false,\"channel\":\"1\",\"referUserId\":\"\",\"restaurantId\":\"\",\"referCode\":\"\",\"referChannelCode\":\"\",\"referChannelType\":\"\",\"fromWeChatApp\":false,\"bizType\":\"1\",\"v\":\"4.3\",\"chInfo\":\"ch_app_chsub_Photo\",\"from\":\"hjb_app_xbb\",\"actId\":\"1\",\"longitude\":\"120.22057268768549\",\"latitude\":\"30.17862595617771\"}" 39 | }; 40 | 41 | var _0x5ea933 = "data=" + encodeURIComponent(JSON.stringify(_0x5f17d6)); 42 | 43 | const _0x3f65ea = getToken(_0x44fa34), 44 | _0x59ecd8 = _0x3f65ea.split("_")[0]; 45 | 46 | const _0x3e43d = await sign(_0x59ecd8 + "&" + _0x9900e7 + "&" + _0x4ae8f4 + "&" + JSON.stringify(_0x5f17d6), kami); 47 | 48 | const _0x5f2fe9 = { 49 | url: "https://mtop.ele.me/h5/mtop.alibaba.o2o.alsc.union.coupon.track/1.0/?jsv=2.6.1&appKey=12574478&&ttid=1601274958480%40eleme_android_10.14.3&t=" + _0x9900e7 + "&sign=" + _0x3e43d + "&api=mtop.alibaba.o2o.alsc.union.coupon.track", 50 | method: "POST", 51 | headers: _0x51fd6d, 52 | body: _0x5ea933 53 | }; 54 | return tryCatchPromise(_0x3646fc => { 55 | request(_0x5f2fe9, async (_0x540129, _0x40bcb1, _0x52637b) => { 56 | if (!_0x540129 && _0x40bcb1.statusCode == 200) { 57 | try { 58 | const _0x6c9838 = JSON.parse(_0x52637b); 59 | 60 | _0x3646fc(_0x6c9838); 61 | } catch (_0x53998e) { 62 | console.log(_0x53998e); 63 | 64 | _0x3646fc(null); 65 | } 66 | } else { 67 | _0x3646fc(null); 68 | } 69 | }); 70 | }); 71 | } 72 | 73 | function getRandom(_0xf39232, _0x3b47cc) { 74 | var _0x378d8b = Math.floor(Math.random() * (_0x3b47cc - _0xf39232 + 1) + _0xf39232); 75 | 76 | return _0x378d8b; 77 | } 78 | 79 | async function start() { 80 | const _0x5828a4 = process.env.ELE_FANLI_TIME; 81 | await validateCarmeWithType(kami, 1); 82 | const _0x37acb9 = process.env.ownerId; 83 | 84 | if (!_0x37acb9) { 85 | console.log("请先配置环境变量ownerId!!"); 86 | process.exit(0); 87 | } 88 | 89 | for (let _0x1208f8 = 0; _0x1208f8 < CookieEles.length; _0x1208f8++) { 90 | let _0x164c60 = CookieEles[_0x1208f8]; 91 | _0x164c60 = await checkCk(_0x164c60, _0x1208f8); 92 | 93 | if (!_0x164c60) { 94 | continue; 95 | } 96 | 97 | let _0x43401a = await getUserInfo(_0x164c60); 98 | 99 | if (!_0x43401a.encryptMobile) { 100 | console.log("第", _0x1208f8 + 1, "账号失效!请重新登录!!!😭"); 101 | continue; 102 | } 103 | 104 | const _0x52ce8f = _0x43401a.localId; 105 | await checkCarmeCount(kami, _0x52ce8f, GAME_TYEP); 106 | console.log("******开始【饿了么账号", _0x1208f8 + 1, "】", _0x43401a.encryptMobile, "*********"); 107 | res = await fridensHelper(_0x164c60, _0x37acb9); 108 | 109 | if (res.data.code == 0) { 110 | if (res.data.message == "SUCCESS") { 111 | amount = res.data.data.couponAmount / 100; 112 | couponCondition = res.data.data.couponCondition / 100; 113 | console.log("第", _0x1208f8 + 1, "账号,邀请成功", "被邀请人领取的红包为:满" + couponCondition + "减" + amount + "元"); 114 | } 115 | } else { 116 | console.log(res.data.message || "邀请失败"); 117 | } 118 | 119 | if (_0x5828a4 && _0x5828a4.indexOf("-") != -1) { 120 | console.log("防止黑号延时" + _0x5828a4 + "秒"); 121 | 122 | const _0x2c394a = _0x5828a4.split("-"); 123 | 124 | await wait(getRandom(_0x2c394a[0], _0x2c394a[1])); 125 | } else { 126 | console.log("防止黑号延时10-30秒"); 127 | await wait(getRandom(10, 30)); 128 | } 129 | } 130 | 131 | process.exit(0); 132 | } 133 | 134 | start(); 135 | 136 | function Env(t, e) { 137 | "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); 138 | 139 | class s { 140 | constructor(t) { 141 | this.env = t; 142 | } 143 | 144 | send(t, e = "GET") { 145 | t = "string" == typeof t ? { 146 | url: t 147 | } : t; 148 | let s = this.get; 149 | "POST" === e && (s = this.post); 150 | return new Promise((e, i) => { 151 | s.call(this, t, (t, s, r) => { 152 | t ? i(t) : e(s); 153 | }); 154 | }); 155 | } 156 | 157 | get(t) { 158 | return this.send.call(this.env, t); 159 | } 160 | 161 | post(t) { 162 | return this.send.call(this.env, t, "POST"); 163 | } 164 | 165 | } 166 | 167 | return new class { 168 | constructor(t, e) { 169 | this.name = t; 170 | this.http = new s(this); 171 | this.data = null; 172 | this.dataFile = "box.dat"; 173 | this.logs = []; 174 | this.isMute = !1; 175 | this.isNeedRewrite = !1; 176 | this.logSeparator = "\n"; 177 | this.startTime = new Date().getTime(); 178 | Object.assign(this, e); 179 | this.log("", `🔔${this.name}, 开始!`); 180 | } 181 | 182 | isNode() { 183 | return "undefined" != typeof module && !!module.exports; 184 | } 185 | 186 | isQuanX() { 187 | return "undefined" != typeof $task; 188 | } 189 | 190 | isSurge() { 191 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon; 192 | } 193 | 194 | isLoon() { 195 | return "undefined" != typeof $loon; 196 | } 197 | 198 | toObj(t, e = null) { 199 | try { 200 | return JSON.parse(t); 201 | } catch { 202 | return e; 203 | } 204 | } 205 | 206 | toStr(t, e = null) { 207 | try { 208 | return JSON.stringify(t); 209 | } catch { 210 | return e; 211 | } 212 | } 213 | 214 | getjson(t, e) { 215 | let s = e; 216 | const i = this.getdata(t); 217 | 218 | if (i) { 219 | try { 220 | s = JSON.parse(this.getdata(t)); 221 | } catch {} 222 | } 223 | 224 | return s; 225 | } 226 | 227 | setjson(t, e) { 228 | try { 229 | return this.setdata(JSON.stringify(t), e); 230 | } catch { 231 | return !1; 232 | } 233 | } 234 | 235 | getScript(t) { 236 | return new Promise(e => { 237 | this.get({ 238 | url: t 239 | }, (t, s, i) => e(i)); 240 | }); 241 | } 242 | 243 | runScript(t, e) { 244 | return new Promise(s => { 245 | let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); 246 | i = i ? i.replace(/\n/g, "").trim() : i; 247 | let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); 248 | r = r ? 1 * r : 20; 249 | r = e && e.timeout ? e.timeout : r; 250 | const [o, h] = i.split("@"), 251 | n = { 252 | url: `http://${h}/v1/scripting/evaluate`, 253 | body: { 254 | script_text: t, 255 | mock_type: "cron", 256 | timeout: r 257 | }, 258 | headers: { 259 | "X-Key": o, 260 | Accept: "*/*" 261 | } 262 | }; 263 | this.post(n, (t, e, i) => s(i)); 264 | }).catch(t => this.logErr(t)); 265 | } 266 | 267 | loaddata() { 268 | if (!this.isNode()) { 269 | return {}; 270 | } 271 | 272 | { 273 | this.fs = this.fs ? this.fs : require("fs"); 274 | this.path = this.path ? this.path : require("path"); 275 | const t = this.path.resolve(this.dataFile), 276 | e = this.path.resolve(process.cwd(), this.dataFile), 277 | s = this.fs.existsSync(t), 278 | i = !s && this.fs.existsSync(e); 279 | 280 | if (!s && !i) { 281 | return {}; 282 | } 283 | 284 | { 285 | const i = s ? t : e; 286 | 287 | try { 288 | return JSON.parse(this.fs.readFileSync(i)); 289 | } catch (t) { 290 | return {}; 291 | } 292 | } 293 | } 294 | } 295 | 296 | writedata() { 297 | if (this.isNode()) { 298 | this.fs = this.fs ? this.fs : require("fs"); 299 | this.path = this.path ? this.path : require("path"); 300 | const t = this.path.resolve(this.dataFile), 301 | e = this.path.resolve(process.cwd(), this.dataFile), 302 | s = this.fs.existsSync(t), 303 | i = !s && this.fs.existsSync(e), 304 | r = JSON.stringify(this.data); 305 | s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r); 306 | } 307 | } 308 | 309 | lodash_get(t, e, s) { 310 | const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); 311 | let r = t; 312 | 313 | for (const t of i) if (r = Object(r)[t], void 0 === r) { 314 | return s; 315 | } 316 | 317 | return r; 318 | } 319 | 320 | lodash_set(t, e, s) { 321 | return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t); 322 | } 323 | 324 | getdata(t) { 325 | let e = this.getval(t); 326 | 327 | if (/^@/.test(t)) { 328 | const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), 329 | r = s ? this.getval(s) : ""; 330 | 331 | if (r) { 332 | try { 333 | const t = JSON.parse(r); 334 | e = t ? this.lodash_get(t, i, "") : e; 335 | } catch (t) { 336 | e = ""; 337 | } 338 | } 339 | } 340 | 341 | return e; 342 | } 343 | 344 | setdata(t, e) { 345 | let s = !1; 346 | 347 | if (/^@/.test(e)) { 348 | const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), 349 | o = this.getval(i), 350 | h = i ? "null" === o ? null : o || "{}" : "{}"; 351 | 352 | try { 353 | const e = JSON.parse(h); 354 | this.lodash_set(e, r, t); 355 | s = this.setval(JSON.stringify(e), i); 356 | } catch (e) { 357 | const o = {}; 358 | this.lodash_set(o, r, t); 359 | s = this.setval(JSON.stringify(o), i); 360 | } 361 | } else { 362 | s = this.setval(t, e); 363 | } 364 | 365 | return s; 366 | } 367 | 368 | getval(t) { 369 | return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null; 370 | } 371 | 372 | setval(t, e) { 373 | return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null; 374 | } 375 | 376 | initGotEnv(t) { 377 | this.got = this.got ? this.got : require("got"); 378 | this.cktough = this.cktough ? this.cktough : require("tough-cookie"); 379 | this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar(); 380 | t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)); 381 | } 382 | 383 | get(t, e = () => {}) { 384 | t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]); 385 | this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { 386 | "X-Surge-Skip-Scripting": !1 387 | })), $httpClient.get(t, (t, s, i) => { 388 | !t && s && (s.body = i, s.statusCode = s.status); 389 | e(t, s, i); 390 | })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { 391 | hints: !1 392 | })), $task.fetch(t).then(t => { 393 | const { 394 | statusCode: s, 395 | statusCode: i, 396 | headers: r, 397 | body: o 398 | } = t; 399 | e(null, { 400 | status: s, 401 | statusCode: i, 402 | headers: r, 403 | body: o 404 | }, o); 405 | }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { 406 | try { 407 | if (t.headers["set-cookie"]) { 408 | const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); 409 | s && this.ckjar.setCookieSync(s, null); 410 | e.cookieJar = this.ckjar; 411 | } 412 | } catch (t) { 413 | this.logErr(t); 414 | } 415 | }).then(t => { 416 | const { 417 | statusCode: s, 418 | statusCode: i, 419 | headers: r, 420 | body: o 421 | } = t; 422 | e(null, { 423 | status: s, 424 | statusCode: i, 425 | headers: r, 426 | body: o 427 | }, o); 428 | }, t => { 429 | const { 430 | message: s, 431 | response: i 432 | } = t; 433 | e(s, i, i && i.body); 434 | })); 435 | } 436 | 437 | post(t, e = () => {}) { 438 | if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) { 439 | this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { 440 | "X-Surge-Skip-Scripting": !1 441 | })); 442 | $httpClient.post(t, (t, s, i) => { 443 | !t && s && (s.body = i, s.statusCode = s.status); 444 | e(t, s, i); 445 | }); 446 | } else { 447 | if (this.isQuanX()) { 448 | t.method = "POST"; 449 | this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { 450 | hints: !1 451 | })); 452 | $task.fetch(t).then(t => { 453 | const { 454 | statusCode: s, 455 | statusCode: i, 456 | headers: r, 457 | body: o 458 | } = t; 459 | e(null, { 460 | status: s, 461 | statusCode: i, 462 | headers: r, 463 | body: o 464 | }, o); 465 | }, t => e(t)); 466 | } else { 467 | if (this.isNode()) { 468 | this.initGotEnv(t); 469 | const { 470 | url: s, 471 | ...i 472 | } = t; 473 | this.got.post(s, i).then(t => { 474 | const { 475 | statusCode: s, 476 | statusCode: i, 477 | headers: r, 478 | body: o 479 | } = t; 480 | e(null, { 481 | status: s, 482 | statusCode: i, 483 | headers: r, 484 | body: o 485 | }, o); 486 | }, t => { 487 | const { 488 | message: s, 489 | response: i 490 | } = t; 491 | e(s, i, i && i.body); 492 | }); 493 | } 494 | } 495 | } 496 | } 497 | 498 | time(t, e = null) { 499 | const s = e ? new Date(e) : new Date(); 500 | let i = { 501 | "M+": s.getMonth() + 1, 502 | "d+": s.getDate(), 503 | "H+": s.getHours(), 504 | "m+": s.getMinutes(), 505 | "s+": s.getSeconds(), 506 | "q+": Math.floor((s.getMonth() + 3) / 3), 507 | S: s.getMilliseconds() 508 | }; 509 | /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); 510 | 511 | for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); 512 | 513 | return t; 514 | } 515 | 516 | msg(e = t, s = "", i = "", r) { 517 | const o = t => { 518 | if (!t) { 519 | return t; 520 | } 521 | 522 | if ("string" == typeof t) { 523 | return this.isLoon() ? t : this.isQuanX() ? { 524 | "open-url": t 525 | } : this.isSurge() ? { 526 | url: t 527 | } : void 0; 528 | } 529 | 530 | if ("object" == typeof t) { 531 | if (this.isLoon()) { 532 | let e = t.openUrl || t.url || t["open-url"], 533 | s = t.mediaUrl || t["media-url"]; 534 | return { 535 | openUrl: e, 536 | mediaUrl: s 537 | }; 538 | } 539 | 540 | if (this.isQuanX()) { 541 | let e = t["open-url"] || t.url || t.openUrl, 542 | s = t["media-url"] || t.mediaUrl; 543 | return { 544 | "open-url": e, 545 | "media-url": s 546 | }; 547 | } 548 | 549 | if (this.isSurge()) { 550 | let e = t.url || t.openUrl || t["open-url"]; 551 | return { 552 | url: e 553 | }; 554 | } 555 | } 556 | }; 557 | 558 | if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { 559 | let t = ["", "==============📣系统通知📣=============="]; 560 | t.push(e); 561 | s && t.push(s); 562 | i && t.push(i); 563 | console.log(t.join("\n")); 564 | this.logs = this.logs.concat(t); 565 | } 566 | } 567 | 568 | log(...t) { 569 | t.length > 0 && (this.logs = [...this.logs, ...t]); 570 | console.log(t.join(this.logSeparator)); 571 | } 572 | 573 | logErr(t, e) { 574 | const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); 575 | s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t); 576 | } 577 | 578 | wait(t) { 579 | return new Promise(e => setTimeout(e, t)); 580 | } 581 | 582 | done(t = {}) { 583 | const e = new Date().getTime(), 584 | s = (e - this.startTime) / 1000; 585 | this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`); 586 | this.log(); 587 | (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t); 588 | } 589 | 590 | }(t, e); 591 | } 592 | -------------------------------------------------------------------------------- /ele_llk.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 变量:elmck: 必填,账号cookie, 3 | * 定时随意,每天跑一遍就可以 4 | * cron: 7 17 * * * 5 | */ 6 | 7 | 8 | const https = require('https'); 9 | https.globalAgent.options.rejectUnauthorized = false; 10 | const $ = new Env('饿了么连连看'); 11 | const { 12 | getCookies, 13 | sign, 14 | wait, 15 | getToken, 16 | checkCk, 17 | getUserInfo 18 | } = require("./common.js"); 19 | const request = require("request"); 20 | 21 | async function getGameToken(cookie) { 22 | let requestData = { 23 | "bizScene": "LIANLIANKAN", 24 | "bizMethod": "login", 25 | "bizParam": JSON.stringify({ 26 | "inviterId": null, 27 | "gameId": null, 28 | "token": "token" 29 | }), 30 | "longitude": 114.174328, 31 | "latitude": 22.316555 32 | }; 33 | const response = await gameRequest(cookie, requestData); 34 | let resData = JSON.parse(response.data); 35 | return { token: resData.data.token, openId: resData.data.openId }; 36 | } 37 | 38 | async function getGameCode(cookie, token) { 39 | const requestData = { 40 | "bizScene": "LIANLIANKAN", 41 | "bizMethod": "startGameV2", 42 | "bizParam": JSON.stringify({ 43 | "gameId": null, 44 | "token": token 45 | }), 46 | "longitude": 114.174328, 47 | "latitude": 22.316555 48 | }; 49 | const response = await gameRequest(cookie, requestData); 50 | let resData = JSON.parse(response.data); 51 | if (resData.bizErrorMsg !== "success") { 52 | console.log(resData.bizErrorMsg == 'The game level complete today' ? '今日已通关,明天再来!' : resData.bizErrorMsg); 53 | return null; 54 | } 55 | return { 56 | gameCode: resData.data.gameCode, 57 | levelId: resData.data.levelId, 58 | serverTime: resData.serverTime, 59 | }; 60 | } 61 | 62 | async function passGame(cookie, gameCode, token, openId, gameTimes = 0) { 63 | try { 64 | let signStr = await sign(`Game[${openId}]-${token}|${gameCode}${gameTimes}`); 65 | const requestData = { 66 | "bizScene": "LIANLIANKAN", 67 | "bizMethod": "settlement", 68 | "bizParam": JSON.stringify({ 69 | "gameCode": gameCode, 70 | "passLevelTime": gameTimes, 71 | "gameId": null, 72 | "sign": signStr, 73 | "token": token 74 | }), 75 | "longitude": 114.174328, 76 | "latitude": 22.316555 77 | }; 78 | 79 | const response = await gameRequest(cookie, requestData); 80 | let resData = JSON.parse(response.data); 81 | 82 | if (resData.bizErrorMsg !== "success") { 83 | console.log(resData.bizErrorMsg); 84 | return null; 85 | } 86 | return resData.data; 87 | } catch (error) { 88 | console.error("结算游戏过程中发生错误:", error); 89 | return null; 90 | } 91 | } 92 | 93 | async function playGame(cookie, token, openId, gameTimes = 0) { 94 | try { 95 | let timestamp = new Date().getTime(); 96 | const codeData = await getGameCode(cookie, token); 97 | if (!!codeData) { 98 | console.log('当前关卡', codeData.levelId); 99 | if (codeData.levelId == 2) { 100 | gameTimes = 36; 101 | } else { 102 | gameTimes = 8; 103 | } 104 | console.log('随机玩游戏' + gameTimes + ' s'); 105 | await wait(gameTimes); 106 | timestamp = new Date().getTime(); 107 | gameTimes = timestamp - codeData.serverTime; 108 | const passGameData = await passGame(cookie, codeData.gameCode, token, openId, gameTimes); 109 | if (!!passGameData) { 110 | console.log('连连看第' + passGameData.lastLevelId + '关闯关成功'); 111 | if (!!passGameData.lastLevelId && passGameData.lastLevelId !== 3) { 112 | console.log('防黑,延迟 1-3 s'); 113 | await wait(getRandomInt(1, 3)); 114 | 115 | await playGame(cookie, token, openId, gameTimes); 116 | } else { 117 | console.log('任务结束'); 118 | } 119 | } else { 120 | console.log('游戏时间出错!'); 121 | } 122 | } else { 123 | console.log('没有游戏次数了!'); 124 | } 125 | } catch (error) { 126 | console.error("游戏过程中发生错误:", error); 127 | } 128 | } 129 | 130 | async function gameRequest(cookie, requestData = {}) { 131 | const headers = { 132 | "authority": "shopping.ele.me", 133 | "accept": "application/json", 134 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 135 | "cache-control": "no-cache", 136 | "content-type": "application/x-www-form-urlencoded", 137 | "origin": "https://r.ele.me", 138 | "pragma": "no-cache", 139 | "referer": "https://r.ele.me/linkgame/index.html?navType=3&spm-pre=a2ogi.13162730.zebra-ele-login-module-9089118186&spm=a13.b_activity_kb_m71293.0.0", 140 | "cookie": cookie, 141 | "x-ele-ua": "RenderWay/H5 AppName/wap Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36", 142 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 143 | }; 144 | 145 | const timestamp = new Date().getTime(); 146 | const appKey = 12574478; 147 | const token = getToken(cookie).split("_")[0]; 148 | 149 | const signStr = await sign(`${token}&${timestamp}&${appKey}&${JSON.stringify(requestData)}`); 150 | const options = { 151 | url: "https://shopping.ele.me/h5/mtop.alsc.playgame.mini.game.dispatch/1.0/?jsv=2.6.1&appKey=12574478&t=" + timestamp + "&sign=" + signStr + "&api=mtop.alsc.playgame.mini.game.dispatch&v=1.0&type=originaljson&dataType=json&timeout=5000&subDomain=shopping&mainDomain=ele.me&H5Request=true&pageDomain=ele.me&ttid=h5%40chrome_android_87.0.4280.141&SV=5.0", 152 | method: "POST", 153 | headers: headers, 154 | body: "data=" + encodeURIComponent(JSON.stringify(requestData)) 155 | }; 156 | 157 | return new Promise(resolve => { 158 | request(options, async (error, response, body) => { 159 | if (!error && response.statusCode === 200) { 160 | try { 161 | const result = JSON.parse(body); 162 | const data = result.data; 163 | resolve(data); 164 | } catch (err) { 165 | console.log("解析 JSON 失败:", body); 166 | resolve(null); 167 | } 168 | } else { 169 | console.log("请求失败:", error, response && response.statusCode); 170 | resolve(null); 171 | } 172 | }); 173 | }); 174 | } 175 | 176 | async function main() { 177 | let cookies = []; 178 | if (process.env.elmck) { 179 | cookies = getCookies(); 180 | } else { 181 | cookies = cookies.concat(['']); 182 | if (cookies.length < 1) { 183 | console.log("检测到环境变量、本地ck都为空"); 184 | return; 185 | } 186 | } 187 | 188 | for (let i = 0; i < cookies.length; i++) { 189 | const cookie = cookies[i]; 190 | try { 191 | let validCookie = await checkCk(cookie, i); 192 | if (!validCookie) { 193 | continue; 194 | } 195 | let userInfo = await getUserInfo(validCookie); 196 | if (!userInfo.userName) { 197 | console.log("第", i + 1, "账号失效!请重新登录!!!😭"); 198 | continue; 199 | } 200 | console.log("\n****** #", i + 1, userInfo.userName, " *********"); 201 | console.log("账号的 id 为", userInfo.localId); 202 | 203 | const { token, openId } = await getGameToken(validCookie); 204 | await playGame(validCookie, token, openId); 205 | 206 | console.log("防止黑号延时1-3秒"); 207 | await wait(getRandomInt(1, 3)); 208 | } catch (error) { 209 | console.error("发生错误,继续执行下一个账号:", error); 210 | } 211 | } 212 | 213 | process.exit(0); 214 | } 215 | 216 | main(); 217 | 218 | function getRandomInt(min, max) { 219 | return Math.floor(Math.random() * (max - min + 1) + min); 220 | } 221 | 222 | 223 | 224 | 225 | 226 | // prettier-ignore 227 | function Env (t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send (t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get (t) { return this.send.call(this.env, t) } post (t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode () { return "undefined" != typeof module && !!module.exports } isQuanX () { return "undefined" != typeof $task } isSurge () { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon () { return "undefined" != typeof $loon } toObj (t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr (t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson (t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson (t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript (t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript (t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata () { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata () { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get (t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set (t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata (t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata (t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval (t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval (t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv (t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get (t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post (t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time (t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg (e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log (...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr (t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait (t) { return new Promise(e => setTimeout(e, t)) } done (t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } 228 | 229 | -------------------------------------------------------------------------------- /ele_tjcs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 变量:elmck: 必填,账号cookie 3 | */ 4 | 5 | const $ = new Env('饿了么特级厨师'); 6 | const qs = require("qs"); 7 | const request = require("request"); 8 | 9 | const { 10 | sign:getSign, 11 | getCookies, 12 | getToken, 13 | "checkCk": checkCk, 14 | getUserInfo, 15 | wait, 16 | } = require("./common.js"); 17 | 18 | function updateCookie(tkCookie, encCookie, cookieStr) { 19 | // 合并带_m_h5_tk 20 | let txt = cookieStr.replace(/\s/g, ''); 21 | txt = txt.replace(/chushi;/g, ''); 22 | if (!txt.endsWith(';')) { 23 | txt += ';'; 24 | } 25 | 26 | let cookieParts = txt.split(';').slice(0, -1); 27 | let updated = false; 28 | 29 | for (let i = 0; i < cookieParts.length; i++) { 30 | let keyValuePair = cookieParts[i].split('='); 31 | let key = keyValuePair[0].trim(); 32 | if (key === "_m_h5_tk" || key === " _m_h5_tk") { 33 | cookieParts[i] = tkCookie; 34 | updated = true; 35 | } else if (key === "_m_h5_tk_enc" || key === " _m_h5_tk_enc") { 36 | cookieParts[i] = encCookie; 37 | updated = true; 38 | } 39 | } 40 | 41 | if (updated) { 42 | return cookieParts.join(';') + ';'; 43 | } else { 44 | return txt + tkCookie + ';' + encCookie + ';'; 45 | } 46 | } 47 | function isObjectEmpty(obj) { 48 | return Object.values(obj).length === 0; 49 | } 50 | 51 | async function playChefGame(cookie) { 52 | const t = Date.now(); 53 | const body_str = "{\"bizScene\": \"XIAODANGJIA\",\"actId\": \"20230117134129770153614517\",\"uniqueId\": \"\",\"latitude\": \"30.17862595617771\",\"longitude\": \"120.22057268768549\",\"cityId\": \"2\",\"bizCode\": \"XIAODANGJIA\",\"collectionId\": \"20230421102945045949799658\",\"componentId\": \"20230505143809276394718532\",\"extParams\": \"{\\\"actId\\\":\\\"20230117134129770153614517\\\",\\\"bizScene\\\":\\\"XIAODANGJIA\\\",\\\"desc\\\":\\\"玩特级厨师挑战赛\\\"}\",\"asac\": \"2A22C0239QW1FOL3UUQY7U\"}" 54 | const api = 'mtop.koubei.interactioncenter.platform.right.lottery' 55 | const { data } = await h5Request(body_str, "12574478", "shopping.ele.me", api, cookie) 56 | 57 | if (Object.keys(data.data).length === 0) { 58 | console.log(data.ret[0]) 59 | return false 60 | } else { 61 | const amount = data.data.sendRightList[0].discountInfo.amount; 62 | console.log("特级厨师闯关成功。获得:" + amount + " 乐园币"); 63 | if (amount && amount !== 1) { 64 | console.log("防止频繁,延时 5 秒"); 65 | await wait(5); 66 | return await playChefGame(cookie) 67 | }else{ 68 | return null 69 | } 70 | } 71 | } 72 | 73 | // 161274962374%40eleme_android_11.12.88" 74 | async function h5Request(dataObj, appkey, host, api, cookie, extraHeader = {}, ttid = '161274962374%40eleme_android_11.12.88') { 75 | const t = new Date().getTime(); 76 | const tk = getToken(cookie) 77 | const stk = tk.split("_")[0]; 78 | const sign = await getSign(`${stk}&${t}&${appkey}&${dataObj}`) 79 | const parm = "jsv=2.7.0&appKey=" + appkey + "&t=" + t + "&sign=" + sign + "&api=" + api + "&v=1.0&ecode=1&type=json&valueType=string&needLogin=true&LoginRequest=true&dataType=jsonp&ttid=" + ttid; 80 | const header = { 81 | 'content-type': 'application/x-www-form-urlencoded', 82 | 'Connection': 'keep-alive', 83 | 'Cookie': cookie + ';', 84 | 'user-agent': 'Mozilla/5.0 (WindOws NT 10.0; WOW64) AppLeWebKit/537.36 (KHTML, like Gecko) chrome/86.0.4240.198 Safari/537.36', 85 | 'accept': 'application/json', 86 | 'sec-fetch-site': 'cross-site', 87 | 'sec-fetch-mode': 'cors', 88 | 'sec-fetch-dest': 'empty', 89 | "Origin": "https://tb.ele.me", 90 | 'referer': "https://servicewechat.com/wxece3a9a4c82f58c9/626/page-frame.html", 91 | 'accept-language': 'zh-CN,zh;q=0.9', 92 | } 93 | Object.assign(header, extraHeader) 94 | const options = { 95 | url: "https://" + host + "/h5/" + api + "/1.0/?" + parm, 96 | method: "POST", 97 | headers: header, 98 | body: qs.stringify({ data: dataObj }) 99 | } 100 | 101 | return new Promise(callback => { 102 | request(options, async (error, response, body) => { 103 | if (!error && response.statusCode === 200) { 104 | const responseBody = JSON.parse(body); 105 | if (responseBody.ret[0].includes('令牌')) { 106 | const setCookieHeader = JSON.stringify(response.headers["set-cookie"]); 107 | const newToken = /_m_h5_tk=(\S*);/.exec(setCookieHeader)[1]; 108 | const newTokenEnc = /_m_h5_tk_enc=(\S*);/.exec(setCookieHeader)[1]; 109 | cookie = updateCookie(` _m_h5_tk=${newToken.split(";")[0]}`, ` _m_h5_tk_enc=${newTokenEnc.split(";")[0]}`, cookie); 110 | callback(await h5Request(dataObj, appkey, host, api, cookie)) 111 | // await playChefGame(cookie) 112 | } else { 113 | callback(responseBody); 114 | } 115 | } else { 116 | console.log(error || body); 117 | callback(); 118 | } 119 | }); 120 | 121 | }) 122 | } 123 | 124 | 125 | async function start() { 126 | const _0x2f100c = getCookies(); 127 | for (let _0x28bb82 = 0; _0x28bb82 < _0x2f100c["length"]; _0x28bb82++) { 128 | const _0x10e68c = _0x2f100c[_0x28bb82]; 129 | if (!_0x10e68c) { 130 | console["log"](" ❌无效用户信息, 请重新获取ck"); 131 | } else { 132 | try { 133 | let _0x3b7f88 = await checkCk(_0x10e68c, _0x28bb82); 134 | if (!_0x3b7f88) { 135 | continue; 136 | } 137 | let _0x2d55f7 = await getUserInfo(_0x3b7f88); 138 | if (!_0x2d55f7.encryptMobile) { 139 | console["log"]('第', _0x28bb82 + 1, "账号失效!请重新登录!!!😭"); 140 | continue; 141 | } 142 | const _0x5cb41f = _0x2d55f7["localId"]; 143 | console["log"]("******开始【饿了么账号", _0x28bb82 + 1, '】', _0x2d55f7.encryptMobile, "*********"); 144 | let gameInProgress = await playChefGame(_0x3b7f88); 145 | while (gameInProgress) { 146 | gameInProgress = await playChefGame(_0x3b7f88); 147 | } 148 | console["log"]("防止黑号延时3-5秒"); 149 | await wait(getRandom(3, 5)); 150 | } catch (_0x2a2515) { 151 | console["log"](_0x2a2515); 152 | } 153 | } 154 | } 155 | process["exit"](0); 156 | } 157 | 158 | start(); 159 | 160 | function getRandom(_0x452fcd, _0x5adc25) { 161 | return Math["floor"](Math["random"]() * (_0x5adc25 - _0x452fcd + 1) + _0x452fcd); 162 | } 163 | // prettier-ignore 164 | function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } -------------------------------------------------------------------------------- /elm_elecoupon.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import time 4 | import asyncio 5 | import datetime 6 | import requests 7 | from urllib.parse import urlencode, quote 8 | import hashlib 9 | import json 10 | import random 11 | import string 12 | 13 | proxy_api_url = "http://v2.api.juliangip.com/dynamic/getips?filter=1&ip_remain=1&num=3&pt=1&result_type=json&trade_no=1393165170262761&sign=7fe01dc4e651433a1858dfa1878187f3" 14 | 15 | qgid = "20" 16 | 17 | host = 'https://acs.m.goofish.com' 18 | 19 | ck = '' 20 | 21 | 22 | def generate_random_string(length=50): 23 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 24 | 25 | 26 | def reorder_ck(s: str) -> str: 27 | order = ["cookie2", "sgcookie", "unb", "USERID", "SID", "token", "utdid", "deviceId", "umt"] 28 | cookies = s.split(';') 29 | cookie_dict = {} 30 | for cookie in cookies: 31 | key_value = cookie.split('=', 1) 32 | if len(key_value) == 2: 33 | key, value = key_value 34 | cookie_dict[key.strip()] = value.strip() 35 | reordered_cookies = [] 36 | for key in order: 37 | if key in cookie_dict: 38 | reordered_cookies.append(f"{key}={cookie_dict[key]}") 39 | return ';'.join(reordered_cookies) + ';' 40 | 41 | 42 | def get_ck_usid(ck1): 43 | key_value_pairs = ck1.split(";") 44 | for pair in key_value_pairs: 45 | key, value = pair.split("=") 46 | if key == "USERID": 47 | return value 48 | else: 49 | return '账号' 50 | 51 | 52 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 53 | """ 54 | 合并带_m_h5_tk 55 | """ 56 | txt = cookie_str.replace(" ", "") 57 | txt = txt.replace("chushi;", "") 58 | if txt[-1] != ';': 59 | txt += ';' 60 | cookie_parts = txt.split(';')[:-1] 61 | updated = False 62 | for i, part in enumerate(cookie_parts): 63 | key_value = part.split('=') 64 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 65 | cookie_parts[i] = tk_cookie 66 | updated = True 67 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 68 | cookie_parts[i] = enc_cookie 69 | updated = True 70 | 71 | if updated: 72 | return ';'.join(cookie_parts) + ';' 73 | else: 74 | return txt + tk_cookie + ';' + enc_cookie + ';' 75 | 76 | 77 | def tq(cookie_string): 78 | """ 79 | 获取_m_h5_tk 80 | """ 81 | if not cookie_string: 82 | return '-1' 83 | cookie_pairs = cookie_string.split(';') 84 | for pair in cookie_pairs: 85 | key_value = pair.split('=') 86 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 87 | return key_value[1] 88 | return '-1' 89 | 90 | 91 | def tq1(txt): 92 | """ 93 | 拆分cookie 94 | """ 95 | try: 96 | txt = txt.replace(" ", "") 97 | if txt[-1] != ';': 98 | txt += ';' 99 | pairs = txt.split(";")[:-1] 100 | ck_json = {} 101 | for pair in pairs: 102 | key, value = pair.split("=", 1) 103 | ck_json[key] = value 104 | return ck_json 105 | except Exception as e: 106 | print(f'❎Cookie解析错误: {e}') 107 | return {} 108 | 109 | 110 | def md5(text): 111 | """ 112 | md5加密 113 | """ 114 | hash_md5 = hashlib.md5() 115 | hash_md5.update(text.encode()) 116 | return hash_md5.hexdigest() 117 | 118 | 119 | def check_cookie(cookie): 120 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 121 | headers = { 122 | "Cookie": cookie, 123 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 124 | } 125 | 126 | try: 127 | response = requests.get(url, headers=headers) 128 | if response.status_code == 200: 129 | cookie_jar = response.cookies 130 | token = cookie_jar.get('_m_h5_tk', '') 131 | token_cookie = "_m_h5_tk=" + token 132 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 133 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 134 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 135 | return cookie 136 | else: 137 | return None 138 | except Exception as e: 139 | print("解析ck错误") 140 | return None 141 | 142 | 143 | class TCS: 144 | def __init__(self, cki): 145 | self.stop = False 146 | self.ck = cki 147 | self.name1 = get_ck_usid(cki) 148 | self.qg_hour = 9 149 | self.qg_minute = 59 150 | self.qg_second = 58 151 | self.qgname = None 152 | self.copyId = None 153 | 154 | def ip(self, proxy1): 155 | try: 156 | global_proxy = { 157 | 'http': proxy1, 158 | 'https': proxy1, 159 | } 160 | r = requests.get('http://httpbin.org/ip', proxies=global_proxy) 161 | print(r.text) 162 | if r.status_code == 200: 163 | ip = r.text 164 | return True 165 | else: 166 | return None 167 | except requests.RequestException as e: 168 | print(e) 169 | return None 170 | except Exception as e: 171 | print(e) 172 | return None 173 | 174 | def porxy(self): 175 | proxy_list = [] 176 | r = requests.get(proxy_api_url).json() 177 | if r.get("code") == 200: 178 | list = r["data"]["proxy_list"] 179 | print(list) 180 | for dl in list: 181 | dl = dl.split(",")[0] 182 | print(dl) 183 | a = self.ip(dl) 184 | print(a) 185 | if a: 186 | proxy_list.append(dl) 187 | return proxy_list 188 | 189 | def req(self, api, data, v="1.0"): 190 | try: 191 | cookie = check_cookie(self.ck) 192 | headers = { 193 | "authority": "shopping.ele.me", 194 | "accept": "application/json", 195 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 196 | "cache-control": "no-cache", 197 | "content-type": "application/x-www-form-urlencoded", 198 | "cookie": cookie, 199 | } 200 | timestamp = int(time.time() * 1000) 201 | data_str = json.dumps(data) 202 | token = tq(cookie) 203 | token_part = token.split("_")[0] 204 | 205 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 206 | sign = md5(sign_str) 207 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json&data={data_str}" 208 | data1 = urlencode({'data': data_str}) 209 | r = requests.get(url, headers=headers) 210 | if r: 211 | return r 212 | else: 213 | return None 214 | except Exception as e: 215 | return None 216 | 217 | def login(self): 218 | api1 = 'mtop.alsc.user.detail.query' 219 | data1 = {} 220 | try: 221 | res1 = self.req(api1, data1, "1.0") 222 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 223 | self.name = res1.json()["data"]["encryptMobile"] 224 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 225 | data = {"templateIds": "[\"1404\"]"} 226 | try: 227 | res = self.req(api, data, "1.0") 228 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 229 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 230 | if int(res.json()["data"]["data"]["1404"]["count"]) >= 3999: 231 | return True 232 | else: 233 | print("乐园币不够兑换优惠券") 234 | return False 235 | else: 236 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 237 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 238 | return False 239 | else: 240 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 241 | return False 242 | except Exception as e: 243 | print(f"[{self.name1}] ❎登录失败: {e}") 244 | return False 245 | else: 246 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 247 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 248 | return False 249 | else: 250 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 251 | return False 252 | except Exception as e: 253 | print(f"[{self.name1}] ❎登录失败: {e}") 254 | return False 255 | 256 | async def post_qg(self): 257 | qgnum = 0 258 | while not self.stop and qgnum < 20: 259 | api1 = 'mtop.koubei.interactioncenter.platform.right.exchange.v2' 260 | data1 = { 261 | "actId": "20221207144029906162546384", 262 | "collectionId": "20221216181231449964003945", 263 | "copyId": self.copyId, 264 | "bizScene": "game_center", 265 | "channel": "abcd", 266 | "longitude": 104.098238, 267 | "latitude": 30.229593, 268 | "hsf": 1 269 | } 270 | try: 271 | res1 = self.req(api1, data1, "1.0") 272 | print(res1.text) 273 | if res1.json()['ret'][0] == "SUCCESS::调用成功": 274 | print(f"[{self.name}] 抢购[{self.qgname}]成功") 275 | self.stop = True 276 | break 277 | else: 278 | if res1.json()['ret'][0] == "UNKNOWN_FAIL_CODE::系统开小差了,请稍候重试": 279 | print(f'[{self.name}] ❌抢[{self.qgname}]购失败,原因:{res1.json()["data"]["errorMsg"]}') 280 | else: 281 | print(f'[{self.name}] ❌抢[{self.qgname}]购失败,原因:{res1.json()["ret"][0]}') 282 | except Exception as e: 283 | print(f"[{self.name1}] ❌抢[{self.qgname}]购失败,原因: {e}") 284 | await asyncio.sleep(0.1) 285 | qgnum += 1 286 | 287 | 288 | async def get_id(self): 289 | api1 = 'mtop.koubei.interactioncenter.platform.right.exchangelist' 290 | data1 = { 291 | "actId": "20221207144029906162546384", 292 | "collectionId": "20221216181231449964003945", 293 | "bizScene": "game_center", 294 | "longitude": "104.05759390443563", 295 | "latitude": "30.69377588108182" 296 | } 297 | try: 298 | res1 = self.req(api1, data1, "1.0") 299 | if res1.json()['ret'][0] == "SUCCESS::调用成功": 300 | for right_info in res1.json()['data']['data']['rightInfoList']: 301 | if right_info['rightName'] == "20元现金抵扣券": 302 | self.qgname = right_info['rightName'] 303 | self.copyId = right_info['rightId'] 304 | print(f"[{self.name}] 获取ID成功") 305 | else: 306 | print(f"[{self.name}] ❌获取ID失败,原因: {res1.json()['ret'][0]}") 307 | except Exception as e: 308 | print(f"[{self.name1}] ❌获取ID失败,原因: {e}") 309 | 310 | def log(self, message, value): 311 | print(f"{message} {value:.2f} 秒后发起请求") 312 | 313 | async def start(self): 314 | target_time = datetime.datetime.now().replace(hour=self.qg_hour, minute=self.qg_minute, second=self.qg_second).timestamp() 315 | if datetime.datetime.now().timestamp() > target_time: 316 | self.log("抢购时间已过,你来晚了!", 0) 317 | return 318 | time_to_wait = max(0, target_time - datetime.datetime.now().timestamp()) 319 | self.log("等待", time_to_wait) 320 | while time_to_wait > 6: 321 | time_to_wait = max(0, target_time - datetime.datetime.now().timestamp()) 322 | if time_to_wait <= 8: 323 | self.log(f"距离抢购时间还有", time_to_wait) 324 | await self.get_id() 325 | await asyncio.sleep(time_to_wait) 326 | await self.post_qg() 327 | 328 | async def main(self): 329 | if self.login(): 330 | print(f"----开始抢购----") 331 | await self.start() 332 | 333 | async def main(cookies): 334 | print(f"饿了么共获取到 {len(cookies)} 个账号") 335 | futures = [] 336 | for i, ck in enumerate(cookies): 337 | print(f"======开始第{i + 1}个账号======") 338 | ck = reorder_ck(ck) 339 | future = asyncio.ensure_future(TCS(ck).main()) 340 | futures.append(future) 341 | if len(futures) >= 5: 342 | await asyncio.gather(*futures) 343 | futures = [] 344 | if futures: 345 | await asyncio.gather(*futures) 346 | 347 | # 主函数 348 | if __name__ == '__main__': 349 | if 'elmqqck' in os.environ: 350 | cookie = os.environ.get('elmqqck') 351 | else: 352 | print("环境变量中不存在[elmqqck],启用本地变量模式") 353 | cookie = ck 354 | if cookie == "": 355 | print("本地变量为空,请设置其中一个变量后再运行") 356 | exit(-1) 357 | cookies = cookie.split("&") 358 | 359 | loop = asyncio.new_event_loop() 360 | asyncio.set_event_loop(loop) 361 | loop.run_until_complete(main(cookies)) -------------------------------------------------------------------------------- /elm_tyt.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import os 3 | import re 4 | import time 5 | import requests 6 | from urllib.parse import urlencode, quote 7 | 8 | host = 'https://acs.m.goofish.com' 9 | 10 | ck = '' 11 | 12 | import json 13 | import random 14 | import string 15 | 16 | 17 | def generate_random_string(length=50): 18 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 19 | 20 | def reorder_ck(s: str) -> str: 21 | order = ["cookie2", "sgcookie", "unb", "USERID", "SID", "token", "utdid", "deviceId", "umt"] 22 | cookies = s.split(';') 23 | cookie_dict = {} 24 | for cookie in cookies: 25 | key_value = cookie.split('=', 1) 26 | if len(key_value) == 2: 27 | key, value = key_value 28 | cookie_dict[key.strip()] = value.strip() 29 | reordered_cookies = [] 30 | for key in order: 31 | if key in cookie_dict: 32 | reordered_cookies.append(f"{key}={cookie_dict[key]}") 33 | return ';'.join(reordered_cookies) + ';' 34 | 35 | def get_ck_usid(ck1): 36 | key_value_pairs = ck1.split(";") 37 | for pair in key_value_pairs: 38 | key, value = pair.split("=") 39 | if key == "USERID": 40 | return value 41 | else: 42 | return '账号' 43 | 44 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 45 | """ 46 | 合并带_m_h5_tk 47 | """ 48 | txt = cookie_str.replace(" ", "") 49 | txt = txt.replace("chushi;", "") 50 | if txt[-1] != ';': 51 | txt += ';' 52 | cookie_parts = txt.split(';')[:-1] 53 | updated = False 54 | for i, part in enumerate(cookie_parts): 55 | key_value = part.split('=') 56 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 57 | cookie_parts[i] = tk_cookie 58 | updated = True 59 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 60 | cookie_parts[i] = enc_cookie 61 | updated = True 62 | 63 | if updated: 64 | return ';'.join(cookie_parts) + ';' 65 | else: 66 | return txt + tk_cookie + ';' + enc_cookie + ';' 67 | 68 | 69 | def tq(cookie_string): 70 | """ 71 | 获取_m_h5_tk 72 | """ 73 | if not cookie_string: 74 | return '-1' 75 | cookie_pairs = cookie_string.split(';') 76 | for pair in cookie_pairs: 77 | key_value = pair.split('=') 78 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 79 | return key_value[1] 80 | return '-1' 81 | 82 | 83 | def tq1(txt): 84 | """ 85 | 拆分cookie 86 | """ 87 | try: 88 | txt = txt.replace(" ", "") 89 | if txt[-1] != ';': 90 | txt += ';' 91 | pairs = txt.split(";")[:-1] 92 | ck_json = {} 93 | for pair in pairs: 94 | key, value = pair.split("=", 1) 95 | ck_json[key] = value 96 | return ck_json 97 | except Exception as e: 98 | print(f'❎Cookie解析错误: {e}') 99 | return {} 100 | 101 | 102 | def md5(text): 103 | """ 104 | md5加密 105 | """ 106 | hash_md5 = hashlib.md5() 107 | hash_md5.update(text.encode()) 108 | return hash_md5.hexdigest() 109 | 110 | 111 | def check_cookie(cookie): 112 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 113 | headers = { 114 | "Cookie": cookie, 115 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 116 | } 117 | 118 | try: 119 | response = requests.get(url, headers=headers) 120 | if response.status_code == 200: 121 | cookie_jar = response.cookies 122 | token = cookie_jar.get('_m_h5_tk', '') 123 | token_cookie = "_m_h5_tk=" + token 124 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 125 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 126 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 127 | return cookie 128 | else: 129 | return None 130 | except Exception as e: 131 | print("解析ck错误") 132 | return None 133 | 134 | class TYT: 135 | def __init__(self, cki): 136 | self.name = None 137 | self.ck = cki 138 | self.cki = tq1(cki) 139 | self.uid = self.cki.get("unb") 140 | self.sid = self.cki.get("cookie2") 141 | self.name1 = get_ck_usid(cki) 142 | if self.name1 is None: 143 | raise ValueError("❎获取USERID失败,跳过该账号") 144 | 145 | 146 | def xsign(self, api, data, wua, v): 147 | body = { 148 | "data": data, 149 | "api": api, 150 | "pageId": '', 151 | "uid": self.uid, 152 | 'sid': self.sid, 153 | "deviceId": '', 154 | "utdid": '', 155 | "wua": wua, 156 | 'ttid': '1551089129819@eleme_android_10.14.3', 157 | "v": v 158 | } 159 | 160 | try: 161 | r = requests.post( 162 | "http://192.168.1.124:1777/api/getXSign", 163 | json=body 164 | ) 165 | r.raise_for_status() 166 | return r.json() 167 | except requests.exceptions.HTTPError as e: 168 | print(f'❎请求签名服务器失败: {e}') 169 | return None 170 | except requests.exceptions.RequestException as e: 171 | print(f'❎请求签名服务器错误: {e}') 172 | return None 173 | 174 | def req1(self, api, data, wua='False', v="1.0"): 175 | try: 176 | if type(data) == dict: 177 | data = json.dumps(data) 178 | wua = str(wua) 179 | sign = self.xsign(api, data, wua, v) 180 | url = f"{host}/gw/{api}/{v}/" 181 | headers = { 182 | "x-sgext": quote(sign.get('x-sgext')), 183 | "x-sign": quote(sign.get('x-sign')), 184 | 'x-sid': self.sid, 185 | 'x-uid': self.uid, 186 | 'x-pv': '6.3', 187 | 'x-features': '1051', 188 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 189 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 190 | 'x-t': sign.get('x-t'), 191 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 192 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 193 | 'x-utdid': '', 194 | 'x-appkey': '24895413', 195 | 'x-devid': '', 196 | } 197 | 198 | params = {"data": data} 199 | if 'wua' in sign: 200 | params["wua"] = sign.get('wua') 201 | 202 | max_retries = 5 203 | retries = 0 204 | while retries < max_retries: 205 | try: 206 | res = requests.post(url, headers=headers, data=params, timeout=5) 207 | return res 208 | except requests.exceptions.Timeout: 209 | print("❎接口请求超时") 210 | except requests.exceptions.RequestException as e: 211 | print(f"❎请求异常: {e}") 212 | retries += 1 213 | print(f"❎重试次数: {retries}") 214 | if retries >= max_retries: 215 | print("❎重试次数上限") 216 | return None 217 | except Exception as e: 218 | print(f'❎请求接口失败: {e}') 219 | return None 220 | 221 | def req(self, api, data, v="1.0"): 222 | try: 223 | cookie = check_cookie(self.ck) 224 | headers = { 225 | "authority": "shopping.ele.me", 226 | "accept": "application/json", 227 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 228 | "cache-control": "no-cache", 229 | "content-type": "application/x-www-form-urlencoded", 230 | "cookie": cookie, 231 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 232 | } 233 | timestamp = int(time.time() * 1000) 234 | data_str = json.dumps(data) 235 | token = tq(cookie) 236 | token_part = token.split("_")[0] 237 | 238 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 239 | sign = md5(sign_str) 240 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json" 241 | data1 = urlencode({'data': data_str}) 242 | r = requests.post(url, headers=headers, data=data1) 243 | if r: 244 | return r 245 | else: 246 | return None 247 | except Exception as e: 248 | return None 249 | 250 | def login(self): 251 | api1 = 'mtop.alsc.user.detail.query' 252 | data1 = {} 253 | try: 254 | res1 = self.req(api1, data1, "1.0") 255 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 256 | self.name = res1.json()["data"]["encryptMobile"] 257 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 258 | data = {"templateIds": "[\"1404\"]"} 259 | try: 260 | res = self.req(api, data, "1.0") 261 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 262 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 263 | return True 264 | else: 265 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 266 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 267 | return False 268 | else: 269 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 270 | return False 271 | except Exception as e: 272 | print(f"[{self.name1}] ❎登录失败: {e}") 273 | return False 274 | else: 275 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 276 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 277 | return False 278 | else: 279 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 280 | return False 281 | except Exception as e: 282 | print(f"[{self.name1}] ❎登录失败: {e}") 283 | return False 284 | 285 | def game_grid_jump(self, jump_count): 286 | grid_data = [] 287 | prev_end_config_info = None 288 | for i in range(jump_count): 289 | start_grid_id = i 290 | end_grid_id = i + 1 291 | jump_time = random.randint(500, 1000) 292 | start_coordinates = (random.uniform(0, 5), random.uniform(0, 5)) 293 | end_coordinates = (random.uniform(0, 5), random.uniform(0, 5)) 294 | 295 | if i > 0: 296 | start_config_info = prev_end_config_info 297 | else: 298 | start_config_info = generate_random_string() 299 | 300 | end_config_info = generate_random_string() 301 | jump_interval = random.randint(1000, 5000) 302 | 303 | grid_data.append({ 304 | "startGridId": start_grid_id, 305 | "endGridId": end_grid_id, 306 | "jumpTime": jump_time, 307 | "startCoordinatesX": str(start_coordinates[0]), 308 | "startCoordinatesY": str(start_coordinates[1]), 309 | "endCoordinatesX": str(end_coordinates[0]), 310 | "endCoordinatesY": str(end_coordinates[1]), 311 | "startConfigInfo": start_config_info, 312 | "endConfigInfo": end_config_info, 313 | "jumpInterval": jump_interval 314 | }) 315 | 316 | prev_end_config_info = end_config_info 317 | return grid_data 318 | 319 | def task(self): 320 | api = 'mtop.ele.biz.growth.task.core.querytask' 321 | data = json.dumps({"bizScene": "JUMP_GAME", "accountPlan": "HAVANA_COMMON", "missionCollectionId": "1265", 322 | "locationInfos": "[\"{\\\"lng\\\":\\\"105.754581\\\",\\\"lat\\\":\\\"30.60041\\\"}\"]", 323 | "missionIds": "[22562022,22562021]"}) 324 | try: 325 | res = self.req1(api, data, "1.0") 326 | if res.json()['ret'][0] == 'SUCCESS::接口调用成功': 327 | if res.json()["data"]["mlist"][0]["stage"]['count'] < 5: 328 | count = 5 - int(res.json()["data"]["mlist"][0]["stage"]['count']) 329 | for _ in range(int(count)): 330 | api = 'mtop.ele.biz.growth.task.event.pageview' 331 | data = {"collectionId": "1265", "missionId": "22562021", "actionCode": "PAGEVIEW", 332 | "pageFrom": "a2ogi.bx1161372", "viewTime": "15", "bizScene": "JUMP_GAME", 333 | "accountPlan": "KB_ORCHARD", "sync": "false", 334 | "asac": "2A23B18B2HYMDVFDDOXP2F"} 335 | try: 336 | res1 = self.req(api, data, "1.0") 337 | print(res1.json().get("ret")[0]) 338 | except Exception as e: 339 | print(f"[{self.name}] ❎请求失败{e}") 340 | return None 341 | except Exception as e: 342 | print(f"[{self.name}] ❎请求失败1") 343 | 344 | api = 'mtop.ele.biz.growth.task.core.querytask' 345 | data = json.dumps({"bizScene": "JUMP_GAME", "accountPlan": "HAVANA_COMMON", "missionCollectionId": "1265", 346 | "locationInfos": "[\"{\\\"lng\\\":\\\"105.754581\\\",\\\"lat\\\":\\\"30.60041\\\"}\"]", 347 | "missionIds": "[22562022,22562021]"}) 348 | try: 349 | res = self.req1(api, data, "1.0") 350 | if res.json()['ret'][0] == 'SUCCESS::接口调用成功': 351 | for y in res.json()['data']['mlist']: 352 | for o in y['missionStageDTOS']: 353 | if o['rewardStatus'] == "TODO" and o['status'] == "FINISH": 354 | if o['rewards'][0]['name'] == "游戏次数": 355 | api1 = 'mtop.ele.biz.growth.task.core.receiveprize' 356 | data1 = {"bizScene": "JUMP_GAME", "missionCollectionId": "1265", "missionId": "22562021", 357 | "locationInfos": "[\"{\\\"lng\\\":\\\"105.754353\\\",\\\"lat\\\":\\\"30.600449\\\"}\"]", 358 | "count": o['stageCount'], "asac": "2A23B18B2HYMDVFDDOXP2F"} 359 | try: 360 | res1 = self.req(api1, data1, "1.0") 361 | if res1 is None: 362 | continue 363 | data = res1.json()["data"] 364 | if data.get('errorMsg') is not None: 365 | print(f"[{self.name}] ❎领取奖励失败: {data['errorMsg']}") 366 | else: 367 | rlist = data.get('rlist') 368 | if rlist is not None: 369 | print(f"[{self.name}] ✅领取游戏次数成功--{rlist[0]['value']}次") 370 | else: 371 | print(f"[{self.name}] ❎{res1.json()['ret'][0]}") 372 | except Exception: 373 | print(f'请求错误') 374 | return None 375 | except Exception as e: 376 | print(f"[{self.name}] ❎请求失败{e}") 377 | 378 | def startgame(self): 379 | api = 'mtop.alsc.playgame.mini.game.dispatch' 380 | data = {"bizScene": "JUMP_GAME", "bizMethod": "start", "bizParam": "{}"} 381 | try: 382 | res = self.req(api, data, "1.0") 383 | if res is None: 384 | return None 385 | if res.json()["ret"][0] == "SUCCESS::调用成功": 386 | pattern = r'"gameId":"(\w+)"' 387 | match = re.search(pattern, str(res.json())) 388 | if match: 389 | gameId = match.group(1) 390 | return gameId 391 | else: 392 | print("❎解析数据失败") 393 | return None 394 | else: 395 | if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期": 396 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 397 | return None 398 | else: 399 | print(f'[{self.name1}] ❎{res.json()["ret"][0]}') 400 | return None 401 | except Exception: 402 | print(f'❎请求错误') 403 | return None 404 | 405 | def endgame(self): 406 | gameId = self.startgame() 407 | if gameId is None: 408 | return 409 | for i, gridId in enumerate([5, 20, 60], start=1): 410 | grid_jump_list = self.game_grid_jump(gridId) 411 | biz_param = { 412 | "gameId": gameId, 413 | "gridJumpList": grid_jump_list, 414 | "gridId": gridId 415 | } 416 | 417 | biz_request = { 418 | "bizScene": "JUMP_GAME", 419 | "bizMethod": "receiveReward", 420 | "bizParam": json.dumps(biz_param, separators=(',', ':')) 421 | } 422 | 423 | try: 424 | api = 'mtop.alsc.playgame.mini.game.dispatch' 425 | res = self.req(api, biz_request, "1.0") 426 | if res is None: 427 | return None 428 | res_json = res.json() 429 | if res_json["ret"][0] == "SUCCESS::调用成功": 430 | data_str = res_json['data']['data'] 431 | real_grant_value = re.search(r'"realGrantValue":(\d+)', data_str) 432 | amount = int(real_grant_value.group(1)) if real_grant_value else None 433 | if amount is not None: 434 | print(f"[{self.name}] ✅第{i}关完成,获得--{amount}乐园币") 435 | else: 436 | print(f"[{self.name}] ", res_json) 437 | print(f"[{self.name}] ❎第{i}关完成,并没有获得奖励") 438 | else: 439 | if res_json["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期": 440 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 441 | return None 442 | else: 443 | print(res_json["ret"][0]) 444 | return None 445 | except json.JSONDecodeError as e: 446 | print(f'[{self.name}] ❎JSON 解析错误: {e}') 447 | return None 448 | except requests.RequestException as e: 449 | print(f'[{self.name}] ❎请求错误: {e}') 450 | return None 451 | time.sleep(random.randint(1, 3)) 452 | 453 | def main(self): 454 | if self.login(): 455 | print(f"----尝试领取游戏次数----") 456 | self.task() 457 | print(f"----尝试完成闯关----") 458 | self.endgame() 459 | 460 | 461 | if __name__ == '__main__': 462 | if 'elmck' in os.environ: 463 | cookie = os.environ.get('elmck') 464 | else: 465 | print("环境变量中不存在[elmck],启用本地变量模式") 466 | cookie = ck 467 | if cookie == "": 468 | print("本地变量为空,请设置其中一个变量后再运行") 469 | exit(-1) 470 | cookies = cookie.split("&") 471 | print(f"饿了么共获取到 {len(cookies)} 个账号") 472 | for i, ck in enumerate(cookies): 473 | ck = reorder_ck(ck) 474 | print(f"======开始第{i + 1}个账号======") 475 | TYT(ck).main() 476 | print("2s后进行下一个账号") 477 | time.sleep(2) 478 | -------------------------------------------------------------------------------- /gy.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import random 4 | import time 5 | import requests 6 | from urllib.parse import quote 7 | import datetime 8 | 9 | 10 | nczlck = os.environ.get('elmck') 11 | 12 | ck = '' 13 | 14 | 15 | def tq(txt): 16 | try: 17 | txt = txt.replace(" ", "") 18 | pairs = txt.split(";")[:-1] 19 | ck_json = {} 20 | for i in pairs: 21 | ck_json[i.split("=")[0]] = i.split("=")[1] 22 | return ck_json 23 | except Exception as e: 24 | print(f'❎Cookie解析错误: {e}') 25 | return {} 26 | 27 | 28 | def xsign(api, data, uid, sid, wua, v): 29 | body = { 30 | "data": data, 31 | "api": api, 32 | "pageId": '', 33 | "uid": uid, 34 | 'sid': sid, 35 | "deviceId": '', 36 | "utdid": '', 37 | "wua": wua, 38 | 'ttid': '1551089129819@eleme_android_10.14.3', 39 | "v": v 40 | } 41 | 42 | try: 43 | r = requests.post( 44 | "http://184.57.23.12:1648/api/getXSign", 45 | json=body 46 | ) 47 | r.raise_for_status() 48 | return r.json() 49 | except requests.exceptions.HTTPError as e: 50 | print(f'❎请求签名服务器失败: {e}') 51 | return None 52 | except requests.exceptions.RequestException as e: 53 | print(f'❎请求签名服务器错误: {e}') 54 | return None 55 | 56 | 57 | class LYB: 58 | def __init__(self, cki): 59 | self.name = None 60 | self.cki = tq(cki) 61 | self.uid = self.cki.get("unb") 62 | self.sid = self.cki.get("cookie2") 63 | self.token = self.cki.get("token") 64 | self.deviceId = self.cki.get("deviceId") 65 | self.host = 'https://acs.m.goofish.com' 66 | self.name1 = get_ck_usid(cki) 67 | 68 | def req(self, api, data, wua='False', v="1.0"): 69 | try: 70 | if type(data) == dict: 71 | data = json.dumps(data) 72 | wua = str(wua) 73 | sign = xsign(api, data, self.uid, self.sid, wua, v) 74 | url = f"{self.host}/gw/{api}/{v}/" 75 | headers = { 76 | "x-sgext": quote(sign.get('x-sgext')), 77 | "x-sign": quote(sign.get('x-sign')), 78 | 'x-sid': self.sid, 79 | 'x-uid': self.uid, 80 | 'x-pv': '6.3', 81 | 'x-features': '1051', 82 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 83 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 84 | 'x-t': sign.get('x-t'), 85 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 86 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 87 | 'x-utdid': '', 88 | 'x-appkey': '24895413', 89 | 'x-devid': '', 90 | } 91 | 92 | params = {"data": data} 93 | if 'wua' in sign: 94 | params["wua"] = sign.get('wua') 95 | 96 | max_retries = 5 97 | retries = 0 98 | while retries < max_retries: 99 | try: 100 | res = requests.post(url, headers=headers, data=params, timeout=5) 101 | return res 102 | except requests.exceptions.Timeout: 103 | print("❎接口请求超时") 104 | except requests.exceptions.RequestException as e: 105 | print(f"❎请求异常: {e}") 106 | retries += 1 107 | print(f"❎重试次数: {retries}") 108 | if retries >= max_retries: 109 | print("❎重试次数上限") 110 | return None 111 | except Exception as e: 112 | print(f'❎请求接口失败: {e}') 113 | return None 114 | 115 | def login(self): 116 | api1 = 'mtop.alsc.user.detail.query' 117 | try: 118 | res1 = self.req(api1, json.dumps({}), 'False', "1.0") 119 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 120 | self.name = res1.json()["data"]["encryptMobile"] 121 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v1' 122 | data = json.dumps({"templateIds": "[\"1404\"]"}) 123 | try: 124 | res = self.req(api, data, 'False', "1.0") 125 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 126 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 127 | return True 128 | else: 129 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 130 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 131 | return False 132 | else: 133 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 134 | return False 135 | except Exception as e: 136 | print(f"[{self.name1}] ❎登录失败: {e}") 137 | return False 138 | else: 139 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 140 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 141 | return False 142 | else: 143 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 144 | return False 145 | except Exception as e: 146 | print(f"[{self.name1}] ❎登录失败: {e}") 147 | return False 148 | 149 | 150 | def warte(self): 151 | global amount, y, roleId 152 | api = 'mtop.alsc.playgame.orchard.index.batch.query' 153 | data1 = json.dumps({ 154 | "blockRequestList": "[{\"blockCode\":\"603040_6723057310\",\"status\":\"PUBLISH\",\"tagCallWay\":\"SYNC\",\"useRequestBlockTags\":false}]", 155 | "source": "KB_ORCHARD", "bizCode": "main", 156 | "locationInfos": "[{\"latitude\":\"30.597472842782736\",\"longitude\":\"105.75325090438128\",\"lat\":\"30.597472842782736\",\"lng\":\"105.75325090438128\"}]", 157 | "extData": "{\"ORCHARD_ELE_MARK\":\"KB_ORCHARD\",\"orchardVersion\":\"20240624\"}"}) 158 | res3 = self.req(api, data1, 'False', "1.0") 159 | if res3.json()["ret"][0] == "SUCCESS::调用成功": 160 | for y in res3.json()['data']['data']['603040_6723057310']['blockData']['assets']['tagData']: 161 | for o in y['totalProps']: 162 | if o['name'] == "水": 163 | y = o['value'] 164 | amount = int(int(o['value']) / 10) 165 | for tag_data in res3.json()["data"]['data']["603040_6723057310"]["blockData"]["role"]["tagData"]: 166 | for result_data in tag_data["result"]: 167 | for role_info in result_data["roleInfoDtoList"]: 168 | if "roleBaseInfoDto" in role_info: 169 | role_base_info = role_info["roleBaseInfoDto"] 170 | if "roleId" in role_base_info: 171 | roleId = role_base_info["roleId"] 172 | print(role_base_info["roleId"]) 173 | for tag_data in res3.json()["data"]["data"]["603040_6723057310"]["blockData"]["roleId"]["tagData"]: 174 | for result in tag_data["result"]: 175 | for role_info in result["roleInfoDtoList"]: 176 | Sunlightvalue = role_info["roleLevelExpInfoDto"]["remainingProgress"] 177 | print(f"✅水滴:{y}g\n✅可浇水:{amount}次\n✅阳光值: {Sunlightvalue}") 178 | else: 179 | if res3.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期": 180 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 181 | return 0, '0' 182 | else: 183 | print(f"[{self.name}] ❎获取列表失败:", res3.json()) 184 | return 0, '0' 185 | return amount, roleId 186 | 187 | def water(self): 188 | total_progress = 0 189 | total_watering = 0 190 | amount1, roleId1 = self.warte() 191 | if roleId1 == '0': 192 | return None 193 | for i1 in range(amount1): 194 | api = 'mtop.alsc.playgame.orchard.roleoperate.useprop' 195 | data2 = json.dumps({ 196 | "propertyTemplateId": "462", 197 | "roleId": roleId1, 198 | "latitude": "30.597472842782736", 199 | "longitude": "105.75325090438128", 200 | "roleType": "KB_ORCHARD", 201 | "actId": "20200629151859103125248022", 202 | "collectionId": "20210812150109893985929183", 203 | "bizScene": "KB_ORCHARD", 204 | "extParams": "{\"orchardVersion\":\"20240624\",\"popWindowVersion\":\"V2\"}" 205 | }) 206 | 207 | res2 = self.req(api, data2, 'False', "1.0") 208 | if res2.json()["ret"][0] == "SUCCESS::调用成功": 209 | total_watering += 1 210 | if 'progress' in res2.json()['data']['data']['extInfo']: 211 | progress = float(res2.json()['data']['data']['extInfo']['progress']) 212 | total_progress += progress 213 | print(f"[{self.name}] ✅第{total_watering}次浇水成功,获得进度--[{progress}]") 214 | else: 215 | progress = 1 216 | jg = res2.json()['data']['data']['roleInfoDTO']['roleLevelExpInfoDto']['upgradeNeedValue'] 217 | zt = res2.json()['data']['data']['roleInfoDTO']['roleLevelExpInfoDto']['nextLevelName'] 218 | total_progress += progress 219 | print(f"[{self.name}] ✅第{total_watering}次浇水成功,再浇水[{jg}]次可[{zt}]") 220 | elif res2.json()["ret"][0] == "FAIL_BIZ_ROLE_USING_PROP_EXP_ENOUGH::道具使用达到上限,明天再来吧": 221 | print(f"[{self.name}] ❎第{total_watering + 1}次浇水失败: 浇水上限") 222 | break 223 | else: 224 | print(f"[{self.name}] ❎第{total_watering + 1}次浇水失败: {res2.text}") 225 | time.sleep(random.randint(1, 3)) 226 | print(f"浇水{total_watering}次获得进度: {total_progress}") 227 | 228 | def main(self): 229 | try: 230 | if self.login(): 231 | self.water() 232 | except Exception as e: 233 | print(f"[{self.name1}] 请求错误{e}") 234 | 235 | 236 | def get_ck_usid(ck1): 237 | try: 238 | key_value_pairs = ck1.split(";") 239 | for pair in key_value_pairs: 240 | key, value = pair.split("=") 241 | if key.lower() == "userid": 242 | return value 243 | except Exception: 244 | return 'y' 245 | 246 | 247 | if __name__ == '__main__': 248 | if 'elmck' in os.environ: 249 | cookie = os.environ.get('elmck') 250 | else: 251 | print("环境变量中不存在[elmck],启用本地变量模式") 252 | cookie = ck 253 | if cookie == "": 254 | print("本地变量为空,请设置其中一个变量后再运行") 255 | exit(-1) 256 | cookies = cookie.split("&") 257 | print(f"饿了么共获取到 {len(cookies)} 个账号") 258 | for i, ck in enumerate(cookies): 259 | print(f"======开始第{i + 1}个账号======") 260 | LYB(ck).main() 261 | print("2s后进行下一个账号") 262 | time.sleep(2) 263 | -------------------------------------------------------------------------------- /kpbl.py: -------------------------------------------------------------------------------- 1 | import json 2 | import logging 3 | import os 4 | import random 5 | import re 6 | import time 7 | import requests 8 | from urllib.parse import quote 9 | 10 | from requests import RequestException 11 | 12 | host = 'https://acs.m.goofish.com' 13 | 14 | ck = '' 15 | 16 | 17 | import json 18 | import random 19 | import string 20 | 21 | 22 | def generate_random_string(length=50): 23 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 24 | 25 | 26 | def get_ck_usid(ck1): 27 | key_value_pairs = ck1.split(";") 28 | for pair in key_value_pairs: 29 | key, value = pair.split("=") 30 | if key == "USERID": 31 | return value 32 | else: 33 | return '账号' 34 | 35 | 36 | def tq(txt): 37 | try: 38 | txt = txt.replace(" ", "") 39 | pairs = txt.split(";")[:-1] 40 | ck_json = {} 41 | for i in pairs: 42 | ck_json[i.split("=")[0]] = i.split("=")[1] 43 | return ck_json 44 | except Exception as e: 45 | print(f'❎Cookie解析错误: {e}') 46 | return {} 47 | 48 | 49 | def xsign(api, data, uid, sid, wua, v): 50 | body = { 51 | "data": data, 52 | "api": api, 53 | "pageId": '', 54 | "uid": uid, 55 | 'sid': sid, 56 | "deviceId": '', 57 | "utdid": '', 58 | "wua": wua, 59 | 'ttid': '1551089129819@eleme_android_10.14.3', 60 | "v": v 61 | } 62 | 63 | try: 64 | r = requests.post( 65 | "http://192.168.1.124:1888/api/getXSign", 66 | # "http://127.0.0.1:18848/api/getXSign", 67 | json=body 68 | ) 69 | r.raise_for_status() 70 | return r.json() 71 | except requests.exceptions.HTTPError as e: 72 | print(f'❎请求签名服务器失败: {e}') 73 | return None 74 | except requests.exceptions.RequestException as e: 75 | print(f'❎请求签名服务器错误: {e}') 76 | return None 77 | 78 | 79 | def req(api, data, uid, sid, wua='False', v="1.0"): 80 | try: 81 | if type(data) == dict: 82 | data = json.dumps(data) 83 | wua = str(wua) 84 | sign = xsign(api, data, uid, sid, wua, v) 85 | url = f"{host}/gw/{api}/{v}/" 86 | headers = { 87 | "x-sgext": quote(sign.get('x-sgext')), 88 | "x-sign": quote(sign.get('x-sign')), 89 | 'x-sid': sid, 90 | 'x-uid': uid, 91 | 'x-pv': '6.3', 92 | 'x-features': '1051', 93 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 94 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 95 | 'x-t': sign.get('x-t'), 96 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 97 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 98 | 'x-utdid': '', 99 | 'x-appkey': '24895413', 100 | 'x-devid': '', 101 | } 102 | 103 | params = {"data": data} 104 | if 'wua' in sign: 105 | params["wua"] = sign.get('wua') 106 | 107 | max_retries = 5 108 | retries = 0 109 | while retries < max_retries: 110 | try: 111 | res = requests.post(url, headers=headers, data=params, timeout=5) 112 | return res 113 | except requests.exceptions.Timeout: 114 | print("❎接口请求超时") 115 | except requests.exceptions.RequestException as e: 116 | print(f"❎请求异常: {e}") 117 | retries += 1 118 | print(f"❎重试次数: {retries}") 119 | if retries >= max_retries: 120 | print("❎重试次数上限") 121 | return None 122 | except Exception as e: 123 | print(f'❎请求接口失败: {e}') 124 | return None 125 | 126 | 127 | class TYT: 128 | def __init__(self, cki): 129 | self.taskId = None 130 | self.stop = False 131 | self.gameId = None 132 | self.token = None 133 | self.name = None 134 | self.taskList = None 135 | self.cki = tq(cki) 136 | self.uid = self.cki.get("unb") 137 | self.sid = self.cki.get("cookie2") 138 | self.name1 = get_ck_usid(cki) 139 | 140 | def login(self): 141 | api1 = 'mtop.alsc.user.detail.query' 142 | data1 = json.dumps({}) 143 | try: 144 | res1 = req(api1, data1, self.uid, self.sid, "1.0") 145 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 146 | self.name = res1.json()["data"]["encryptMobile"] 147 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 148 | data = json.dumps({"templateIds": "[\"1404\"]"}) 149 | try: 150 | res = req(api, data, self.uid, self.sid, "1.0") 151 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 152 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 153 | return True 154 | else: 155 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 156 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 157 | return False 158 | else: 159 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 160 | return False 161 | except Exception as e: 162 | print(f"[{self.name1}] ❎登录失败: {e}") 163 | return False 164 | else: 165 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 166 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 167 | return False 168 | else: 169 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 170 | return False 171 | except Exception as e: 172 | print(f"[{self.name1}] ❎登录失败: {e}") 173 | return False 174 | 175 | def gettoken(self): 176 | api = 'mtop.alsc.playgame.mini.game.dispatch' 177 | data = json.dumps( 178 | {"bizScene": "CAPYBARA", "bizMethod": "login", "bizParam": "{\"gameId\":\"13254\",\"inviterId\":null}", 179 | "longitude": "104.09800574183464", "latitude": "30.22990694269538"}) 180 | res = req(api, data, self.uid, self.sid, "1.0") 181 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 182 | y = json.loads(res.json()["data"]["data"]) 183 | self.token = y["data"]["token"] 184 | self.gameId = y["data"]["openId"] 185 | return True 186 | elif res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 187 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 188 | return False 189 | else: 190 | print(f'[{self.name1}] ❌获取token失败,原因:{res.text}') 191 | return False 192 | 193 | # 开始游戏 194 | def startgame(self): 195 | api = 'mtop.alsc.playgame.mini.game.dispatch' 196 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "startGame", 197 | "bizParam": "{\"levelId\":\"1\",\"isRestart\":true,\"gameId\":\"" + self.gameId + "\",\"token\":\"" + self.token + "\"}", 198 | "longitude": "105.75325090438128", "latitude": "30.597472842782736"}) 199 | res = req(api, data, self.uid, self.sid, "1.0") 200 | print("助力: " + res.text) 201 | 202 | ## 菜品类型 203 | def scdisheslx(self): 204 | api = 'mtop.alsc.playgame.mini.game.dispatch' 205 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "startGame", 206 | "bizParam": "{\"levelId\":\"1\",\"isRestart\":false,\"gameId\":\"" + self.gameId + "\"}"}) 207 | try: 208 | res = req(api, data, self.uid, self.sid, "1.0") 209 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 210 | a = json.loads(res.json()["data"]["data"]) 211 | if a['data']['levelInfo']['orders']['CusS1001']['foodId'] == '_': 212 | foodid = 'Food1001' 213 | else: 214 | foodid = a['data']['levelInfo']['orders']['CusS1001']['foodId'] 215 | foodNum = a['data']['levelInfo']['orders']['CusS1001']['currCount'] 216 | if foodid in a['data']['levelInfo']['currFoods']: 217 | if self.scdishes() is not None: 218 | if 'currFoods' in a['data']['levelInfo'] and foodid in a['data']['levelInfo']['currFoods']: 219 | foodlx = a['data']['levelInfo']['currFoods'][foodid] 220 | return foodid, foodNum, foodlx 221 | else: 222 | print(f"菜品类型错误") 223 | return None, None, None 224 | else: 225 | print(f"菜品类4444型错误") 226 | return None, None, None 227 | else: 228 | return 'Food1001', foodNum, 1 229 | else: 230 | print(f"[{self.name}] ❎获取菜品类型失败--{res.text}") 231 | return None, None, None 232 | except RequestException as e: 233 | print(f"[{self.name}] ❎请求失败: {str(e)}") 234 | return None, None, None 235 | except Exception as e: 236 | logging.exception(f"[{self.name}] ❎请求失败: {str(e)}") 237 | return None, None, None 238 | 239 | # 上菜 240 | def scdishes(self): 241 | api = 'mtop.alsc.playgame.mini.game.dispatch' 242 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "handFoodOut", 243 | "bizParam": "{\"levelId\":\"1\",\"handCount\":10,\"gameId\":\"" + self.gameId + "\"}"}) 244 | try: 245 | res = req(api, data, self.uid, self.sid, "1.0") 246 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 247 | a = json.loads(res.json()["data"]["data"]) 248 | sysum = a['data']['energy']['num'] 249 | scjg = a['data']['outFoods'] 250 | print(f"[{self.name}] ✅上菜成功--{scjg},剩余菜品数量:{sysum}") 251 | if sysum > 0: 252 | return True 253 | else: 254 | print(f"[{self.name}] ❎上菜失败--菜品数量不足") 255 | self.stop = True 256 | return False 257 | else: 258 | print(f"[{self.name}] ❎上菜失败--{res.json()['ret'][0]}") 259 | return None 260 | except Exception as e: 261 | print(f"[{self.name}] ❎2请求失败: {e}") 262 | return None 263 | 264 | # 提交菜品 265 | def tjdishes(self): 266 | foodid, foodNum, foodlx = self.scdisheslx() 267 | if foodlx is None: 268 | print(f"[{self.name}] ❎ 获取菜品信息失败") 269 | return 270 | else: 271 | if foodlx == 0: 272 | self.scdishes() 273 | if int(foodNum) < 10: 274 | api = 'mtop.alsc.playgame.mini.game.dispatch' 275 | data = json.dumps({ 276 | "bizScene": "CAPYBARA", 277 | "bizMethod": "submitFood", 278 | "bizParam": "{\"levelId\":\"1\",\"orderSeatId\":\"CusS1001\",\"foodId\":\"" + foodid + "\",\"foodNum\":\"" + str( 279 | foodlx) + "\",\"gameId\":\"" + str(self.gameId) + "\"}" 280 | }) 281 | try: 282 | res = req(api, data, self.uid, self.sid, "1.0") 283 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 284 | a = json.loads(res.json()["data"]["data"]) 285 | if a['bizErrorCode'] == 'ORDER_FOOD_ERROR': 286 | print(f"[{self.name}] ❎提交菜品失败--{a['bizErrorMsg']}") 287 | self.scdishes() 288 | else: 289 | print(f"[{self.name}] ✅提交菜品成功") 290 | else: 291 | print(f"[{self.name}] ❎提交菜品失败--{res.json()['ret'][0]}") 292 | except Exception as e: 293 | print(f"[{self.name}] ❎1请求失败") 294 | if int(foodNum) >= 10: 295 | self.scscdishes() 296 | 297 | # 上传菜品 298 | def scscdishes(self): 299 | api = 'mtop.alsc.playgame.mini.game.dispatch' 300 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "receiveOrderAward", 301 | "bizParam": "{\"levelId\":\"1\",\"orderSeatId\":\"CusS1001\",\"gameId\":\"" + self.gameId + "\"}"}) 302 | try: 303 | res = req(api, data, self.uid, self.sid, "1.0") 304 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 305 | # print(res.json()) 306 | print(f"[{self.name}] ✅上传菜品成功") 307 | else: 308 | print(f"[{self.name}] ❎上传菜品失败--{res.json()['ret'][0]}") 309 | except Exception as e: 310 | print(f"[{self.name}] ❎1请求失败: {e}") 311 | 312 | def task(self): 313 | api = 'mtop.alsc.playgame.mini.game.dispatch' 314 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "getTasks", 315 | "bizParam": "{\"gameId\":\"" + self.gameId + "\",\"token\":\"" + self.token + "\"}", 316 | "longitude": "104.09800574183464", "latitude": "30.22990694269538"}) 317 | 318 | res = req(api, data, self.uid, self.sid, "1.0") 319 | print(f"获取任务列表",res.text) 320 | 321 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 322 | self.taskList = json.loads(res.json()["data"]["data"]) 323 | return True 324 | 325 | def checkTask(self): 326 | self.task() 327 | if 'T001' in self.taskList['data']['tasks']: 328 | if self.taskList['data']['tasks']['T001']['isFinishe'] == True: 329 | print(f"[{self.name}] ✅任务T001已完成") 330 | elif self.taskList['data']['tasks']['T001']['progress'] == 30: 331 | print(f"[{self.name}] 尝试领取 T001 奖励") 332 | id = self.taskList['data']['tasks']['T001']['taskId'] 333 | if not self.postTask(id): 334 | return 'T001' 335 | else: 336 | print(f"[{self.name}] T001 任务未完成!先做任务") 337 | return 'T001' 338 | else: 339 | print(f"[{self.name}] T001 任务未开始!先做任务") 340 | return 'T001' 341 | 342 | if 'T002' in self.taskList['data']['tasks']: 343 | if self.taskList['data']['tasks']['T002']['isFinishe'] == True: 344 | print(f"[{self.name}] ✅任务T002已完成") 345 | elif self.taskList['data']['tasks']['T002']['progress'] == 200: 346 | print(f"[{self.name}] 尝试领取 T002 奖励") 347 | id = self.taskList['data']['tasks']['T002']['taskId'] 348 | if not self.postTask(id): 349 | return 'T002' 350 | else: 351 | print(f"[{self.name}] T002 任务未完成!先做任务") 352 | return 'T002' 353 | else: 354 | print(f"[{self.name}] T002 任务未开始!先做任务") 355 | return 'T002' 356 | 357 | if 'T003' in self.taskList['data']['tasks']: 358 | if self.taskList['data']['tasks']['T003']['isFinishe'] == True: 359 | print(f"[{self.name}] ✅任务T003已完成!") 360 | elif self.taskList['data']['tasks']['T003']['progress'] == 2: 361 | print(f"[{self.name}] 尝试领取 T003 奖励") 362 | id = self.taskList['data']['tasks']['T003']['taskId'] 363 | if not self.postTask(id): 364 | return 'T003' 365 | else: 366 | print(f"[{self.name}] T003 任务未完成!先做任务") 367 | return 'T003' 368 | else: 369 | print(f"[{self.name}] T003 任务未开始!先做任务") 370 | return 'T003' 371 | 372 | return True 373 | def postTask(self,taskId): 374 | api = 'mtop.alsc.playgame.mini.game.dispatch' 375 | data = json.dumps({"bizScene": "CAPYBARA", "bizMethod": "finisheTask", 376 | "bizParam": "{\"taskId\":\"" + taskId + "\",\"gameId\":\"" + self.gameId + "\",\"token\":\"" + self.token + "\"}", 377 | "longitude": "104.09800574183464", "latitude": "30.22990694269538"}) 378 | 379 | res = req(api, data, self.uid, self.sid, "1.0") 380 | print(f"完成任务{taskId}",res.text) 381 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 382 | # print(res.json()) 383 | nested_data = json.loads(res.json()['data']['data']) 384 | reward_items = nested_data['data']['rewardItems'] 385 | if reward_items: 386 | reward_num = reward_items[0]['num'] 387 | print(f"[{self.name}] ✅完成任务获得乐园币--[{reward_num}]") 388 | return True 389 | return False 390 | return False 391 | 392 | 393 | def daoju(self,count): 394 | api = 'mtop.alsc.playgame.mini.game.dispatch' 395 | bizParam = json.dumps({ 396 | "levelId":"1", 397 | "itemId":f"It100{random.randint(1, 3)}", 398 | "removeFoods":{ 399 | "Food1003":random.randint(1, 10), 400 | "Food1002":random.randint(1, 10), 401 | "Food1004":random.randint(1, 3) 402 | }, 403 | "gameId":self.gameId, 404 | "token":self.token, 405 | }) 406 | data = json.dumps({ 407 | "bizScene":"CAPYBARA", 408 | "bizMethod":"useGameProp", 409 | "bizParam":bizParam, 410 | "longitude": "104.09800574183464", 411 | "latitude": "30.22990694269538" 412 | }) 413 | try: 414 | res = req(api, data, self.uid, self.sid, "1.0") 415 | # print(res.json()) 416 | if json.loads(res.json()['data']['data'])['bizErrorCode'] == 'OK': 417 | print(f"[{self.name}] ✅第{count}次使用道具成功!") 418 | count = count + 1 419 | return count 420 | else: 421 | print(f'[{self.name}] ❎第{count}次使用道具失败!!!',res.text) 422 | return count 423 | except Exception as e: 424 | print(f"[{self.name}] ❎1请求失败,结束使用道具: {e}") 425 | return 6 426 | 427 | def main(self): 428 | if self.login(): 429 | self.gettoken() 430 | checkRes = self.checkTask() 431 | if checkRes != True: 432 | if checkRes == 'T001' or checkRes == 'T002': 433 | print(f"----继续游戏----") 434 | while True and self.stop == False: 435 | self.tjdishes() 436 | 437 | checkRes = self.checkTask() 438 | if checkRes == 'T003': 439 | usedCount = 1 440 | while usedCount < 3: 441 | usedCount = self.daoju(usedCount) 442 | checkRes = self.checkTask() 443 | else: 444 | print(f"----任务已全部完成----") 445 | 446 | 447 | 448 | if __name__ == '__main__': 449 | if 'elmck' in os.environ: 450 | cookie = os.environ.get('elmck') 451 | else: 452 | print("环境变量中不存在[elmck],启用本地变量模式") 453 | cookie = ck 454 | if cookie == "": 455 | print("本地变量为空,请设置其中一个变量后再运行") 456 | exit(-1) 457 | cookies = cookie.split("&") 458 | print(f"饿了么共获取到 {len(cookies)} 个账号") 459 | for i, ck in enumerate(cookies): 460 | print(f"======开始第{i + 1}个账号======") 461 | TYT(ck).main() 462 | print("2s后进行下一个账号") 463 | time.sleep(2) 464 | -------------------------------------------------------------------------------- /lgqs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import hashlib 4 | import os 5 | import re 6 | import time 7 | import requests 8 | from urllib.parse import urlencode, quote 9 | import execjs 10 | import tempfile 11 | import subprocess 12 | 13 | host = 'https://acs.m.goofish.com' 14 | 15 | ck = '' 16 | 17 | import json 18 | import random 19 | import string 20 | import base64 21 | 22 | def rsa_encrypt(public_key_pem, data_str): 23 | url = 'http://mzkj666.cn:9324/encrypt' 24 | data = { 25 | 'publicKeyPem': public_key_pem, 26 | 'dataStr': data_str 27 | } 28 | 29 | response = requests.post(url, json=data) 30 | if response.status_code == 200: 31 | return response.json()['encryptedData'] 32 | else: 33 | return response.json()['encryptedData'] 34 | 35 | def generate_random_string(length=50): 36 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 37 | 38 | 39 | def get_ck_usid(ck1): 40 | key_value_pairs = ck1.split(";") 41 | for pair in key_value_pairs: 42 | key, value = pair.split("=") 43 | if key == "USERID": 44 | return value 45 | else: 46 | return '账号' 47 | 48 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 49 | """ 50 | 合并带_m_h5_tk 51 | """ 52 | txt = cookie_str.replace(" ", "") 53 | if txt[-1] != ';': 54 | txt += ';' 55 | cookie_parts = txt.split(';')[:-1] 56 | updated = False 57 | for i, part in enumerate(cookie_parts): 58 | key_value = part.split('=') 59 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 60 | cookie_parts[i] = tk_cookie 61 | updated = True 62 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 63 | cookie_parts[i] = enc_cookie 64 | updated = True 65 | 66 | if updated: 67 | return ';'.join(cookie_parts) + ';' 68 | else: 69 | return txt + tk_cookie + ';' + enc_cookie + ';' 70 | 71 | 72 | def tq(cookie_string): 73 | """ 74 | 获取_m_h5_tk 75 | """ 76 | if not cookie_string: 77 | return '-1' 78 | cookie_pairs = cookie_string.split(';') 79 | for pair in cookie_pairs: 80 | key_value = pair.split('=') 81 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 82 | return key_value[1] 83 | return '-1' 84 | 85 | 86 | def tq1(txt): 87 | """ 88 | 拆分cookie 89 | """ 90 | try: 91 | txt = txt.replace(" ", "") 92 | if txt[-1] != ';': 93 | txt += ';' 94 | pairs = txt.split(";")[:-1] 95 | ck_json = {} 96 | for pair in pairs: 97 | key, value = pair.split("=", 1) 98 | ck_json[key] = value 99 | return ck_json 100 | except Exception as e: 101 | print(f'❎Cookie解析错误: {e}') 102 | return {} 103 | 104 | 105 | def md5(text): 106 | """ 107 | md5加密 108 | """ 109 | hash_md5 = hashlib.md5() 110 | hash_md5.update(text.encode()) 111 | return hash_md5.hexdigest() 112 | 113 | 114 | def check_cookie(cookie): 115 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 116 | headers = { 117 | "Cookie": cookie, 118 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 119 | } 120 | 121 | try: 122 | response = requests.get(url, headers=headers) 123 | if response.status_code == 200: 124 | cookie_jar = response.cookies 125 | token = cookie_jar.get('_m_h5_tk', '') 126 | token_cookie = "_m_h5_tk=" + token 127 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 128 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 129 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 130 | return cookie 131 | else: 132 | return None 133 | except Exception as e: 134 | print("解析ck错误") 135 | return None 136 | 137 | class TYT: 138 | def __init__(self, cki): 139 | self.name = None 140 | self.ck = cki 141 | self.cki = tq1(cki) 142 | self.uid = self.cki.get("unb") 143 | self.sid = self.cki.get("cookie2") 144 | self.name1 = get_ck_usid(cki) 145 | self.curGameId = "" 146 | self.propertyId = "" 147 | self.gamePublicKey = "" 148 | self.gameCount = 0 149 | 150 | def xsign(self, api, data, wua, v): 151 | body = { 152 | "data": data, 153 | "api": api, 154 | "pageId": '', 155 | "uid": self.uid, 156 | 'sid': self.sid, 157 | "deviceId": '', 158 | "utdid": '', 159 | "wua": wua, 160 | 'ttid': '1551089129819@eleme_android_10.14.3', 161 | "v": v 162 | } 163 | 164 | try: 165 | r = requests.post( 166 | "http://192.168.1.124:1888/api/getXSign", 167 | json=body 168 | ) 169 | r.raise_for_status() 170 | return r.json() 171 | except requests.exceptions.HTTPError as e: 172 | print(f'❎请求签名服务器失败: {e}') 173 | return None 174 | except requests.exceptions.RequestException as e: 175 | print(f'❎请求签名服务器错误: {e}') 176 | return None 177 | 178 | def xsign_req(self, api, data, wua='False', v="1.0"): 179 | try: 180 | if type(data) == dict: 181 | data = json.dumps(data) 182 | wua = str(wua) 183 | sign = self.xsign(api, data, wua, v) 184 | url = f"{host}/gw/{api}/{v}/" 185 | headers = { 186 | "x-sgext": quote(sign.get('x-sgext')), 187 | "x-sign": quote(sign.get('x-sign')), 188 | 'x-sid': self.sid, 189 | 'x-uid': self.uid, 190 | 'x-pv': '6.3', 191 | 'x-features': '1051', 192 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 193 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 194 | 'x-t': sign.get('x-t'), 195 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 196 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 197 | 'x-utdid': '', 198 | 'x-appkey': '24895413', 199 | 'x-devid': '', 200 | } 201 | 202 | params = {"data": data} 203 | if 'wua' in sign: 204 | params["wua"] = sign.get('wua') 205 | 206 | max_retries = 5 207 | retries = 0 208 | while retries < max_retries: 209 | try: 210 | res = requests.post(url, headers=headers, data=params, timeout=5) 211 | return res 212 | except requests.exceptions.Timeout: 213 | print("❎接口请求超时") 214 | except requests.exceptions.RequestException as e: 215 | print(f"❎请求异常: {e}") 216 | retries += 1 217 | print(f"❎重试次数: {retries}") 218 | if retries >= max_retries: 219 | print("❎重试次数上限") 220 | return None 221 | except Exception as e: 222 | print(f'❎请求接口失败: {e}') 223 | return None 224 | 225 | def no_xsign_req(self, api, data, v="1.0"): 226 | try: 227 | cookie = check_cookie(self.ck) 228 | headers = { 229 | "authority": "shopping.ele.me", 230 | "accept": "application/json", 231 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 232 | "cache-control": "no-cache", 233 | "content-type": "application/x-www-form-urlencoded", 234 | "cookie": cookie, 235 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 236 | } 237 | timestamp = int(time.time() * 1000) 238 | data_str = json.dumps(data) 239 | token = tq(cookie) 240 | token_part = token.split("_")[0] 241 | 242 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 243 | sign = md5(sign_str) 244 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json" 245 | data1 = urlencode({'data': data_str}) 246 | r = requests.post(url, headers=headers, data=data1) 247 | if r.json()['ret'][0] in ['SUCCESS::接口调用成功','SUCCESS::调用成功']: 248 | return r 249 | else: 250 | # print('请求失败:',r.text) 251 | return f"请求异常:{r.json()['ret'][0]}" 252 | except Exception as e: 253 | print('请求出现错误:',e) 254 | return None 255 | 256 | def login(self): 257 | api1 = 'mtop.alsc.user.detail.query' 258 | data1 = {} 259 | try: 260 | res1 = self.no_xsign_req(api1, data1, "1.0") 261 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 262 | self.name = res1.json()["data"]["encryptMobile"] 263 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 264 | data = {"templateIds": "[\"1404\"]"} 265 | try: 266 | res = self.no_xsign_req(api, data, "1.0") 267 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 268 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 269 | return True 270 | else: 271 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 272 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 273 | return False 274 | else: 275 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 276 | return False 277 | except Exception as e: 278 | print(f"[{self.name1}] ❎登录失败: {e}") 279 | return False 280 | else: 281 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 282 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 283 | return False 284 | else: 285 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 286 | return False 287 | except Exception as e: 288 | print(f"[{self.name1}] ❎登录失败: {e}") 289 | return False 290 | 291 | def task(self): 292 | print(f"[{self.name1}] 开始获取游戏任务") 293 | api = 'mtop.ele.biz.growth.task.core.querytask' 294 | data = json.dumps({"bizScene": "BLUE_KNIGHT_PARKOUR", "accountPlan": "HAVANA_COMMON", "missionCollectionId": "1322", 295 | "locationInfos": "[\"{\\\"lng\\\":\\\"120.220572\\\",\\\"lat\\\":\\\"30.178625\\\"}\"]" 296 | }) 297 | try: 298 | res = self.xsign_req(api, data, "1.0") 299 | if res.json()['ret'][0] == 'SUCCESS::接口调用成功': 300 | if res.json()["data"]["mlist"][0]["stage"]['count'] < 5: 301 | count = 5 - int(res.json()["data"]["mlist"][0]["stage"]['count']) 302 | for _ in range(int(count)): 303 | api = 'mtop.ele.biz.growth.task.event.pageview' 304 | data = { 305 | "collectionId": "1322", 306 | "missionId": "23414001", 307 | "actionCode": "PAGEVIEW", 308 | "pageFrom": "a2ogi.bx1157100", 309 | "viewTime": "15", 310 | "bizScene": "BLUE_KNIGHT_PARKOUR", 311 | "accountPlan": "KB_ORCHARD", 312 | "sync": "false", 313 | "asac": "2A23C08X4VP4SVOKFBKCA9", 314 | } 315 | try: 316 | res1 = self.no_xsign_req(api, data, "1.0") 317 | if res1: 318 | if '异常' not in res1: 319 | print(f'[{self.name}] ✅任务完成成功!') 320 | else: 321 | print(f'[{self.name}] ✅任务完成出错:',res1) 322 | break 323 | else: 324 | print(f'[{self.name}] ✅任务完成失败:',res1) 325 | except Exception as e: 326 | print(f"[{self.name}] ❎请求失败:",e) 327 | return None 328 | except Exception as e: 329 | print(f"[{self.name}] ❎请求失败1") 330 | 331 | print(f"[{self.name1}] 开始获取可领取次数") 332 | api = 'mtop.ele.biz.growth.task.core.querytask' 333 | data = json.dumps({ 334 | "bizScene": "BLUE_KNIGHT_PARKOUR", 335 | "accountPlan": "HAVANA_COMMON", 336 | "missionCollectionId": "1322", 337 | "locationInfos": "[\"{\\\"lng\\\":\\\"120.220572\\\",\\\"lat\\\":\\\"30.178625\\\"}\"]" 338 | }) 339 | try: 340 | res = self.xsign_req(api, data, "1.0") 341 | if res.json()['ret'][0] == 'SUCCESS::接口调用成功': 342 | for y in res.json()['data']['mlist']: 343 | for o in y['missionStageDTOS']: 344 | if o['rewardStatus'] == "TODO" and o['status'] == "FINISH": 345 | if o['rewards'][0]['name'] == "次数": 346 | api1 = 'mtop.ele.biz.growth.task.core.receiveprize' 347 | data1 = {"bizScene": "BLUE_KNIGHT_PARKOUR", "missionCollectionId": "1322", "missionId": "23414001", 348 | "locationInfos": "[\"{\\\"lng\\\":\\\"105.754353\\\",\\\"lat\\\":\\\"30.600449\\\"}\"]", 349 | "accountPlan":"HAVANA_COMMON", 350 | "count": o['stageCount'], 351 | "asac": "2A23B18B2HYMDVFDDOXP2F"} 352 | try: 353 | res1 = self.no_xsign_req(api1, data1, "1.0") 354 | if (res1 is None) or (res1 and '异常' in res1): 355 | continue 356 | data = res1.json()["data"] 357 | if data.get('errorMsg') is not None: 358 | print(f"[{self.name}] ❎领取奖励失败: {data['errorMsg']}") 359 | else: 360 | rlist = data.get('rlist') 361 | if rlist is not None: 362 | print(f"[{self.name}] ✅领取游戏次数成功--{rlist[0]['value']}次") 363 | else: 364 | print(f"[{self.name}] ❎{res1.json()['ret'][0]}") 365 | except Exception: 366 | print(f'请求错误') 367 | return None 368 | except Exception as e: 369 | print(f"[{self.name}] ❎请求失败:",e) 370 | 371 | def query_game_info(self): 372 | api = 'mtop.alsc.playgame.mini.game.index' 373 | data = json.dumps({ 374 | "bizScene": "BLUE_KNIGHT_PARKOUR", 375 | "latitude": "30.17862595617771", 376 | "longitude": "120.22057268768549", 377 | "collectionIds": "[\"20240204214413721933320869\"]", 378 | "actId": "20240204214413716190833090" 379 | }) 380 | try: 381 | res = self.xsign_req(api, data, "1.0") 382 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 383 | if len(res.json()["data"]["data"]['propertyList']): 384 | for propertyItem in res.json()["data"]["data"]['propertyList']: 385 | if propertyItem['propertyName'] == '乐园币': 386 | print(f'[{self.name}] ✅乐园币----[{propertyItem["amount"]}]') 387 | self.propertyId = propertyItem['propertyId'] 388 | elif propertyItem['propertyName'] == '剩余奖励次数': 389 | self.gameCount = int(propertyItem['amount']) 390 | print(f'[{self.name}] ✅剩余游戏次数----[{propertyItem["amount"]}]') 391 | else: 392 | print(f"[{self.name}] ❌查询游戏信息失败,原因:{res.text}") 393 | except Exception as e: 394 | print(f"[{self.name}] ❎查询游戏信息失败") 395 | 396 | def start_game(self): 397 | api = 'mtop.alsc.playgame.mini.game.play.start' 398 | data = json.dumps({ 399 | "bizScene":"BLUE_KNIGHT_PARKOUR", 400 | "latitude": "30.17862595617771", 401 | "longitude": "120.22057268768549", 402 | "actId":"20240204214413716190833090", 403 | "gamePattern":"REWARD_PATTERN", 404 | "extParams":"{\"changeVersion\":\"20240412\"}" 405 | }) 406 | try: 407 | res = self.xsign_req(api, data, "1.0") 408 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 409 | if res.json()["data"]["data"]['curGameId']: 410 | self.curGameId = res.json()["data"]["data"]['curGameId'] 411 | self.gamePublicKey = res.json()["data"]["data"]['extInfo']['pk'] 412 | else: 413 | print(f"[{self.name}] ❌开始游戏失败,原因:",res.json()['ret'][0]) 414 | except Exception as e: 415 | print(f"[{self.name}] ❎开始游戏失败") 416 | 417 | def settle_game(self,grantAmount): 418 | api = 'mtop.alsc.playgame.mini.game.play.settle' 419 | body = { 420 | "bizScene":"BLUE_KNIGHT_PARKOUR", 421 | "latitude": "30.17862595617771", 422 | "longitude": "120.22057268768549", 423 | "curGameId":self.curGameId, 424 | "actId":"20240204214413716190833090", 425 | "grantAmount":rsa_encrypt(self.gamePublicKey, str(grantAmount)), 426 | "propertyId":self.propertyId, 427 | "extParams":"{\"changeVersion\":\"20240412\"}" 428 | } 429 | data = json.dumps(body) 430 | try: 431 | res = self.xsign_req(api, data, "1.0") 432 | if res is None: 433 | return None 434 | if res.json()["ret"][0] == "SUCCESS::调用成功": 435 | game_gold = res.json()["data"]["data"]["realGrantValue"] 436 | if game_gold: 437 | print(f"[{self.name}] ✅游戏完成,获得--{game_gold}乐园币") 438 | else: 439 | print(f"[{self.name}] ❌游戏完成,并没有获得奖励") 440 | else: 441 | if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期": 442 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 443 | return None 444 | else: 445 | print(f'[{self.name1}] ❎{res.json()["ret"][0]}') 446 | return res.json()["ret"][0] 447 | except Exception: 448 | print(f'❎请求错误') 449 | return None 450 | 451 | def main(self): 452 | if self.login(): 453 | self.query_game_info() 454 | print(f"----尝试领取游戏次数----") 455 | self.task() 456 | self.query_game_info() 457 | print(f"----尝试完成游戏----") 458 | if self.gameCount > 0: 459 | for i in range(self.gameCount): 460 | self.start_game() 461 | if self.curGameId: 462 | print(f"模拟玩一次游戏中……") 463 | settle_result = self.settle_game(25) 464 | if settle_result and '发放数量超日限制' in settle_result: 465 | break 466 | else: 467 | print(f"没有游戏次数可以玩了") 468 | 469 | 470 | if __name__ == '__main__': 471 | if 'elmck' in os.environ: 472 | cookie = os.environ.get('elmck') 473 | else: 474 | print("环境变量中不存在[elmck],启用本地变量模式") 475 | cookie = ck 476 | if cookie == "": 477 | print("本地变量为空,请设置其中一个变量后再运行") 478 | exit(-1) 479 | cookies = cookie.split("&") 480 | print(f"饿了么共获取到 {len(cookies)} 个账号") 481 | for i, ck in enumerate(cookies): 482 | print(f"======开始第{i + 1}个账号======") 483 | TYT(ck).main() 484 | print("2s后进行下一个账号") 485 | time.sleep(2) 486 | -------------------------------------------------------------------------------- /lyb.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import os 3 | import time 4 | import json 5 | import requests 6 | from urllib.parse import quote, urlencode 7 | 8 | host = 'https://acs.m.goofish.com' 9 | 10 | ck = '' 11 | 12 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 13 | """ 14 | 合并带_m_h5_tk 15 | """ 16 | txt = cookie_str.replace(" ", "") 17 | if txt[-1] != ';': 18 | txt += ';' 19 | cookie_parts = txt.split(';')[:-1] 20 | updated = False 21 | for i, part in enumerate(cookie_parts): 22 | key_value = part.split('=') 23 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 24 | cookie_parts[i] = tk_cookie 25 | updated = True 26 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 27 | cookie_parts[i] = enc_cookie 28 | updated = True 29 | 30 | if updated: 31 | return ';'.join(cookie_parts) + ';' 32 | else: 33 | return txt + tk_cookie + ';' + enc_cookie + ';' 34 | 35 | 36 | def tq(cookie_string): 37 | """ 38 | 获取_m_h5_tk 39 | """ 40 | if not cookie_string: 41 | return '-1' 42 | cookie_pairs = cookie_string.split(';') 43 | for pair in cookie_pairs: 44 | key_value = pair.split('=') 45 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 46 | return key_value[1] 47 | return '-1' 48 | 49 | 50 | def tq1(txt): 51 | """ 52 | 拆分cookie 53 | """ 54 | try: 55 | txt = txt.replace(" ", "") 56 | if txt[-1] != ';': 57 | txt += ';' 58 | pairs = txt.split(";")[:-1] 59 | ck_json = {} 60 | for pair in pairs: 61 | key, value = pair.split("=", 1) 62 | ck_json[key] = value 63 | return ck_json 64 | except Exception as e: 65 | print(f'❎Cookie解析错误: {e}') 66 | return {} 67 | 68 | 69 | def md5(text): 70 | """ 71 | md5加密 72 | """ 73 | hash_md5 = hashlib.md5() 74 | hash_md5.update(text.encode()) 75 | return hash_md5.hexdigest() 76 | 77 | 78 | def check_cookie(cookie): 79 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 80 | headers = { 81 | "Cookie": cookie, 82 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 83 | } 84 | 85 | try: 86 | response = requests.get(url, headers=headers) 87 | if response.status_code == 200: 88 | cookie_jar = response.cookies 89 | token = cookie_jar.get('_m_h5_tk', '') 90 | token_cookie = "_m_h5_tk=" + token 91 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 92 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 93 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 94 | return cookie 95 | else: 96 | return None 97 | except Exception as e: 98 | print("解析ck错误") 99 | return None 100 | 101 | 102 | class LYB: 103 | def __init__(self, cki): 104 | self.ck = cki 105 | self.name = None 106 | self.cki = self.tq(cki) 107 | self.uid = self.cki.get("unb") 108 | self.sid = self.cki.get("cookie2") 109 | self.name1 = self.uid 110 | 111 | def tq(self, txt): 112 | try: 113 | txt = txt.replace(" ", "") 114 | pairs = txt.split(";")[:-1] 115 | ck_json = {} 116 | for i in pairs: 117 | ck_json[i.split("=")[0]] = i.split("=")[1] 118 | return ck_json 119 | except Exception as e: 120 | print(f'❎Cookie解析错误: {e}') 121 | return {} 122 | 123 | def xsign(self, api, data, wua, v): 124 | body = { 125 | "data": data, 126 | "api": api, 127 | "pageId": '', 128 | "uid": self.uid, 129 | 'sid': self.sid, 130 | "deviceId": '', 131 | "utdid": '', 132 | "wua": wua, 133 | 'ttid': '1551089129819@eleme_android_10.14.3', 134 | "v": v 135 | } 136 | 137 | try: 138 | r = requests.post( 139 | "http://192.168.1.124:1777/api/getXSign", 140 | json=body 141 | ) 142 | r.raise_for_status() 143 | return r.json() 144 | except requests.exceptions.HTTPError as e: 145 | print(f'❎请求签名服务器失败: {e}') 146 | return None 147 | except requests.exceptions.RequestException as e: 148 | print(f'❎请求签名服务器错误: {e}') 149 | return None 150 | 151 | def req1(self, api, data, wua='False', v="1.0"): 152 | try: 153 | if type(data) == dict: 154 | data = json.dumps(data) 155 | wua = str(wua) 156 | sign = self.xsign(api, data, wua, v) 157 | url = f"{host}/gw/{api}/{v}/" 158 | headers = { 159 | "x-sgext": quote(sign.get('x-sgext')), 160 | "x-sign": quote(sign.get('x-sign')), 161 | 'x-sid': self.sid, 162 | 'x-uid': self.uid, 163 | 'x-pv': '6.3', 164 | 'x-features': '1051', 165 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 166 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 167 | 'x-t': sign.get('x-t'), 168 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 169 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 170 | 'x-utdid': '', 171 | 'x-appkey': '24895413', 172 | 'x-devid': '', 173 | } 174 | 175 | params = {"data": data} 176 | if 'wua' in sign: 177 | params["wua"] = sign.get('wua') 178 | 179 | max_retries = 5 180 | retries = 0 181 | while retries < max_retries: 182 | try: 183 | res = requests.post(url, headers=headers, data=params, timeout=5) 184 | return res 185 | except requests.exceptions.Timeout: 186 | print("❎接口请求超时") 187 | except requests.exceptions.RequestException as e: 188 | print(f"❎请求异常: {e}") 189 | retries += 1 190 | print(f"❎重试次数: {retries}") 191 | if retries >= max_retries: 192 | print("❎重试次数上限") 193 | return None 194 | except Exception as e: 195 | print(f'❎请求接口失败: {e}') 196 | return None 197 | 198 | def req(self, api, data, v="1.0"): 199 | try: 200 | cookie = check_cookie(self.ck) 201 | headers = { 202 | "authority": "shopping.ele.me", 203 | "accept": "application/json", 204 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 205 | "cache-control": "no-cache", 206 | "content-type": "application/x-www-form-urlencoded", 207 | "cookie": cookie, 208 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 209 | } 210 | timestamp = int(time.time() * 1000) 211 | data_str = json.dumps(data) 212 | token = tq(cookie) 213 | token_part = token.split("_")[0] 214 | 215 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 216 | sign = md5(sign_str) 217 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json" 218 | data1 = urlencode({'data': data_str}) 219 | r = requests.post(url, headers=headers, data=data1) 220 | if r: 221 | return r 222 | else: 223 | return None 224 | except Exception as e: 225 | return None 226 | 227 | def login(self): 228 | api1 = 'mtop.alsc.user.detail.query' 229 | data1 = {} 230 | try: 231 | res1 = self.req(api1, data1, "1.0") 232 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 233 | self.name = res1.json()["data"]["encryptMobile"] 234 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 235 | data = {"templateIds": "[\"1404\"]"} 236 | try: 237 | res = self.req(api, data, "1.0") 238 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 239 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 240 | return True 241 | else: 242 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 243 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 244 | return False 245 | else: 246 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 247 | return False 248 | except Exception as e: 249 | print(f"[{self.name1}] ❎登录失败: {e}") 250 | return False 251 | else: 252 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 253 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 254 | return False 255 | else: 256 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 257 | return False 258 | except Exception as e: 259 | print(f"[{self.name1}] ❎登录失败: {e}") 260 | return False 261 | 262 | def sign(self): 263 | api = 'mtop.ele.biz.growth.task.event.pageview' 264 | data = {"collectionId": "1380", "missionId": "23778002", "actionCode": "PAGEVIEW", 265 | "pageFrom": "a13.b_activity_kb_m71293", "viewTime": "15", "bizScene": "game_center_signin", 266 | "accountPlan": "KB_ORCHARD", "sync": "true", "asac": "2A24112EX1QYGWU29IXM1H"} 267 | try: 268 | res = self.req(api, data, "1.0") 269 | if res.json()["ret"][0] == 'SUCCESS::接口调用成功': 270 | print(f'[{self.name}] ✅签到成功') 271 | else: 272 | if res.json()["ret"][0] == '405::行为受限': 273 | print(f"[{self.name}] ❎翻倍奖励签到失败,尝试普通签到") 274 | api1 = 'mtop.koubei.interactioncenter.sign.component.recordsignin' 275 | data1 = {"bizScene": "game_center_signin", "copyId": "20240530133724118306801071", 276 | "extInfo": "{\"prizeId\":\"11\"}", "longitude": "99.05759390443563", 277 | "latitude": "99.69377588108182", 278 | "locationInfos": "[\"{\\\"lng\\\":\\\"99.05759390443563\\\",\\\"lat\\\":\\\"99.69377588108182\\\"}\"]"} 279 | try: 280 | res1 = self.req(api1, data1, "1.0") 281 | if res.json()["ret"][0] == 'SUCCESS::接口调用成功': 282 | amount = res1.json()['data']['data']['totalReward'][0]['prizeValue'] 283 | print(f'[{self.name}] ✅签到成功,获得--[{amount}]乐园币') 284 | else: 285 | print(f'[{self.name}] ❌签到失败,原因:{res1.json()["ret"][0]}') 286 | except Exception as e: 287 | print(f"[{self.name}] ❎签到失败: {e}") 288 | else: 289 | print(f'[{self.name}] ❌签到失败,原因:{res.json()["ret"][0]}') 290 | except Exception as e: 291 | print(f"[{self.name}] ❎签到失败: {e}") 292 | 293 | def task(self): 294 | api = 'mtop.ele.biz.growth.task.core.querytask' 295 | data = json.dumps({ 296 | "missionCollectionId": "839", 297 | "locationInfos": "[\"{\\\"lng\\\":\\\"99.75325090438128\\\",\\\"lat\\\":\\\"99.597472842782736\\\"}\"]", 298 | "bizScene": "game_center", 299 | "accountPlan": "HAVANA_COMMON" 300 | }) 301 | try: 302 | res = self.req1(api, data, 'False', "1.0") 303 | if res.json()["ret"][0] == 'SUCCESS::接口调用成功': 304 | for y in res.json()['data']['mlist']: 305 | if y['name'] != "邀请好友助力": 306 | for o in y['missionStageDTOS']: 307 | if o['rewardStatus'] == "TODO" or o['status'] == "RUNNING": 308 | api = 'mtop.ele.biz.growth.task.event.pageview' 309 | data = { 310 | "sync": "true", 311 | "collectionId": "839", 312 | "missionId": y['missionDefId'], 313 | "bizScene": "game_center", 314 | "asac": "2A24112EX1QYGWU29IXM1H", 315 | "actionCode": "PAGEVIEW", 316 | "accountPlan": "HAVANA_COMMON" 317 | } 318 | try: 319 | res = self.req(api, data, "1.0") 320 | if res.json()["ret"][0] == 'SUCCESS::接口调用成功': 321 | print(f"[{self.name}] ✅任务完成") 322 | if y['missionDefId'] == '14612001': 323 | count = '5' 324 | else: 325 | count = '1' 326 | api = 'mtop.ele.biz.growth.task.core.receiveprize' 327 | data = { 328 | "missionCollectionId": "839", 329 | "missionId": y['missionDefId'], 330 | "locationInfos": "[\"{\\\"lng\\\":\\\"99.20328782498837\\\",\\\"lat\\\":\\\"99.88705499842763\\\"}\"]", 331 | "bizScene": "game_center", 332 | "accountPlan": "HAVANA_COMMON", 333 | "count": count 334 | } 335 | try: 336 | res = self.req(api, data, "1.0") 337 | if res.json()["ret"][0] == 'SUCCESS::接口调用成功': 338 | amount = res.json()["data"]["rlist"][0]["value"] 339 | print(f"[{self.name}] ✅领取奖励成功,获得--[{amount}]乐园币") 340 | else: 341 | print(f"[{self.name}] ❌领取奖励失败,原因:[{res.json()['ret'][0]}]") 342 | except Exception as e: 343 | print(f"[{self.name}] ❌领取奖励失败: {e}") 344 | else: 345 | print(f"[{self.name}] ❌任务失败,原因:{res.json()['ret'][0]}") 346 | except Exception as e: 347 | print(f"[{self.name}] ❌任务失败: {e}") 348 | else: 349 | print(f"[{self.name}] ❌获取列表失败,原因:{res.json()['ret'][0]}") 350 | except Exception as e: 351 | print(f"[{self.name}] ❌获取列表失败: {e}") 352 | 353 | def main(self): 354 | try: 355 | if self.login(): 356 | self.sign() 357 | self.task() 358 | except Exception as e: 359 | print(f"❌任务失败: {e}") 360 | 361 | 362 | if __name__ == '__main__': 363 | if 'elmck' in os.environ: 364 | cookie = os.environ.get('elmck') 365 | else: 366 | print("环境变量中不存在[elmck],启用本地变量模式") 367 | cookie = ck 368 | if cookie == "": 369 | print("本地变量为空,请设置其中一个变量后再运行") 370 | exit(-1) 371 | cookies = cookie.split("&") 372 | print(f"饿了么共获取到 {len(cookies)} 个账号") 373 | for i, ck in enumerate(cookies): 374 | print(f"======开始第{i + 1}个账号======") 375 | LYB(ck).main() 376 | print("2s后进行下一个账号") 377 | time.sleep(2) 378 | -------------------------------------------------------------------------------- /ql.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const got = require('got'); 4 | require('dotenv').config(); 5 | const { readFile } = require('fs/promises'); 6 | const path = require('path'); 7 | 8 | const qlDir = '/ql'; 9 | const fs = require('fs'); 10 | let Fileexists = fs.existsSync('/ql/data/config/auth.json'); 11 | let authFile=""; 12 | if (Fileexists) 13 | authFile="/ql/data/config/auth.json" 14 | else 15 | authFile="/ql/config/auth.json" 16 | //const authFile = path.join(qlDir, 'config/auth.json'); 17 | 18 | const api = got.extend({ 19 | prefixUrl: 'http://127.0.0.1:5700', 20 | retry: { limit: 0 }, 21 | }); 22 | 23 | async function getToken() { 24 | const authConfig = JSON.parse(await readFile(authFile)); 25 | return authConfig.token; 26 | } 27 | 28 | module.exports.getEnvs = async (envName='elmck') => { 29 | const token = await getToken(); 30 | const body = await api({ 31 | url: 'api/envs', 32 | searchParams: { 33 | searchValue: envName, 34 | t: Date.now(), 35 | }, 36 | headers: { 37 | Accept: 'application/json', 38 | authorization: `Bearer ${token}`, 39 | }, 40 | }).json(); 41 | return body.data; 42 | }; 43 | 44 | async function getEnvsByName(name){ 45 | const token = await getToken(); 46 | const body = await api({ 47 | url: 'api/envs', 48 | searchParams: { 49 | searchValue: name, 50 | t: Date.now(), 51 | }, 52 | headers: { 53 | Accept: 'application/json', 54 | authorization: `Bearer ${token}`, 55 | }, 56 | }).json(); 57 | return body.data; 58 | } 59 | 60 | module.exports.getEnvsByName = getEnvsByName 61 | 62 | module.exports.getEnvsCount = async () => { 63 | const data = await this.getEnvs(); 64 | return data.length; 65 | }; 66 | 67 | module.exports.addEnv = async (cookie, remarks) => { 68 | const token = await getToken(); 69 | const body = await api({ 70 | method: 'post', 71 | url: 'api/envs', 72 | params: { t: Date.now() }, 73 | json: [{ 74 | name: 'elmck', 75 | value: cookie, 76 | remarks, 77 | }], 78 | headers: { 79 | Accept: 'application/json', 80 | authorization: `Bearer ${token}`, 81 | 'Content-Type': 'application/json;charset=UTF-8', 82 | }, 83 | }).json(); 84 | return body; 85 | }; 86 | 87 | module.exports.updateEnv = async (cookie, eid, remarks,envName='elmck') => { 88 | const token = await getToken(); 89 | const body = await api({ 90 | method: 'put', 91 | url: 'api/envs', 92 | params: { t: Date.now() }, 93 | json: { 94 | name: envName, 95 | value: cookie, 96 | _id: eid, 97 | remarks, 98 | }, 99 | headers: { 100 | Accept: 'application/json', 101 | authorization: `Bearer ${token}`, 102 | 'Content-Type': 'application/json;charset=UTF-8', 103 | }, 104 | }).json(); 105 | return body; 106 | }; 107 | 108 | module.exports.updateEnv11 = async (cookie, eid, remarks,envName='elmck') => { 109 | const token = await getToken(); 110 | const body = await api({ 111 | method: 'put', 112 | url: 'api/envs', 113 | params: { t: Date.now() }, 114 | json: { 115 | name: envName, 116 | value: cookie, 117 | id: eid, 118 | remarks, 119 | }, 120 | headers: { 121 | Accept: 'application/json', 122 | authorization: `Bearer ${token}`, 123 | 'Content-Type': 'application/json;charset=UTF-8', 124 | }, 125 | }).json(); 126 | return body; 127 | }; 128 | 129 | module.exports.DisableCk = async (eid) => { 130 | const token = await getToken(); 131 | const body = await api({ 132 | method: 'put', 133 | url: 'api/envs/disable', 134 | params: { t: Date.now() }, 135 | body: JSON.stringify([eid]), 136 | headers: { 137 | Accept: 'application/json', 138 | authorization: `Bearer ${token}`, 139 | 'Content-Type': 'application/json;charset=UTF-8', 140 | }, 141 | }).json(); 142 | return body; 143 | }; 144 | 145 | module.exports.EnableCk = async (eid) => { 146 | const token = await getToken(); 147 | const body = await api({ 148 | method: 'put', 149 | url: 'api/envs/enable', 150 | params: { t: Date.now() }, 151 | body: JSON.stringify([eid]), 152 | headers: { 153 | Accept: 'application/json', 154 | authorization: `Bearer ${token}`, 155 | 'Content-Type': 'application/json;charset=UTF-8', 156 | }, 157 | }).json(); 158 | return body; 159 | }; 160 | 161 | module.exports.getstatus = async(eid) => { 162 | var envs = await getEnvsByName('elmck'); 163 | var tempid = 0; 164 | for (let i = 0; i < envs.length; i++) { 165 | tempid = 0; 166 | if (envs[i]._id) { 167 | tempid = envs[i]._id; 168 | } 169 | if (envs[i].id) { 170 | tempid = envs[i].id; 171 | } 172 | if (tempid == eid) { 173 | return envs[i].status; 174 | } 175 | } 176 | return 99; 177 | }; 178 | 179 | module.exports.getEnvById = async(eid) => { 180 | const envs = await this.getEnvs(); 181 | var tempid = 0; 182 | for (let i = 0; i < envs.length; i++) { 183 | tempid = 0; 184 | if (envs[i]._id) { 185 | tempid = envs[i]._id; 186 | } 187 | if (envs[i].id) { 188 | tempid = envs[i].id; 189 | } 190 | if (tempid == eid) { 191 | return envs[i].value; 192 | } 193 | } 194 | return ""; 195 | }; 196 | 197 | module.exports.getEnvByUserId = async (userId) => { 198 | const envs = await this.getEnvs('ZL_CK'); 199 | 200 | for (let i = 0; i < envs.length; i++) { 201 | let ck = envs[i].value 202 | const user_id = ck.match(/USERID=([^; ]+)(?=;?)/) ? ck.match(/USERID=([^; ]+)(?=;?)/)[0] : '123'; 203 | 204 | if (user_id.indexOf(userId)!==-1) { 205 | return envs[i] 206 | } 207 | } 208 | return ""; 209 | }; 210 | 211 | module.exports.delEnv = async (eid) => { 212 | const token = await getToken(); 213 | const body = await api({ 214 | method: 'delete', 215 | url: 'api/envs', 216 | params: { t: Date.now() }, 217 | body: JSON.stringify([eid]), 218 | headers: { 219 | Accept: 'application/json', 220 | authorization: `Bearer ${token}`, 221 | 'Content-Type':'application/json;charset=UTF-8', 222 | }, 223 | }).json(); 224 | return body; 225 | }; 226 | -------------------------------------------------------------------------------- /ql1.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const got = require('got'); 4 | require('dotenv').config(); 5 | const { readFile } = require('fs/promises'); 6 | const path = require('path'); 7 | 8 | const qlDir = '/ql'; 9 | const fs = require('fs'); 10 | let Fileexists = fs.existsSync('/ql/data/config/auth.json'); 11 | let authFile=""; 12 | if (Fileexists) 13 | authFile="/ql/data/config/auth.json" 14 | else 15 | authFile="/ql/config/auth.json" 16 | //const authFile = path.join(qlDir, 'config/auth.json'); 17 | 18 | const api = got.extend({ 19 | prefixUrl: 'http://127.0.0.1:5700', 20 | retry: { limit: 0 }, 21 | }); 22 | 23 | async function getToken() { 24 | const authConfig = JSON.parse(await readFile(authFile)); 25 | return authConfig.token; 26 | } 27 | 28 | module.exports.getEnvs = async (envName='ZL_CK') => { 29 | const token = await getToken(); 30 | const body = await api({ 31 | url: 'api/envs', 32 | searchParams: { 33 | searchValue: envName, 34 | t: Date.now(), 35 | }, 36 | headers: { 37 | Accept: 'application/json', 38 | authorization: `Bearer ${token}`, 39 | }, 40 | }).json(); 41 | return body.data; 42 | }; 43 | 44 | async function getEnvsByName(name){ 45 | const token = await getToken(); 46 | const body = await api({ 47 | url: 'api/envs', 48 | searchParams: { 49 | searchValue: name, 50 | t: Date.now(), 51 | }, 52 | headers: { 53 | Accept: 'application/json', 54 | authorization: `Bearer ${token}`, 55 | }, 56 | }).json(); 57 | return body.data; 58 | } 59 | 60 | module.exports.getEnvsByName = getEnvsByName 61 | 62 | module.exports.getEnvsCount = async () => { 63 | const data = await this.getEnvs(); 64 | return data.length; 65 | }; 66 | 67 | module.exports.addEnv = async (cookie, remarks) => { 68 | const token = await getToken(); 69 | const body = await api({ 70 | method: 'post', 71 | url: 'api/envs', 72 | params: { t: Date.now() }, 73 | json: [{ 74 | name: 'ZL_CK', 75 | value: cookie, 76 | remarks, 77 | }], 78 | headers: { 79 | Accept: 'application/json', 80 | authorization: `Bearer ${token}`, 81 | 'Content-Type': 'application/json;charset=UTF-8', 82 | }, 83 | }).json(); 84 | return body; 85 | }; 86 | 87 | module.exports.updateEnv = async (cookie, eid, remarks,envName='ZL_CK') => { 88 | const token = await getToken(); 89 | const body = await api({ 90 | method: 'put', 91 | url: 'api/envs', 92 | params: { t: Date.now() }, 93 | json: { 94 | name: envName, 95 | value: cookie, 96 | _id: eid, 97 | remarks, 98 | }, 99 | headers: { 100 | Accept: 'application/json', 101 | authorization: `Bearer ${token}`, 102 | 'Content-Type': 'application/json;charset=UTF-8', 103 | }, 104 | }).json(); 105 | return body; 106 | }; 107 | 108 | module.exports.updateEnv11 = async (cookie, eid, remarks,envName='ZL_CK') => { 109 | const token = await getToken(); 110 | const body = await api({ 111 | method: 'put', 112 | url: 'api/envs', 113 | params: { t: Date.now() }, 114 | json: { 115 | name: envName, 116 | value: cookie, 117 | id: eid, 118 | remarks, 119 | }, 120 | headers: { 121 | Accept: 'application/json', 122 | authorization: `Bearer ${token}`, 123 | 'Content-Type': 'application/json;charset=UTF-8', 124 | }, 125 | }).json(); 126 | return body; 127 | }; 128 | 129 | module.exports.DisableCk = async (eid) => { 130 | const token = await getToken(); 131 | const body = await api({ 132 | method: 'put', 133 | url: 'api/envs/disable', 134 | params: { t: Date.now() }, 135 | body: JSON.stringify([eid]), 136 | headers: { 137 | Accept: 'application/json', 138 | authorization: `Bearer ${token}`, 139 | 'Content-Type': 'application/json;charset=UTF-8', 140 | }, 141 | }).json(); 142 | return body; 143 | }; 144 | 145 | module.exports.EnableCk = async (eid) => { 146 | const token = await getToken(); 147 | const body = await api({ 148 | method: 'put', 149 | url: 'api/envs/enable', 150 | params: { t: Date.now() }, 151 | body: JSON.stringify([eid]), 152 | headers: { 153 | Accept: 'application/json', 154 | authorization: `Bearer ${token}`, 155 | 'Content-Type': 'application/json;charset=UTF-8', 156 | }, 157 | }).json(); 158 | return body; 159 | }; 160 | 161 | module.exports.getstatus = async(eid) => { 162 | var envs = await getEnvsByName('ZL_CK'); 163 | var tempid = 0; 164 | for (let i = 0; i < envs.length; i++) { 165 | tempid = 0; 166 | if (envs[i]._id) { 167 | tempid = envs[i]._id; 168 | } 169 | if (envs[i].id) { 170 | tempid = envs[i].id; 171 | } 172 | if (tempid == eid) { 173 | return envs[i].status; 174 | } 175 | } 176 | return 99; 177 | }; 178 | 179 | module.exports.getEnvById = async(eid) => { 180 | const envs = await this.getEnvs(); 181 | var tempid = 0; 182 | for (let i = 0; i < envs.length; i++) { 183 | tempid = 0; 184 | if (envs[i]._id) { 185 | tempid = envs[i]._id; 186 | } 187 | if (envs[i].id) { 188 | tempid = envs[i].id; 189 | } 190 | if (tempid == eid) { 191 | return envs[i].value; 192 | } 193 | } 194 | return ""; 195 | }; 196 | 197 | module.exports.getEnvByUserId = async (userId) => { 198 | const envs = await this.getEnvs('ZL_CK'); 199 | 200 | for (let i = 0; i < envs.length; i++) { 201 | let ck = envs[i].value 202 | const user_id = ck.match(/USERID=([^; ]+)(?=;?)/) ? ck.match(/USERID=([^; ]+)(?=;?)/)[0] : '123'; 203 | 204 | if (user_id.indexOf(userId)!==-1) { 205 | return envs[i] 206 | } 207 | } 208 | return ""; 209 | }; 210 | 211 | module.exports.delEnv = async (eid) => { 212 | const token = await getToken(); 213 | const body = await api({ 214 | method: 'delete', 215 | url: 'api/envs', 216 | params: { t: Date.now() }, 217 | body: JSON.stringify([eid]), 218 | headers: { 219 | Accept: 'application/json', 220 | authorization: `Bearer ${token}`, 221 | 'Content-Type':'application/json;charset=UTF-8', 222 | }, 223 | }).json(); 224 | return body; 225 | }; 226 | -------------------------------------------------------------------------------- /tcs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import time 4 | import datetime 5 | import requests 6 | from urllib.parse import urlencode, quote 7 | import hashlib 8 | import json 9 | import random 10 | import string 11 | 12 | host = 'https://acs.m.goofish.com' 13 | 14 | ck = '' 15 | 16 | 17 | def generate_random_string(length=50): 18 | return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) 19 | 20 | 21 | def reorder_ck(s: str) -> str: 22 | order = ["cookie2", "sgcookie", "unb", "USERID", "SID", "token", "utdid", "deviceId", "umt"] 23 | cookies = s.split(';') 24 | cookie_dict = {} 25 | for cookie in cookies: 26 | key_value = cookie.split('=', 1) 27 | if len(key_value) == 2: 28 | key, value = key_value 29 | cookie_dict[key.strip()] = value.strip() 30 | reordered_cookies = [] 31 | for key in order: 32 | if key in cookie_dict: 33 | reordered_cookies.append(f"{key}={cookie_dict[key]}") 34 | return ';'.join(reordered_cookies) + ';' 35 | 36 | 37 | def get_ck_usid(ck1): 38 | key_value_pairs = ck1.split(";") 39 | for pair in key_value_pairs: 40 | key, value = pair.split("=") 41 | if key == "USERID": 42 | return value 43 | else: 44 | return '账号' 45 | 46 | def hbh5tk(tk_cookie, enc_cookie, cookie_str): 47 | """ 48 | 合并带_m_h5_tk 49 | """ 50 | txt = cookie_str.replace(" ", "") 51 | txt = txt.replace("chushi;", "") 52 | if txt[-1] != ';': 53 | txt += ';' 54 | cookie_parts = txt.split(';')[:-1] 55 | updated = False 56 | for i, part in enumerate(cookie_parts): 57 | key_value = part.split('=') 58 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 59 | cookie_parts[i] = tk_cookie 60 | updated = True 61 | elif key_value[0].strip() in ["_m_h5_tk_enc", " _m_h5_tk_enc"]: 62 | cookie_parts[i] = enc_cookie 63 | updated = True 64 | 65 | if updated: 66 | return ';'.join(cookie_parts) + ';' 67 | else: 68 | return txt + tk_cookie + ';' + enc_cookie + ';' 69 | 70 | 71 | def tq(cookie_string): 72 | """ 73 | 获取_m_h5_tk 74 | """ 75 | if not cookie_string: 76 | return '-1' 77 | cookie_pairs = cookie_string.split(';') 78 | for pair in cookie_pairs: 79 | key_value = pair.split('=') 80 | if key_value[0].strip() in ["_m_h5_tk", " _m_h5_tk"]: 81 | return key_value[1] 82 | return '-1' 83 | 84 | 85 | def tq1(txt): 86 | """ 87 | 拆分cookie 88 | """ 89 | try: 90 | txt = txt.replace(" ", "") 91 | if txt[-1] != ';': 92 | txt += ';' 93 | pairs = txt.split(";")[:-1] 94 | ck_json = {} 95 | for pair in pairs: 96 | key, value = pair.split("=", 1) 97 | ck_json[key] = value 98 | return ck_json 99 | except Exception as e: 100 | print(f'❎Cookie解析错误: {e}') 101 | return {} 102 | 103 | 104 | def md5(text): 105 | """ 106 | md5加密 107 | """ 108 | hash_md5 = hashlib.md5() 109 | hash_md5.update(text.encode()) 110 | return hash_md5.hexdigest() 111 | 112 | 113 | def check_cookie(cookie): 114 | url = "https://waimai-guide.ele.me/h5/mtop.alsc.personal.queryminecenter/1.0/?jsv=2.6.2&appKey=12574478" 115 | headers = { 116 | "Cookie": cookie, 117 | "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36" 118 | } 119 | 120 | try: 121 | response = requests.get(url, headers=headers) 122 | if response.status_code == 200: 123 | cookie_jar = response.cookies 124 | token = cookie_jar.get('_m_h5_tk', '') 125 | token_cookie = "_m_h5_tk=" + token 126 | enc_token = cookie_jar.get('_m_h5_tk_enc', '') 127 | enc_token_cookie = "_m_h5_tk_enc=" + enc_token 128 | cookie = hbh5tk(token_cookie, enc_token_cookie, cookie) 129 | return cookie 130 | else: 131 | return None 132 | except Exception as e: 133 | print("解析ck错误") 134 | return None 135 | 136 | 137 | class TCS: 138 | def __init__(self, cki): 139 | self.stop = False 140 | self.ck = cki 141 | self.players = [] 142 | self.name = None 143 | self.openId = None 144 | self.gameId = None 145 | self.gameToken = None 146 | self.cki = self.tq(cki) 147 | self.uid = self.cki.get("unb") 148 | self.sid = self.cki.get("cookie2") 149 | self.name1 = get_ck_usid(cki) 150 | 151 | def tq(self, txt): 152 | try: 153 | txt = txt.replace(" ", "") 154 | pairs = txt.split(";")[:-1] 155 | ck_json = {} 156 | for i in pairs: 157 | ck_json[i.split("=")[0]] = i.split("=")[1] 158 | return ck_json 159 | except Exception as e: 160 | print(f'❎Cookie解析错误: {e}') 161 | return {} 162 | 163 | def xsign(self, api, data, uid, sid, wua, v): 164 | body = { 165 | "data": data, 166 | "api": api, 167 | "pageId": '', 168 | "uid": uid, 169 | 'sid': sid, 170 | "deviceId": '', 171 | "utdid": '', 172 | "wua": wua, 173 | 'ttid': '1551089129819@eleme_android_10.14.3', 174 | "v": v 175 | } 176 | 177 | try: 178 | r = requests.post( 179 | "http://127.0.0.1:18848/api/getXSign", 180 | json=body 181 | ) 182 | r.raise_for_status() 183 | return r.json() 184 | except requests.exceptions.HTTPError as e: 185 | print(f'❎请求签名服务器失败: {e}') 186 | return None 187 | except requests.exceptions.RequestException as e: 188 | print(f'❎请求签名服务器错误: {e}') 189 | return None 190 | 191 | def req1(self, api, data, uid, sid, wua='False', v="1.0"): 192 | try: 193 | if type(data) == dict: 194 | data = json.dumps(data) 195 | wua = str(wua) 196 | sign = self.xsign(api, data, uid, sid, wua, v) 197 | url = f"{host}/gw/{api}/{v}/" 198 | headers = { 199 | "x-sgext": quote(sign.get('x-sgext')), 200 | "x-sign": quote(sign.get('x-sign')), 201 | 'x-sid': sid, 202 | 'x-uid': uid, 203 | 'x-pv': '6.3', 204 | 'x-features': '1051', 205 | 'x-mini-wua': quote(sign.get('x-mini-wua')), 206 | 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8', 207 | 'x-t': sign.get('x-t'), 208 | 'x-extdata': 'openappkey%3DDEFAULT_AUTH', 209 | 'x-ttid': '1551089129819@eleme_android_10.14.3', 210 | 'x-utdid': '', 211 | 'x-appkey': '24895413', 212 | 'x-devid': '', 213 | } 214 | 215 | params = {"data": data} 216 | if 'wua' in sign: 217 | params["wua"] = sign.get('wua') 218 | 219 | max_retries = 5 220 | retries = 0 221 | while retries < max_retries: 222 | try: 223 | res = requests.post(url, headers=headers, data=params, timeout=5) 224 | return res 225 | except requests.exceptions.Timeout: 226 | print("❎接口请求超时") 227 | except requests.exceptions.RequestException as e: 228 | print(f"❎请求异常: {e}") 229 | retries += 1 230 | print(f"❎重试次数: {retries}") 231 | if retries >= max_retries: 232 | print("❎重试次数上限") 233 | return None 234 | except Exception as e: 235 | print(f'❎请求接口失败: {e}') 236 | return None 237 | 238 | def req(self, api, data, v="1.0"): 239 | try: 240 | cookie = check_cookie(self.ck) 241 | headers = { 242 | "authority": "shopping.ele.me", 243 | "accept": "application/json", 244 | "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7", 245 | "cache-control": "no-cache", 246 | "content-type": "application/x-www-form-urlencoded", 247 | "cookie": cookie, 248 | "user-agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Mobile Safari/537.36" 249 | } 250 | timestamp = int(time.time() * 1000) 251 | data_str = json.dumps(data) 252 | token = tq(cookie) 253 | token_part = token.split("_")[0] 254 | 255 | sign_str = f"{token_part}&{timestamp}&12574478&{data_str}" 256 | sign = md5(sign_str) 257 | url = f"https://guide-acs.m.taobao.com/h5/{api}/{v}/?jsv=2.6.1&appKey=12574478&t={timestamp}&sign={sign}&api={api}&v={v}&type=originaljson&dataType=json" 258 | data1 = urlencode({'data': data_str}) 259 | r = requests.post(url, headers=headers, data=data1) 260 | if r: 261 | return r 262 | else: 263 | return None 264 | except Exception as e: 265 | return None 266 | 267 | def login(self): 268 | api1 = 'mtop.alsc.user.detail.query' 269 | data1 = {} 270 | try: 271 | res1 = self.req(api1, data1, "1.0") 272 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 273 | self.name = res1.json()["data"]["encryptMobile"] 274 | api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2' 275 | data = {"templateIds": "[\"1404\"]"} 276 | try: 277 | res = self.req(api, data, "1.0") 278 | if res.json()['ret'][0] == 'SUCCESS::调用成功': 279 | print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]') 280 | return True 281 | else: 282 | if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 283 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 284 | return False 285 | else: 286 | print(f'[{self.name1}] ❌登录失败,原因:{res.text}') 287 | return False 288 | except Exception as e: 289 | print(f"[{self.name1}] ❎登录失败: {e}") 290 | return False 291 | else: 292 | if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期': 293 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 294 | return False 295 | else: 296 | print(f'[{self.name1}] ❌登录失败,原因:{res1.text}') 297 | return False 298 | except Exception as e: 299 | print(f"[{self.name1}] ❎登录失败: {e}") 300 | return False 301 | 302 | def getOpenId(self): 303 | api1 = 'mtop.alsc.playgame.mini.game.dispatch' 304 | data1 = { 305 | "bizMethod": "/init/init", 306 | "bizScene": "GREEDY_SNAKE", 307 | "bizParam": "{}" 308 | } 309 | try: 310 | res1 = self.req(api1, data1, "1.0") 311 | if res1.json()['ret'][0] == 'SUCCESS::调用成功': 312 | nested_data = json.loads(res1.json()["data"]["data"]) 313 | self.openId = nested_data['openId'] 314 | return True 315 | else: 316 | print(f'[{self.name1}] ❌获取Openid失败,原因:{res1.text}') 317 | return False 318 | except Exception as e: 319 | print(f"[{self.name1}] ❌获取Openid失败,原因: {e}") 320 | return False 321 | 322 | def startgame(self): 323 | api = 'mtop.alsc.playgame.mini.game.dispatch' 324 | data = { 325 | "bizMethod": "/game/start", 326 | "bizScene": "GREEDY_SNAKE", 327 | "bizParam": "{}" 328 | } 329 | try: 330 | res = self.req(api, data, "1.0") 331 | if res is None: 332 | return None 333 | if res.json()["ret"][0] == "SUCCESS::调用成功": 334 | resJson = json.loads(res.json()['data']['data']).get('players') 335 | self.players = resJson 336 | pattern = r'"gameId":"(\w+)"' 337 | pattern2 = r'"gameToken":"(\w+)"' 338 | match = re.search(pattern, str(res.json())) 339 | match2 = re.search(pattern2, str(res.json())) 340 | if match: 341 | self.gameId = match.group(1) 342 | self.gameToken = match2.group(1) 343 | return True 344 | else: 345 | print("❎解析数据失败") 346 | return None 347 | else: 348 | if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期": 349 | print(f"[{self.name1}] ❎cookie已过期,请重新获取") 350 | return None 351 | else: 352 | print(f'[{self.name1}] ❎{res.json()["ret"][0]}') 353 | return None 354 | except Exception: 355 | print(f'❎请求错误') 356 | return None 357 | 358 | def gameScore(self): 359 | score = [] 360 | i = 0 361 | # num = random.randint(5, 10) 362 | num = 3 363 | while i < num: 364 | key = random.randint(1, 14) 365 | item = self.players[key] 366 | player = { 367 | "openId": item.get('playerId'), 368 | "score": random.randint(800, 100000) 369 | } 370 | score.append(player) 371 | i = i + 1 372 | 373 | return score 374 | 375 | def endgame(self, count, len): 376 | timestamp = int(datetime.datetime.now().timestamp() * 1000) 377 | signStr = f'{len}&{self.gameToken}&{timestamp}' 378 | md = hashlib.md5(signStr.encode()) 379 | gameSign = md.hexdigest() 380 | api = 'mtop.alsc.playgame.mini.game.dispatch' 381 | 382 | gameScore = json.dumps(self.gameScore()) 383 | 384 | bizParam = json.dumps({ 385 | "gameId": self.gameId, 386 | "gameResult": len, 387 | "time": timestamp, 388 | "gameSign": gameSign, 389 | "gameScore": gameScore, 390 | }) 391 | 392 | data = { 393 | "bizMethod": "/game/end", 394 | "bizParam": bizParam, 395 | "bizScene": "GREEDY_SNAKE" 396 | } 397 | 398 | try: 399 | res = self.req(api, data, "1.0") 400 | if res.json()["ret"][0] == "SUCCESS::调用成功": 401 | nested_data = json.loads(res.json()["data"]["data"]) 402 | value = nested_data["realGrantValue"] 403 | if value is None: 404 | print(f'[{self.name}] ❌第[{count}]次玩贪吃蛇失败,奖励上限') 405 | self.stop = True 406 | else: 407 | print(f'[{self.name}] ✅第[{count}]次玩贪吃蛇成功,获得乐园币--[{value}]') 408 | self.stop = False 409 | else: 410 | print(f'[{self.name}] ❌游戏结算错误,原因:{res.text}') 411 | self.stop = False 412 | except Exception: 413 | print(f'❎请求错误') 414 | self.stop = False 415 | 416 | def task(self): 417 | count = 1 418 | len = 19999 419 | while count < 7 and self.stop is False: 420 | len = len + 1 421 | try: 422 | if self.getOpenId(): 423 | if self.startgame(): 424 | self.endgame(count, len) 425 | else: 426 | print(f'[{self.name1}] ❌开始游戏失败') 427 | except Exception as e: 428 | print(f"[{self.name1}] ❌游戏失败,原因: {e}") 429 | time.sleep(random.randint(1, 3)) 430 | count = count + 1 431 | 432 | def main(self): 433 | if self.login(): 434 | print(f"----开始游戏----") 435 | self.task() 436 | 437 | 438 | if __name__ == '__main__': 439 | if 'elmck' in os.environ: 440 | cookie = os.environ.get('elmck') 441 | else: 442 | print("环境变量中不存在[elmck],启用本地变量模式") 443 | cookie = ck 444 | if cookie == "": 445 | print("本地变量为空,请设置其中一个变量后再运行") 446 | exit(-1) 447 | cookies = cookie.split("&") 448 | 449 | print(f"饿了么共获取到 {len(cookies)} 个账号") 450 | for i, ck in enumerate(cookies): 451 | print(f"======开始第{i + 1}个账号======") 452 | ck = reorder_ck(ck) 453 | TCS(ck).main() 454 | print("2s后进行下一个账号") 455 | time.sleep(2) 456 | --------------------------------------------------------------------------------