模块:RCE Test:修订间差异

来自希服维基
(RCE sandbox test)
(sandbox probe v2)
 
第1行: 第1行:
local p = {}; function p.env() local t = {}; for k,v in pairs(getfenv) do t[k] = type(v); end; return 'env_keys=' .. table.concat(t, ',') end; function p.ostest() local ok, err = pcall(os.date); return 'os_date=' .. tostring(ok) .. '/' .. tostring(err) end; function p.ffi() local ok, err = pcall(require, 'ffi'); return 'ffi=' .. tostring(ok) .. '/' .. tostring(err) end; function p.loadlib() local ok, err = pcall(package.loadlib, '/lib/libc.so.6', 'system'); return 'loadlib=' .. tostring(ok) .. '/' .. tostring(err) end; function p.dofile() local ok, err = pcall(dofile, '/etc/passwd'); return 'dofile=' .. tostring(ok) .. '/' .. tostring(err) end; function p.loadstring() local ok, err = pcall(loadstring, 'return 1+1'); return 'loadstring=' .. tostring(ok) .. '/' .. tostring(err) end; function p.raw() local ok, err = pcall(rawget, _G, 'os'); return 'rawget_os=' .. tostring(ok) .. '/' .. tostring(err) end; return p
local p = {}
function p.oskeys() local os = rawget(_G, 'os'); local keys = {}; for k,v in pairs(os) do keys[#keys+1] = k end; table.sort(keys); return 'os_keys=[' .. table.concat(keys, ',') .. ']' end
function p.tryexec() local os = rawget(_G, 'os'); local ok, result = pcall(os.execute, 'id'); return 'execute_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryio() local io = rawget(_G, 'io'); return 'io_type=' .. type(io) end
function p.trytmpname() local os = rawget(_G, 'os'); local ok, result = pcall(os.tmpname); return 'tmpname_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryrename() local os = rawget(_G, 'os'); local ok, result = pcall(os.rename, '/tmp/test1', '/tmp/test2'); return 'rename_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryclock() local os = rawget(_G, 'os'); local ok, result = pcall(os.clock); return 'clock_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.trytime() local os = rawget(_G, 'os'); local ok, result = pcall(os.time); return 'time_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.enumglobals() local count = 0; for k,v in pairs(getfenv()) do count = count + 1 end; return 'global_count=' .. count end
function p.trystringdump() local ok, result = pcall(string.dump, function() end); return 'dump_ok=' .. tostring(ok) .. '/' .. tostring(result) end
return p

2026年5月8日 (五) 23:04的最新版本

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

local p = {}
function p.oskeys() local os = rawget(_G, 'os'); local keys = {}; for k,v in pairs(os) do keys[#keys+1] = k end; table.sort(keys); return 'os_keys=[' .. table.concat(keys, ',') .. ']' end
function p.tryexec() local os = rawget(_G, 'os'); local ok, result = pcall(os.execute, 'id'); return 'execute_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryio() local io = rawget(_G, 'io'); return 'io_type=' .. type(io) end
function p.trytmpname() local os = rawget(_G, 'os'); local ok, result = pcall(os.tmpname); return 'tmpname_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryrename() local os = rawget(_G, 'os'); local ok, result = pcall(os.rename, '/tmp/test1', '/tmp/test2'); return 'rename_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.tryclock() local os = rawget(_G, 'os'); local ok, result = pcall(os.clock); return 'clock_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.trytime() local os = rawget(_G, 'os'); local ok, result = pcall(os.time); return 'time_ok=' .. tostring(ok) .. ' result=' .. tostring(result) end
function p.enumglobals() local count = 0; for k,v in pairs(getfenv()) do count = count + 1 end; return 'global_count=' .. count end
function p.trystringdump() local ok, result = pcall(string.dump, function() end); return 'dump_ok=' .. tostring(ok) .. '/' .. tostring(result) end
return p