模块:RCE Test:修订间差异
(test) |
(sandbox probe v2) |
||
| (未显示同一用户的1个中间版本) | |||
| 第1行: | 第1行: | ||
local p = {}; function 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