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

Mentor

10 Dec 2022 · 24 min read · root access
Mentor - maquina de Hack The Box

Executive summary — Mentor only exposes SSH and HTTP over TCP, but the real entry point lives in SNMP over UDP, a port a conventional TCP scan never reveals. From there the box is a chain of six reused secrets without a single CVE involved: SNMP leaks a process's command line (and with it a password), that password grants admin access to a FastAPI API with a backup endpoint vulnerable to command injection, the resulting RCE lands inside a Docker container whose source code holds PostgreSQL credentials, the database stores user passwords as unsalted MD5, and two of those passwords are reused verbatim as system SSH credentials — the second one with sudo over /bin/sh at the very end.

PlatformHack The Box
Operating systemLinux
DifficultyMedium
StatusRetired
Target IP10.129.x.x

Attack map

[22,80] mentorquotes.htb — TCP only; SNMP UDP/161 invisible to the TCP scan
   ▼
[161/udp] SNMP — "internal" community (onesixtyone misses it, snmpwalk finds it)
   │  hrSWRunParameters -> "login.py <password>" in the process command line
   ▼
[FastAPI] api.mentorquotes.htb — login as james (admin) with that password
   │  /admin/backup (undocumented) — blind command injection via "path"
   ▼
[RCE]  root INSIDE the Docker container (BusyBox, no bash)
   │  /app/app/db.py -> postgres:postgres@172.22.0.1/mentorquotes_db
   │  users table -> MD5 hashes for james and svc; svc cracks with rockyou
   ▼
[SSH]  svc  (user.txt) — DB password reused as the system account password
   │  /etc/snmp/snmpd.conf -> james's password in clear text (createUser bootstrap)
   ▼
[SSH]  james — password from snmpd.conf reused
   │  sudo (ALL) /bin/sh, unrestricted
   ▼
[ROOT]  root.txt

1. Reconnaissance

ping -c 3 -W 3 mentorquotes.htb

ttl=63 (64 minus one hop) points to Linux. Full TCP scan:

nmap -p- --min-rate 5000 -T4 -Pn -oN nmap-allports.txt mentorquotes.htb
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Only two ports, with no obvious web vector behind them — easy to get stuck here. Version detection to confirm the base system:

nmap -sCV -p22,80 -Pn -oN nmap-services.txt mentorquotes.htb
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.52 ((Ubuntu))
|_http-title: Did not follow redirect to http://mentorquotes.htb/

OpenSSH 8.9p1 + Apache 2.4.52 confirm Ubuntu 22.04. When TCP offers so little surface, the mandatory next reflex — the one a lot of people skip because it's slow and noisy — is checking UDP, where services like SNMP live:

sudo nmap -sU --top-ports 50 -T4 -Pn -oN nmap-udp.txt mentorquotes.htb
PORT      STATE  SERVICE
161/udp   open   snmp        <- INVISIBLE to the TCP scan

161/udp — SNMP open. This port never shows up in a TCP scan, and it changes the whole machine: SNMP exposes system management data (processes, software, network) to anyone who knows the community string that works as its password.

🔒 Clearance required

This content is Root Access only. Everything else on the site — the free tier, the whole public library — stays open.

See Root Access plans

No account? Create one free then upgrade from your console.