Skip to main content

JNDI Injection

Supports six exploitation methods, plus a ShowHand chain for one-click testing of common chains

Payload NameDescriptionApplicable VersionSupported Protocol
JNDIBasicPayloadMost basic vulnerability exploitation method, supports remote loading, LDAP recommended, wider JDK version coverage than RMIJDK < 8u191LDAP、RMI
JNDILDAPDeserializePayloadLDAP DeserializationLower JDK versionsLDAP
JNDIResourceRefPayloadObjectFactory-based exploitation using Tomcat BeanFactory classMost Tomcat versions: tomcat8 < 8.5.79 tomcat9 < 9.0.63 tomcat10 < 10.0.21 tomcat10.1 < 10.1.0-M14LDAP、RMI
JNDIReferencePayloadObjectFactory-based exploitation using other methods, relatively strict conditionsLower JDK versionsLDAP、RMI
JNDIRefBypassPayloadBypasses high version JDK LDAP deserialization restrictions using javaReferenceAddress attributeLower JDK versionsLDAP、RMI
JNDIRMIDeserializePayloadRMI DeserializationAll JDK versionsRMI

When using this module, ensure relevant ports are open. If using JNDIBasicPayload for remote class loading, configure the Reverse IP option properly.

Since version 1.4.0, Java Chains has added automatic service startup functionality. When generating, it will automatically detect and start corresponding services.

JNDIBasicPayload

LDAP remote bytecode loading

warning

Note: When using this method, you must set Reverse IP in the JNDI control panel to ensure the target server connects back to Java Chains' HTTP port (default is port 58080)

The selected Gadget here is Exec, which is used to execute commands. Clicking it will expand it to show the Gadget details. You can enter the command to be executed in the cmd parameter box. The default command here is calc.

Place the generated LDAP/RMI Payload where JNDI injection exists

The following function operations are basically the same, so I won't elaborate further.

JNDILDAPDeserializePayload

Deserialization based on LDAP's javaSerializedData field

The control panel here is for selecting deserialization exploit chains

JNDIResourceRefPayload

LDAP BeanFactory-based Tomcat EL, Groovy and other exploits

classdescriptionremark
javax.el.ELProcessor#evalEL expression executionBuilt into Tomcat, most common exploitation
groovy.lang.GroovyShell#evaluateGroovy expression execution
org.mvel2.sh.ShellSession#execMVEL expression execution
bsh.Interpreter#evalBeanshell expression execution
org.yaml.snakeyaml.Yaml#loadSnakeyaml deserializationTested successfully in SpringBoot environment
com.thoughtworks.xstream.XStream#fromXMLXStream deserializationXStream dependency must be vulnerable version
com.sun.glass.utils.NativeLibLoaderLocal dynamic library loadingJDK built-in class

JNDIReferencePayload

LDAP Reference exploitation based on other ObjectFactory, such as various DataSource JDBC exploits

The following classes are suitable for scenarios where BeanFactory cannot be used, some data source factories that can be used as alternative ObjectFactory, can implement loading local jdbc url and convert to jdbc-related exploits:

DataSource classNamedescriptionremark
org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactoryLoad local jdbc url
org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactoryLoad local jdbc url
org.apache.commons.dbcp.BasicDataSourceFactoryLoad local jdbc url
org.apache.commons.dbcp2.BasicDataSourceFactoryLoad local jdbc url
org.apache.tomcat.jdbc.pool.DataSourceFactoryLoad local jdbc url
com.alibaba.druid.pool.DruidDataSourceFactoryLoad local jdbc urlSlightly different format from BasicDataSourceFactory; Local testing shows infinite Payload execution
com.zaxxer.hikari.HikariJNDIFactoryLoad local jdbc urlSlightly different format from BasicDataSourceFactory

JNDIRMIDeserializePayload

RMI deserialization, applicable to all JDK versions

JNDIRefBypassPayload

LDAP high version JDK bypass ReferenceBypass, equivalent to bypass version of JNDIReferencePayload

JNDIShowHandPayload

JNDI all-in-one chain, one-click testing of common exploit chains to improve testing efficiency

Chain Detection via DNSLog

This Payload is suitable for target environments with configured DNS servers and DNS protocol outbound access.

Using the all-in-one chain, batch generate dozens of LDAP Payload URLs for batch testing Select JNDIShowHandPayload -> DNSLogAndHttp, and configure DNSLog address Click [Run] button, wait a moment for batch generation of LDAP URL Payload addresses

Taking Log4j vulnerability as an example, batch send packets through Burpsuite's Intruder module

Configure Payload and disable URL encoding according to actual situation

Recommend using single thread and setting packet interval to at least 3 seconds

Click [Start attack] to begin brute force

Analyzing DNSLog Results

Check the DNSLog platform. If DNSLog exists, it definitely indicates bytecode execution; if no DNSLog exists, there are following possibilities that need investigation:

  1. Sent Payload is blocked by WAF/RASP a. Solution: Bypass WAF/RASP
  2. Target server has no DNS configured, or DNS protocol cannot access internet a. Solution: Use Sleep bytecode to determine exploit chain existence through delay, or switch to HTTPReq gadget for detection, directly make requests through IP without DNS resolution to check HTTP protocol outbound access
  3. Target lacks common chains, or environment is extreme a. Solution: Use FindClass and other means to comprehensively determine JDK version and dependencies for targeted exploitation or bypass.

If progress is smooth, there will be many DNSLog requests (one DNSLog is enough to confirm success):

If WebLog exists, it indicates HTTP outbound access

DNSLog results look like:

basic.dnslogandhttp.macos.xxx.eyes.sh
deser.jackson.templatesimpl.macos.xxx.eyes.sh
resourceref.tomcatelref.elconvert.macos.xxx.eyes.sh
reference.tomcatdbcp2jdbcattack.pgsql-jdbc-jndi.bean-xml.macos.xxx.eyes.sh
rmi.jackson.templatesimpl.macos.xxx.eyes.sh

The first field corresponds to:

DNSLog RecordCorresponding Exploitation Method
basic.dnslogandhttp.macos.xxx.eyes.shJNDIBasicPayload
deser.jackson.templatesimpl.macos.xxx.eyes.shJNDILDAPDeserializePayload
resourceref.tomcatelref.elconvert.macos.xxx.eyes.shJNDIResourceRefPayload
reference.tomcatdbcp2jdbcattack.pgsql.sbxcl.macos.xxx.eyes.shJNDIReferencePayload
rmi.jackson.templatesimpl.macos.xxx.eyes.shJNDIRMIDeserializePayload

DNSLog Alias Mapping

Since some gadget names are too long and may not display on certain dnslog platforms, some gadgets have alias operations. These aliases will appear in dnslog. Here's the correspondence between gadgets and aliases:

Gadget NameAlias
JNDIBasicPayloadbasic
JNDILDAPDeserializePayloadldap_deser or deser
JNDIReferencePayloadreference
JNDIResourceRefPayloadresourceref
JNDIRefBypassPayloadrefbypass
JNDIRMIDeserializePayloadrmi
CommonsBeanutils1cb1
CommonsBeanutils2cb2
CommonsBeanutils3cb3
CommonsBeanutils4cb4
CommonsCollectionsK1K1
CommonsCollectionsK2K2
CommonsCollectionsK3K3
CommonsCollectionsK4K4
PostgreSqlJdbc4Jndipgsql or pgsql-jdbc-jndi
SnakeyamlJarConvertsjc or snake_convert
SnakeyamlJarSpi4JNDIsjsj or snake_jar_jndi
SpringBeanXmlClassLoadersbxcl or bean-xml