-- ========================================================================= -- ⚙️ 全局配置区域 -- ========================================================================= local SERVER_HOST = "http://46.224.69.39:47507" -- 网盘网址 local REG_API = SERVER_HOST .. "/api/v4/user" local LOGIN_PREPARE_API = SERVER_HOST .. "/api/v4/session/prepare" local DIR_API = SERVER_HOST .. "/api/v4/directory" local UPLOAD_API = SERVER_HOST .. "/api/v4/file/upload" local MY_HEADERS = { ["Content-Type"] = "application/json", ["User-Agent"] = "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36" } function main() while true do local menu = gg.choice({ '🔑 1. 登录系统账号 (智能测序版)', '📝 2. 注册新用户' }, nil, "✨ 云更新后台接口管理中心 ✨") if menu == 1 then login() elseif menu == 2 then register() else os.exit() end end end -- ========================================================================= -- 🔑 自适应碰撞登录流(彻底终结 404) -- ========================================================================= function login() local prompt = gg.prompt({'输入邮箱:', '输入密码:'}, {'', ''}, {'text', 'text'}) if not prompt then return end local email, password = prompt[1], prompt[2] if email == "" or password == "" then gg.alert("❌ 错误:邮箱或密码不能为空") return end MY_HEADERS["Cookie"] = nil -- 🏃‍♂️ 第一步:执行预检 (GET) gg.toast("⏳ 正在建立安全握手...") local encoded_email = email:gsub("@", "%%40") local prepare_url = LOGIN_PREPARE_API .. "?email=" .. encoded_email local prep_res = gg.makeRequest(prepare_url, MY_HEADERS) if prep_res.code ~= 200 then gg.alert("❌ 预检失败,请检查网络或网址。") return end -- 🌟 提取预检 Cookie local prep_cookie = prep_res.headers["Set-Cookie"] or prep_res.headers["set-cookie"] if prep_cookie then if type(prep_cookie) == "table" then prep_cookie = prep_cookie[1] end local cookie_val = prep_cookie:match("([^;]+)") if cookie_val then MY_HEADERS["Cookie"] = cookie_val end end gg.sleep(500) -- 稍微歇歇,防止请求过快 -- 🎯 第二步:智能探测合集 -- 后端路由严格,这里列出 Cloudreve 各种魔改版所有可能的登录入口 local guess_list = { { method = "POST", url = SERVER_HOST .. "/api/v4/session" }, { method = "PUT", url = SERVER_HOST .. "/api/v4/session" }, { method = "POST", url = SERVER_HOST .. "/api/v4/session/" }, { method = "POST", url = SERVER_HOST .. "/api/v4/user/session" } } local body = string.format('{"identity":"%s","password":"%s"}', email, password) local final_res = nil local hit_index = 0 gg.toast("🚀 正在对云端路由进行自适应匹配...") for i, guess in ipairs(guess_list) do local response = gg.makeRequest(guess.url, MY_HEADERS, body) -- 如果返回的不是 404,说明这条路是对的!(哪怕是 400 或者是密码错误提示) if response.code ~= 404 then final_res = response hit_index = i break end end -- 🧾 结果大考盘 if not final_res then gg.alert("❌ 碰撞结束:所有已知登录路由全部返回 404!\n这说明服务器修改了默认登录路径,请确保在网页端成功点击过最后的“登录”按钮以供黄鸟记录。") return end -- 打印捕获喜报 local success_route = guess_list[hit_index] if final_res.code == 200 and final_res.content:find('"code":0') then local login_cookie = final_res.headers["Set-Cookie"] or final_res.headers["set-cookie"] if login_cookie then if type(login_cookie) == "table" then login_cookie = login_cookie[1] end local cookie_val = login_cookie:match("([^;]+)") if cookie_val then MY_HEADERS["Cookie"] = cookie_val end end gg.toast("🎉 成功捕捉正确路由并登录成功!") run_toolbox() else gg.alert("🎯 【成功捕捉到正确接口!】\n\n" .. "正确的请求方式: " .. success_route.method .. "\n" .. "正确的接口路径: " .. success_route.url .. "\n\n" .. "服务器响应状态码: " .. final_res.code .. "\n" .. "返回体: " .. (final_res.content or "无")) end end -- ========================================================================= -- 📝 用户注册逻辑(保留跑通的稳定版本) -- ========================================================================= function register() local prompt = gg.prompt({'输入邮箱:', '输入密码:'}, {'', ''}, {'text', 'text'}) if not prompt then return end local email, password = prompt[1], prompt[2] if email == "" or password == "" then return end local nickname = email:match("([^@]+)") or "user" gg.toast("正在向云端提交注册...") local body = string.format('{"email":"%s","password":"%s","nickname":"%s"}', email, password, nickname) local response = gg.makeRequest(REG_API, MY_HEADERS, body) if response.code == 200 and response.content:find('"code":0') then gg.alert("🎉 注册成功!现在可以去登录了。") else gg.alert("❌ 注册失败:\n" .. (response.content or "")) end end -- ========================================================================= -- 📁 个人云控制台核心逻辑 -- ========================================================================= function get_user_apps() local response = gg.makeRequest(DIR_API .. "?path=/", MY_HEADERS) local apps = {} if response.code == 200 then for obj in response.content:gmatch("%{[^%}]+%}") do local name = obj:match('"name"%s*:%s*"([^"]+)"') local is_dir = obj:match('"type"%s*:%s*"dir"') if name and is_dir then table.insert(apps, name) end end end return apps end function run_toolbox() while true do local menu = gg.choice({ '📂 1. 查看我创建的应用目录', '➕ 2. 创建新应用(独立目录)', '🚪 3. 注销账户登出' }, nil, "📂 欢迎回到个人云空间后台") if menu == 1 then local apps = get_user_apps() if #apps == 0 then gg.alert("📭 空间内暂无应用目录。") else local list_str = "应用列表:\n" for _, v in ipairs(apps) do list_str = list_str .. "• " .. v .. "\n" end gg.alert(list_str) end elseif menu == 2 then local prompt = gg.prompt({'输入新应用文件夹名称:'}, {''}, {'text'}) if prompt and prompt[1] ~= "" then local body = string.format('{"path":"/%s"}', prompt[1]) local res = gg.makeRequest(DIR_API, MY_HEADERS, body) if res.code == 200 then gg.alert("✅ 创建成功") else gg.alert("❌ 失败:\n"..res.content) end end else MY_HEADERS["Cookie"] = nil break end end end main()