-- 通用模块 require("TSLib") require('api') local ts = require("ts") local ios_config = require("config") -- local config_map = require("config_map") local json = ts.json function open_app(app_bid) runApp(app_bid) return true -- if runApp(app_bid) == 0 then -- for i = 1, 3 do -- if isFrontApp(app_bid) == 1 then return true end -- mSleep(1000) -- end -- return false -- else -- return false -- end end function device_clear(email) -- 清理弹窗 if email then wolf_log(email .. " 进行弹窗清理...") toast(email .. "进行弹窗清理...", 2) os.execute("/usr/local/bin/kdd " .. email) mSleep(500) os.execute("/usr/bin/runasroot /var/mobile/clear_account3.sh") end end function check_alert_v2() -- find_table = ios_config.ios_查找文字.弹窗_验证ID -- if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then -- toast("异常弹窗_文字", 2) -- tap(238, 763) -- end wolf_log('检测弹窗1') find_table = ios_config.ios_查找文字.弹窗_验证ID if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_文字", 2) tap(238, 763) end wolf_log('检测弹窗2') find_table = ios_config.ios_查找文字.弹窗_验证ID_以后 if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_新协议", 2) tap(246, 763) end wolf_log('检测弹窗3') find_table = ios_config.ios_查找文字.重登_设置_电话异常弹窗 if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_电话", 2) tap(223, 760) end os.execute("rm -rf /var/mobile/a.lock") end function relogin_chek_alert() wolf_log('检测弹窗1') find_table = ios_config.ios_查找文字.重登_异常弹窗 if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_好", 2) tap(373, 729) end wolf_log('检测弹窗2') find_table = ios_config.ios_查找文字.重登_设置_电话异常弹窗 if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_电话", 2) tap(223, 760) end end function check_alert() wolf_log('检测弹窗') find_table = ios_config.ios_查找文字.弹窗_登录ID if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_文字", 2) tap(243, 626) end wolf_log('检测弹窗3') if not os.execute("find /var/mobile/a.lock") then return 403 end wolf_log('检测弹窗4') find_table = ios_config.ios_查找文字.弹窗_验证ID if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then toast("异常弹窗_文字", 2) tap(238, 763) end os.execute("rm -rf /var/mobile/a.lock") -- find_table = ios_config.ios_查找文字.弹窗_验证ID -- if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], find_table[1], 100, 1) then -- toast("检测到弹窗", 2) -- tap(238, 763) -- mSleep(1000) -- end -- if find_str(ios_config.ios_查找文字.弹窗_验证ID_以后, true, 1) then -- wolf_log("异常弹窗_文字") -- tap(246, 763) -- mSleep(500) -- return 200 -- -- end -- if multiColor(ios_config.ios_多色判断.异常弹窗_3,90) then -- wolf_log("异常弹窗_3") -- tap(246, 763) -- mSleep(500) -- return 200 -- end -- if multiColor(ios_config.ios_多色判断.异常弹窗_1,95) then -- wolf_log("异常弹窗_1") -- tap(238, 763) -- mSleep(1000) -- return 200 -- end -- if multiColor(ios_config.ios_多色判断.异常弹窗_2,95) then -- wolf_log("异常弹窗_2") -- tap(238, 763) -- mSleep(1000) -- return 200 -- end -- if multiColor(ios_config.ios_多色判断.异常弹窗_4,90) then -- wolf_log("异常弹窗_4") -- tap(238, 763) -- mSleep(1000) -- return 200 -- end end function find_multi_color(find_table, sec, no_check_alert) no_check_alert = no_check_alert or nil if sec < 1 then sec = 1 end while sec > 0 do if not no_check_alert then check_alert() end if multiColor(find_table) then break end sec = sec - 1 mSleep(1000) end if sec > 0 then return true else return false end end function find_str(find_table, no_check_alert, sec) -- 直接调用方法会出问题 no_check_alert = no_check_alert or nil local index = sec while index > 0 do if not no_check_alert then check_alert() end if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], "", find_table[7], 1) then return true end index = index - 1 mSleep(500) end return false end function find_x_y_colour(find_table, sec, no_check_alert) -- 查找图色 no_check_alert = no_check_alert or nil if sec < 3 then sec = 3 end for i = 1, sec do if not no_check_alert then check_alert() end -- toast("查找图色:" .. find_table[1] .. " | 正在进行第 " .. i .. "次尝试", 1) x, y = findMultiColorInRegionFuzzy(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], find_table[7], { orient = 2 }) if x ~= -1 then return x, y end mSleep(1000) end return -1, -1 end function random_str(int_num) -- 生成随机汉字 local str1 ="安彤含祖赩涤彰爵舞深群适渺辞莞延稷桦赐帅适亭濮存城稷澄添悟绢绢澹迪婕箫识悟舞添剑深禄延涤濮存罡禄瑛瑛嗣嫚朵寅添渟黎臻舞绢城骥彰渺禾教祖剑黎莞咸浓芦澹帅臻渟添禾亭添亭霖深策臻稷辞悟悟澄涉城鸥黎悟乔恒黎鲲涉莞霖甲深婕乔程澹男岳深涉益澹悟箫乔多职适芦瑛澄婕朵适祖霖瑛坤嫚涉男珂箫芦黎珹绢芦程识嗣珂瑰枝允黎庸嗣赐罡纵添禄霖男延甲彰咸稷箫岳悟职祖恒珂庸琅男莞庸浓多罡延瑛濮存爵添剑益骥澄延迪寅婕程霖识瑰识程群教朵悟舞岳浓箫城适程禾嫚罡咸职铃爵渺添辞嫚浓寅鲲嗣瑛鸥多教瑛迪坤铃珹群黎益澄程莞深坤澹禄职澹赩澄藉群箫骥定彰寅臻渟枝允珹深群黎甲鲲亭黎藏浓涤渟莞寅辞嗣坤迪嫚添策庸策藉瑰彰箫益莞渺乔彰延舞祖婕澹渺鸥纵嗣瑛藏濮存婕职程芦群禾嫚程辞祖黎职浓桦藏渟禾彰帅辞铃铃黎允绢濮存剑辞禾瑰添延添悟赐祖咸莞男绢策婕藉禾浓珹涤祖汉骥舞瑛多稷赐莞渟黎舞桦黎群藏渺黎坤桦咸迪澈舞允稷咸剑定亭澄濮存鲲臻全鸥多赐程添瑛亭帅悟甲男帅涤适纵渟鲲亭悟琅亭添允舞禾庸咸瑛教鲲允箫芦允瑛咸鸥帅悟延珂黎珹箫爵剑霖剑霖禄鸥悟涉彰群悟辞帅渺莞澄桦瑛适臻益霖珹亭澹辞坤程嗣铃箫策澈枝赐莞爵渟禄群枝添芦群浓赐职益城澄赩琅延群乔珹鲲祖群悟黎定庸澄芦延霖罡鲲咸渺纵亭禄鸥赩涤剑澹藏纵濮存澄芦剑延瑰稷黎益赩澄允悟澈甲嗣绢朵益甲悟涤婕群咸臻箫鲲寅鸥桦益珂舞允庸芦藉寅渺咸赐澄程剑瑰霖瑰铃帅男铃悟识瑰仕仕城允莞全朵涤铃剑渺稷剑珂铃箫全仕益纵芦桦珂濮存城朵朵咸程剑澄定澈爵寅庸定莞瑛教彰黎箫仕黎桦赩深赩爵迪悟珹涤琅添箫桦帅瑛黎黎策识寅嫚涉迪策汉舞定彰允男祖教澄群瑛濮存男禾教莞禾鸥澈濮存岳城嫚深舞教岳澄亭禾坤朵亭职莞稷寅瑰城庸亭舞禾瑛恒坤浓彰莞澄澈鸥臻稷教琅辞益剑藉黎添瑛延舞坤仕岳多婕骥迪帅黎悟全澄识益甲桦纵适罡彰澄禾婕程黎城涤浓枝箫咸渟岳渟澹臻珹识珹澄箫辞浓鲲识悟允悟禾识群祖迪渟鲲群庸莞珹悟澹瑰悟鸥汉群甲莞庸职琅莞桦鲲朵深乔辞允彰渺朵瑰亭瑰朵定深男识群职霖益男舞城允舞爵赩枝罡罡群澹芦藉爵悟渟澹禾多庸箫坤乔芦甲濮存多渟藉珹赐汉纵亭禾城枝剑露以玉春飞慧娜悠亦元晔曜霜宁桃彦仪雨琴青筠逸曼代菀孤昆秋蕊语莺丝红羲盛静南淑震晴彭祯山霞凝柔隽松翠高骊雅念皓双洛紫瑞英思歆蓉娟波芸荷笑云若宏夏妍嘉彩如鹏寄芝柳凌莹蝶舒恬虹清爽月巧乾勋翰芳罗刚鸿运枫阳葳杰怀悦凡哲瑶凯然尚丹奇弘顺依雪菡君畅白振馨寻涵问洁辉忆傲伟经润志华兰芹修晨木宛俊博韶天锐溪燕家沈放明光千永溶昊梅巍真尔馥莲怜惜佳广香宇槐珺芷帆秀理柏书沛琪仙之竹向卉欣旻晓冬幻和雁淳浩歌荣懿文幼岚昕牧绿轩工旭颜醉玑卓觅叶夜灵胜晗恨流佁乐火音采睿翎萱民画梦寒泽怡丽心石邵玮佑旺壮名一学谷韵宜冰赫新蕾美晖项琳平树又炳骏气海毅敬曦婉爰伯珊影鲸容晶婷林子昌梧芙澍诗星冉初映善越原茂国腾孟水烟半峯莉绮德慈敏才戈梓景智盼霁琇苗熙姝从谊风发钰玛忍婀菲昶可荌小倩妙涛姗方图迎惠晤宣康娅玟奕锦濯穆禧伶丰良祺珍曲喆扬拔驰绣烁叡长雯颖辰慕承远彬斯薇成聪爱朋萦田致世实愫进瀚朝强铭煦朗精艺熹建忻晏冷佩东古坚滨菱囡银咏正儿瑜宝蔓端蓓芬碧人开珠昂琬洋璠桐舟姣琛亮煊信今年庄淼沙黛烨楠桂斐胤骄兴尘河晋卿易愉蕴雄访湛蓝媛骞娴儒妮旋友娇泰基礼芮羽妞意翔岑苑暖玥尧璇阔燎偲靖行瑾资漪晟冠同齐复吉豆唱韫素盈密富其翮熠绍澎淡韦诚滢知鹍苒抒艳义婧闳琦壤杨芃洲阵璟茵驹涆来捷嫒圣吟恺璞西旎俨颂灿情玄利痴蕙力潍听磊宸笛中好任轶玲螺郁畴会暄峻略琼琰默池温炫季雰司杉觉维饮湉许宵茉贤昱蕤珑锋纬渊超萍嫔大霏楚通邈飙霓谧令厚本邃合宾沉昭峰业豪达彗纳飒壁施欢姮甫湘漾闲恩莎祥启煜鸣品希融野化钊仲蔚生攸能衍菁迈望起微鹤荫靓娥泓金琨筱赞典勇斌媚寿喜飇濡宕茜魁立裕弼翼央莘绚焱奥萝米衣森荃航璧为跃蒙庆琲倚穹武甜璐俏茹悌格穰皛璎龙材湃农福旷童亘苇范寰瓃忠虎颐蓄霈言禹章花健炎籁暮升葛贞侠专懋澜量纶布皎源耀鸾慨曾优栋妃游乃用路余珉藻耘军芊日赡勃卫载时三闵姿麦瑗泉郎怿惬萌照夫鑫樱琭钧掣芫侬丁育浦磬献苓翱雍婵阑女北未陶干自作伦珧溥桀州荏举杏茗洽焕吹甘硕赋漠颀妤诺展俐朔菊秉苍津空洮济尹周江荡简莱榆贝萧艾仁漫锟谨魄蔼豫纯翊堂嫣誉邦果暎珏临勤墨薄颉棠羡浚兆环铄" local options = { ["tstab"] = 1, --随机生成 2 位字符串 ["num"] = int_num, } return getRndStr(str1, options) end function restart_vpn() -- 重新启动VPN -- 关闭 VPN 开关 setVPNEnable(false) for i = 1, 10 do statusa = getVPNStatus() toast("VPN状态:" .. statusa.status, 2) if not statusa.active and statusa.status == "未连接" then break end mSleep(1000) end mSleep(1000) --打开 VPN 开 setVPNEnable(true) mSleep(3000) if find_str(ios_config.ios_查找文字.vpn_弹窗) then -- 输入VPN密码 toast("输入VPN密码", 2) tap(227, 462) mSleep(1000) inputKey(ios_config.ios_注册信息.vpn_pwd, 10, 100) mSleep(1000) -- 点击下一页 toast("点击连接VPN", 2) tap(508, 608) mSleep(1000) end for i = 1, 20 do statusa = getVPNStatus() toast("VPN状态:" .. statusa.status, 2) if statusa.status == "已连接" then break end mSleep(1000) end if statusa.status ~= "已连接" then toast("VPN启动失败,重新执行", 2) restart_vpn() end ip = getNetIP() toast("当前IP:" .. ip, 2) end function get_ip() local ip = "" for i = 1, 10 do ip = getNetIP() if ip then break end mSleep(1000) end return ip end function change_ip() -- 飞行模式,切换IP -- 初始化确保流量是打开的 setAirplaneMode (false) mSleep(1000) setCellularDataEnable (true) setWifiEnable(false) mSleep(2000) local ip = get_ip() while (true) do toast("切换IP中...", 2) setAirplaneMode (true) mSleep(3000) setAirplaneMode (false) setWifiEnable(false) mSleep(3000) local new_ip = get_ip() toast("旧IP:" .. ip .. "\r\n" .. "新IP:" .. new_ip, 2) if new_ip and ip ~= new_ip then break end mSleep(1000) end end function change_ip_new() -- 飞行模式,切换IP if ios_config.action.wifi then setWifiEnable(true) return nil end setWifiEnable(false) setCellularDataEnable (true) setAirplaneMode (true) mSleep(5000) setAirplaneMode (false) end function change_wifi_proxy(proxy_ip, proxy_port) -- 先打开wifi setWifiEnable(true) mSleep(500) openURL("prefs:root=WIFI"); if not find_multi_color(ios_config.ios_多色判断.设置_wifi页面, 10) then toast("wifi页面加载失败", 2) return 400 end mSleep(1000) check_tap(411, 333) if not find_multi_color(ios_config.ios_多色判断.设置_wifi设置参数页面, 10) then toast("wifi参数页面加载失败", 2) return 400 end -- 滑动到底部 index = 3 while index > 0 do moveTo(440, 1172, 440, 602) mSleep(1000) if find_multi_color(ios_config.ios_多色判断.设置_wifi设置参数页面, 5) then break end index = index - 1 end if index <= 0 then toast("未定位到wifi设置底部", 2) return 400 end mSleep(500) check_tap(406, 1214) if not find_multi_color(ios_config.ios_多色判断.设置_wifi设置代理参数页面, 5) then toast("未定位到wifi 代理设置页面", 2) return 400 end if not proxy_ip then -- 关闭代理 mSleep(500) check_tap(475, 247) else -- 开启代理 mSleep(500) check_tap(475, 323) check_tap(475, 323) mSleep(500) -- 填写代理参数 check_tap(506, 586) mSleep(500) wolf_inputText(proxy_ip) mSleep(500) check_tap(506, 707) mSleep(500) wolf_inputText(proxy_port) mSleep(500) check_tap(687, 84) check_tap(687, 84) check_tap(687, 84) end return 200 end function check_tap(x,y) check_alert() tap(x,y) end -- ----------【校验lua脚本版本,进行更新并重载】---------- function verify_update_lua(versions) if versions ~= ios_config.ios_lua_version then toast("wolf版本更新中...",10) os.execute("wget -O /tmp/lua.sh http://35.220.167.14:8010/lua.sh && sh /tmp/lua.sh && rm -f /tmp/lua.sh") mSleep(2000) ios_config.is_restart_lua = true -- return_task_fail(config_map[ios_config.ios_任务信息.task_type].url, { -- task_id = ios_config.ios_任务信息.task_id, -- fail_code = 900, -- fail_reason = '脚本更新重载,放弃当前任务' -- }) else toast("wolf版本为最新 " .. versions ,10) end end function verify_lua_tap() while true do closeApp("*",0) closeApp("*",1) mSleep(2000) mSleep(500) pressHomeKey(0) mSleep(100) pressHomeKey(1) mSleep(500) open_app(ios_config.ios_app_bid.设置) if find_multi_color(ios_config.ios_多色判断.设置_首页_加载完毕, 10) then break end end mSleep(500) pressHomeKey(0) mSleep(100) pressHomeKey(1) mSleep(500) mSleep(500) pressHomeKey(0) mSleep(100) pressHomeKey(1) mSleep(500) if find_multi_color(ios_config.ios_多色判断.设置_首页_加载完毕, 3) then return false else return true end end function reload_spring2() -- ----------【校验触动lib是否失效,如果失效,就执行返回设备异常】---------- -- 执行backboardd toast('执行注销任务...',2) ts_execute("/usr/bin/killall -9 backboardd") wolf_log("等待注销完成 " .. deviceIsLock()) while deviceIsLock() == 0 do mSleep(1000) end wolf_log("当前锁屏状态 " .. deviceIsLock()) while deviceIsLock() ~= 0 do toast('home键按压1',2) pressHomeKey(0) mSleep(500) pressHomeKey(1) end return true end function reload_spring() toast('执行注销任务...', 2) -- 不再使用 -9 ts_execute("/usr/bin/killall backboardd") -- 给 backboardd / SpringBoard 启动留时间 mSleep(3000) local timeout = 30 local waited = 0 -- 等待进入锁屏 while deviceIsLock() == 0 and waited < timeout do mSleep(1000) waited = waited + 1 end if waited >= timeout then wolf_log("注销失败:等待锁屏超时") return false end wolf_log("检测到锁屏,等待系统稳定") -- 锁屏出现并不代表 SpringBoard 已完全初始化 mSleep(3000) waited = 0 while deviceIsLock() ~= 0 and waited < 15 do pressHomeKey(0) mSleep(200) pressHomeKey(1) mSleep(1000) waited = waited + 1 end if deviceIsLock() ~= 0 then wolf_log("注销完成,但设备解锁失败") return false end wolf_log("注销恢复完成") return true end function wolf_log(content) -- 获取当前时间(精确到秒的 Unix 时间戳) local current_seconds = os.time() -- 如需格式化显示(年-月-日 时:分:秒),可配合 os.date() local formatted_time = os.date("%Y-%m-%d %H:%M:%S", current_seconds) nLog('[' .. formatted_time .. ']' .. ios_config.ios_任务信息.device_id .. " >>> " .. content) log('[' .. formatted_time .. ']' .. ios_config.ios_任务信息.device_id .. " >>> " .. content, "lua_log") end function storage_space() str = ts.system.space(); -- 使用正则表达式提取剩余容量和总容量的数值 local remaining, total = str:match("剩余容量([%d%.]+)G/总容量([%d%.]+)G") -- 检查提取结果是否有效 if not remaining or not total then return nil end -- 将字符串转换为数字 local remaining_num = tonumber(remaining) local total_num = tonumber(total) -- 检查数值转换是否成功 if not remaining_num or not total_num then return nil end -- 计算百分比(保留两位小数) percentage = total_num - remaining_num return percentage end function check_internet() local wait_sec = 0 local succuess = 0 while wait_sec < 30 do nettype = ts.getNetType() toast('等待网络恢复正常,当前网络状态:[' .. nettype .. ']已等待' .. wait_sec .. '已恢复' .. succuess,1) if nettype ~= 'NO NETWORK' then succuess = succuess + 1 else succuess = 0 end if succuess >= 3 then break end wait_sec = wait_sec + 1 mSleep(1000) end if succuess > 0 then return true else return false end end function wolf_inputText(content) wolf_log("输入文字:" .. content) mSleep(ios_config.interval.tap_input) if ios_config.action.input_clipboard then check_alert() inputStr(content) else check_alert() inputText(content, 1) end mSleep(ios_config.interval.input_after) end function wolf_inputKey(content) wolf_log("输入文字:" .. content) mSleep(ios_config.interval.tap_input) inputKey(content, 10, 100) mSleep(ios_config.interval.input_after) end function device_check() -- 设备类型 producttype = ts.system.devicetype() wolf_log('设备类型'.. producttype) -- 调整设备,减少发热 -- 屏幕亮度最低 -- setBacklightLevel(0) -- 关蓝牙 setBTEnable(false) -- 关wifi -- setWifiEnable(ios_config.action.wifi) -- 关声音 -- setVolumeLevel(0) -- 永不锁屏 setAutoLockTime(0) -- 锁定方向 setRotationLockEnable(true) -- if string.sub(getDeviceName(), 1, 1) ~= "c" and string.sub(name, 1, 1) ~= "m" then -- toast('设备名非法,设备名必须为c开头',10) -- lua_exit() -- end return 200 end -- ----------【以下功能暂未使用】---------- function captcha_id_loop() -- 循环验证id弹窗 find_table = ios_config.ios_查找文字.弹窗_验证ID for i = 1, 30 do if findTextUntil(find_table[1], find_table[2], find_table[3], find_table[4], find_table[5], find_table[6], find_table[1], find_table[7], find_table[8]) then toast("检测到弹窗", 2) tap(243, 759) end mSleep(1000) end end