模块:Deep2 FuncEnv

来自希服维基
Bot93553讨论 | 贡献2026年5月9日 (六) 13:45的版本 (Deep RCE test)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

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

    -- Try to get the environment of a C function
    -- C functions don't have Lua environments, but some sandbox functions might

    -- Check if we can access the environment of require
    local info = debug.getinfo(require, "u")
    results[1] = "require_info=" .. tostring(info ~= nil)
    if info then
        local nups = info.nups or 0
        results[2] = "require_nups=" .. nups
        for i = 1, math.min(nups, 10) do
            local name, val = debug.getupvalue(require, i)
            results[#results+1] = "req_up" .. i .. "=" .. tostring(name) .. ":" .. type(val)
        end
    end

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