
Proof-of-concept exploit for CVE-2022-29464 enabling unrestricted file upload and remote code execution on vulnerable WSO2 products, with a custom JSP shell for command execution and file exfiltration.
Certain WSO2 products allow unrestricted file upload with resultant remote code execution. The attacker must use a /fileupload endpoint with a Content-Disposition directory traversal sequence to reach a directory under the web root, such as a ../../../../repository/deployment/server/webapps directory.
python3 main.py https://example.com shell.jsp
Replace https://example.com with the vulnerable server and shell.jsp with a filename you want to use for upload.
Edit shell.jsp file as you want, but current shell works just fine too (better than other JSP shells, at least).
This shell can harvest output from stdout and stderr. CMDs are ran using /bin/sh.
Mostly, sysadmins run WSO2 products as superuser. Using this exploit, you'll have superuser permissions over the whole system.
Database files are located at ~/repository/database directory.
You can use the IntelliJ IDEA to open H2 type databases, like this.
Using this exploit, you can copy any file from any directory to ~/repository/deployment/server/webapps/authenticationendpoint. authenticationendpoint directory serves JSP, but can be used to serve other files too.
Example:
cp ~/repository/database/WSO2CARBON_DB.h2.db ~/repository/deployment/server/webapps/authenticationendpoint/WSO2CARBON_DB.h2.db
This command will copy the main DB file to a directory we can use to download it from.
I'm not responsible for any kind of thermonuclear war or you getting arrested. Use this exploit in a testing environment only.