Hacker exploits Log4j vulnerability to target HTB Crafty Minecraft server

Today I will show with a live example how a Minecraft server running on Windows can be attacked using an existing exploit. Once we have the ability to execute code remotely, we will analyze the installed plugins and find data to escalate privileges in the system.

Our goal is to capture the Crafty car from the training area Hack The Box. The task level is easy. All actions will be performed on Linux.

warning

It is recommended to connect to machines with HTB only via VPN. Do not do this from computers that contain data that is important to you, as you will end up on a shared network with other participants.

Intelligence service

Port scanning

Add the machine's IP address to /etc/hosts:

И запус­каем ска­ниро­вание пор­тов.

Справка: сканирование портов

Ска­ниро­вание пор­тов — стан­дар­тный пер­вый шаг при любой ата­ке. Он поз­воля­ет ата­кующе­му узнать, какие служ­бы на хос­те при­нима­ют соеди­нение. На осно­ве этой информа­ции выбира­ется сле­дующий шаг к получе­нию точ­ки вхо­да.

На­ибо­лее извес­тный инс­тру­мент для ска­ниро­вания — это Nmap. Улуч­шить резуль­таты его работы ты можешь при помощи сле­дующе­го скрип­та:

#!/bin/bash

ports=$(nmap -p- --min-rate=500 $1 | grep ^(0-9) | cut -d '/' -f 1 | tr 'n' ',' | sed s/,$//)

nmap -p$ports -A $1

It works in two stages. The first one performs a regular quick scan, the second one performs a more thorough scan using the available scripts (option -A).

The result of the script

The scanner found two open ports:

  • 80 - Microsoft IIS 10.0 web server;
  • 25565 - Minecraft server 1.16.5.

First of all, let's look at what's on the web server. There we are greeted by a one-page website revealing another subdomain.

Site's home page
Site's home page

We add a new subdomain to our file /etc/hosts.

10.10.11.249 crafty.htb play.crafty.htb

I would like to note right away that scanning neither the first nor the second site yielded anything. For this reason, let's move on to the Minecraft server.

Point of entry

The first step is to check whether there are ready-made exploits for the detected software. There are special databases (for example, Exploit-DB), but to get started, you can just search on Google. At the request “Minecraft 1.16.5 exploit” we receive information that this version of the server has a vulnerable Log4j component.

Search for exploits on Google
Search for exploits on Google

We find it on GitHub exploitwhich allows you to get remote code execution (RCE).