GithubHelp home page GithubHelp logo

log4j-minilab's Introduction

LOG4J Mini Lab

The Log4J incident from December 2021 was one of the biggest and most impactful security issues in recent Java history.

In this minilab, we will look into the vulnerability and try to create our own server.

Check out this repository

git clone https://github.com/bmvermeer/log4j-minilab.git

The repository contains an application and a template for a malicious log4shell server.

Running the application

cd log4japp
./mvnw compile spring-boot:run 

Running the server

cd log4shell-server 
./mvnw compile exec:java

The application contains a vulnerable Log4j version. It evaluates JNDI commands and you can connect to an LDAP server that you own to create arbitrary code execution. The log4shell-server already contains an incomplete LDAP server based on the marschalsec project by Moritz Bechler. This server gives a reference to Evil.class which is served to you using an HTTP server. Both the LDAP server and the HTTP are fully functional.

Assignment 1

check if we are vulnerable

  • Startup the log4japp
  • go to http://localhost:8080/
  • try to login with an incorrect username and password.
  • See in the console what is logged
  • Check if we use a log4j version that is vulnerable (<2.15)
  • Startup the log4shell-server and try to connect to to the server
  • If the console gives you a javax.naming.NamingException with Root exception is java.lang.ClassCastException, than you are on the correct spot.

Assignment 2

Implement class Evil

Implement class Evil so it will print “HACKED AT DEVOXXUK” when we load it using the LDAP string from before.

Assignment 3

Try to execute a command.

For instance open the calculator on your machine.

Assignment 4

Create a reversed shell attack

  • Install netcat on your machine
  • Open netcat and listen to port 9001 (in a new shell window)
  • Edit your Evil class so it opens a connection to your (local) host on port 9001
  • If everything works out, netcat is now connected to your machine and you have shell access. Imagine doing this on a remote machine :)

log4j-minilab's People

Contributors

bmvermeer avatar simonsnyk avatar

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.