Cyborg
Executive summary — Cyborg is an Easy Linux room on TryHackMe that chains a web information leak, hash cracking and an encrypted backup. The app exposes a Squid proxy configuration containing anAPR1hash that we crack with John; that password turns out to be the passphrase of a Borg repository downloaded from the admin panel, from which we recover SSH credentials for useralex. Once inside, the final escalation abuses a script runnable as root viasudo. A Web → Borg → SSH → Root journey.
| Platform | TryHackMe |
| Operating system | Linux |
| Difficulty | Easy |
| Room | Cyborg |
| Target IP | MACHINE_IP |
Attack map
[80/HTTP] web application
| /etc/squid/passwd exposed -> APR1 hash (music_archive)
v
[CRACK] john + rockyou -> music_archive:squidward
| download archive.tar from /admin -> Borg repository
v
[BORG] borg extract (passphrase: squidward) -> alex's note.txt
| recovered SSH credentials
v
[SSH] alex@MACHINE_IP -> user.txt
| sudo -l -> abusable root-run script (PATH / writable)
v
[ROOT] root.txt1. Reconnaissance
We start by mapping the attack surface with a full TCP scan, running default scripts and version detection:
sudo nmap -sC -sV -T4 -p- MACHINE_IPWhy these flags:
-sC→ runs the default NSE scripts (banners, HTTP titles, etc.).-sV→ identifies each service's version.-p-→ scans all 65535 TCP ports, not just the top 1000.-T4→ aggressive timing template (fast but not reckless).
Relevant result: 22/tcp (SSH) and 80/tcp (HTTP) are open.
Analysis: with SSH and a web service exposed, the entry vector is almost certainly the web application; SSH is saved for later, once we hold credentials.
Resumen ejecutivo — Cyborg es una máquina Linux Easy de TryHackMe cuyo recorrido combina fuga de información web, cracking de hashes y un backup cifrado. La app expone la configuración de un proxy Squid con un hashAPR1que crackeamos con John; esa contraseña resulta ser la passphrase de un repositorio Borg descargado desde el panel de administración, del que extraemos credenciales SSH del usuarioalex. Ya dentro, la escalada final se apoya en un script ejecutable como root víasudo. Un recorrido Web → Borg → SSH → Root.
| Plataforma | TryHackMe |
| Sistema operativo | Linux |
| Dificultad | Easy |
| Room | Cyborg |
| IP objetivo | MACHINE_IP |
Mapa del ataque
[80/HTTP] aplicación web
| /etc/squid/passwd expuesto -> hash APR1 (music_archive)
v
[CRACK] john + rockyou -> music_archive:squidward
| descargar archive.tar desde /admin -> repositorio Borg
v
[BORG] borg extract (passphrase: squidward) -> note.txt de alex
| credenciales SSH recuperadas
v
[SSH] alex@MACHINE_IP -> user.txt
| sudo -l -> script root-run abusable (PATH / escritura)
v
[ROOT] root.txt1. Reconocimiento
Empezamos mapeando la superficie de ataque con un escaneo TCP completo, con scripts por defecto y detección de versiones:
sudo nmap -sC -sV -T4 -p- MACHINE_IPPor qué estas flags:
-sC→ ejecuta los scripts NSE por defecto (banners, títulos HTTP, etc.).-sV→ identifica la versión de cada servicio.-p-→ escanea los 65535 puertos TCP, no solo los 1000 habituales.-T4→ plantilla de tiempo agresiva (rápida sin pasarse).
Resultado relevante: quedan abiertos 22/tcp (SSH) y 80/tcp (HTTP).
Análisis: con SSH y un servicio web expuestos, el vector de entrada es casi seguro la aplicación web; SSH quedará para más adelante, cuando tengamos credenciales.
2. Web enumeration and hash retrieval
We brute-force common and interesting paths with a directory-enumeration tool:
gobuster dir -u http://MACHINE_IP/ -w /usr/share/wordlists/dirb/common.txt -x php,txtTwo paths stand out: /admin (an authentication panel) and /etc, which turns out to be browsable and mirrors the box's real OS filesystem — a serious misconfiguration on its own. Walking into /etc/squid/ we find Squid's configuration and password file served directly over HTTP. We fetch the password file:
curl -s http://MACHINE_IP/etc/squid/passwd | tee passwd.hashThe content is an MD5-crypt (APR1) hash for user music_archive — the $apr1$... format used by Apache/Squid for basic authentication.
Public background — how Squid stores this: Squid'sbasic_authscheme doesn't check credentials itself; it delegates to an external helper (commonlybasic_ncsa_auth), wired up insquid.confwith a line such asauth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd. That helper reads a standard htpasswd-format file — the same format Apache uses for HTTP Basic Auth — where each line isuser:$apr1$salt$hash. APR1 ("Apache MD5") is MD5 run through roughly 1,000 salted iterations: slower to crack than raw MD5, but still far weaker than modern KDFs like bcrypt/scrypt/yescrypt — well within reach ofjohn/hashcat(mode1600) against a wordlist likerockyou.
The lesson here: serving internal configuration files (/etc/squid/) through the web server is a serious information leak. They should never be reachable from the document root.3. Cracking the APR1 hash with John
With the hash in a file, we run John the Ripper against the rockyou wordlist. John auto-detects the APR1 format:
john passwd.hash --wordlist=/usr/share/wordlists/rockyou.txt
john --show passwd.hashResult:
music_archive:squidwardKeep this password:squidwardis not justmusic_archive's credential; later on it turns out to be the passphrase of the Borg repository. Password reuse is what chains the whole box together.
4. Downloading and extracting the site archive
In the site's admin panel (http://MACHINE_IP/admin, Archive → Download section) there is a downloadable archive.tar. We unpack it:
# after downloading archive.tar from http://MACHINE_IP/admin
tar -xvf archive.tarInside we find a Borg repository at home/field/dev/final_archive, with the typical Borg files: README, config, data/, index, nonce and integrity/hint files.
What Borg is:borgbackupis a deduplicating, encrypted backup tool. In its defaultrepokey/keyfileencryption modes, the repository key is derived from the passphrase (via PBKDF2) and used to drive AES-256 in CTR mode for confidentiality plus HMAC-SHA256 for integrity/authentication of every chunk. That is exactly why a repository is not read «by hand»: without the correct passphrase the on-diskdata/,indexandnoncefiles are opaque ciphertext, and only theborgclient can unwrap them.
5. Listing and extracting the Borg repository
We install borgbackup if missing and list the repository. The passphrase is the password we cracked earlier, squidward:
sudo apt-get update && sudo apt-get install -y borgbackup
borg list ./home/field/dev/final_archive
borg extract ./home/field/dev/final_archive::music_archiveWhy it works: borg list shows the repository's archives (snapshots) — here, one named music_archive. borg extract dumps its contents into the current directory. When prompted for the passphrase, we enter squidward.
After extracting, we inspect the recovered files looking for credentials:
grep -Rni "alex" .
cat home/alex/Documents/note.txtThe recovered note contains SSH credentials for user alex.
Chain so far: Squid hash leak → cracking → Borg passphrase → SSH credential theft from a backup. A «minor» flaw (exposed config file) becomes system access.
6. SSH access and user flag
With the recovered credentials, we log in over SSH as alex:
ssh alex@MACHINE_IPAnd read the user flag:
cat ~/user.txt7. Privilege escalation
First reflex after landing a user: check what we can run with sudo without a password:
sudo -lThe box escalates through a script executed with root privileges (something like backup.sh) that is abusable. Depending on how it is configured, the vector fits one of these two classic patterns:
- PATH injection: if the root script calls a binary by name (no absolute path), we create a malicious binary with that name and prepend its directory to
PATHbefore invoking it. - Writable script: if the script —or a file it executes— sits in a writable path, we replace it with one that spawns a shell.
Consistent approach: enumeratesudo -l, locate root-run scripts that are readable/writable, and analyze how they usePATHand which commands they invoke. That is where the escalation lives.
Once exploited, we confirm privileges and read the root flag:
id
cat /root/root.txtVulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Web | HTTP server | Squid configuration file (/etc/squid/passwd) exposed over HTTP | Leak of music_archive's APR1 hash |
| Credentials | APR1 hash | Weak password crackable with rockyou | Reused passphrase (squidward) |
| Backup | Borg repository | Encrypted backup downloadable with a known passphrase | SSH credentials for alex |
| PrivEsc | sudo / root-run script | Script runnable as root, abusable via PATH or write access | Execution as root |
Lessons learned
- Config leak: never serve internal files (
/etc/squid/) from the document root. A leaked hash is a starting point. - Password reuse:
squidwardwas both a web credential and the Borg passphrase. A single weak password toppled several layers. - Backups as a target: an encrypted backup is not safe if the passphrase is weak or stored elsewhere. They hold juicy secrets (here, SSH credentials).
- Sudoers hygiene: allowing a poorly written root-run script (PATH-based calls, writable files) is equivalent to handing out a root shell. Audit it.
2. Enumeración web y fuga del hash
Enumeramos rutas comunes e interesantes por fuerza bruta con una herramienta de descubrimiento de directorios:
gobuster dir -u http://MACHINE_IP/ -w /usr/share/wordlists/dirb/common.txt -x php,txtDestacan dos rutas: /admin (un panel de autenticación) y /etc, que resulta ser navegable y refleja el sistema de ficheros real de la máquina — una mala configuración grave por sí sola. Entrando en /etc/squid/ encontramos la configuración de Squid y su fichero de contraseñas servidos directamente por HTTP. Descargamos el fichero de contraseñas:
curl -s http://MACHINE_IP/etc/squid/passwd | tee passwd.hashEl contenido es un hash MD5-crypt (APR1) para el usuario music_archive — el formato $apr1$... usado por Apache/Squid para autenticación básica.
Contexto público — cómo lo guarda Squid: el esquemabasic_authde Squid no comprueba las credenciales por sí mismo; delega en un helper externo (habitualmentebasic_ncsa_auth), configurado ensquid.confcon una línea del tipoauth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd. Ese helper lee un fichero con el formato estándar htpasswd —el mismo que usa Apache para HTTP Basic Auth— donde cada línea esusuario:$apr1$salt$hash. APR1 ("Apache MD5") es MD5 aplicado en unas 1.000 iteraciones con sal; más lento de crackear que un MD5 plano, pero muy por debajo de KDFs modernas como bcrypt/scrypt/yescrypt — perfectamente al alcance dejohn/hashcat(modo1600) contra un diccionario comorockyou.
La lección aquí: servir ficheros de configuración internos (/etc/squid/) a través del servidor web es una fuga de información grave. Nunca deben ser accesibles desde el document root.3. Crackeo del hash APR1 con John
Con el hash en un fichero, lanzamos John the Ripper contra el diccionario rockyou. John detecta automáticamente el formato APR1:
john passwd.hash --wordlist=/usr/share/wordlists/rockyou.txt
john --show passwd.hashResultado:
music_archive:squidwardGuarda esta contraseña:squidwardno solo sirve como credencial demusic_archive; más adelante resulta ser la passphrase del repositorio Borg. La reutilización de contraseñas es la que encadena toda la máquina.
4. Descarga y extracción del archivo del sitio
En el panel de administración del sitio (http://MACHINE_IP/admin, sección Archive → Download) hay un archive.tar descargable. Lo desempaquetamos:
# tras descargar archive.tar desde http://MACHINE_IP/admin
tar -xvf archive.tarDentro aparece un repositorio Borg en home/field/dev/final_archive, con los ficheros típicos de Borg: README, config, data/, index, nonce y ficheros de integridad/hints.
Qué es Borg:borgbackupes una herramienta de copias de seguridad deduplicadas y cifradas. En sus modos de cifrado por defecto (repokey/keyfile), la clave del repositorio se deriva de la passphrase (vía PBKDF2) y se usa para aplicar AES-256 en modo CTR como confidencialidad más HMAC-SHA256 como integridad/autenticación de cada fragmento. Por eso un repositorio no se lee «a mano»: sin la passphrase correcta, los ficherosdata/,indexynonceen disco son texto cifrado opaco, y solo el clienteborgpuede desentrañarlos.
5. Listado y extracción del repositorio Borg
Instalamos borgbackup si no lo tenemos y listamos el repositorio. La passphrase es la contraseña que crackeamos antes, squidward:
sudo apt-get update && sudo apt-get install -y borgbackup
borg list ./home/field/dev/final_archive
borg extract ./home/field/dev/final_archive::music_archivePor qué funciona: borg list muestra los archives (snapshots) del repositorio — aquí, uno llamado music_archive. borg extract vuelca su contenido al directorio actual. Cuando pida la passphrase, introducimos squidward.
Tras extraer, inspeccionamos los ficheros recuperados buscando credenciales:
grep -Rni "alex" .
cat home/alex/Documents/note.txtLa nota recuperada contiene credenciales SSH del usuario alex.
Cadena hasta aquí: fuga del hash de Squid → crackeo → passphrase de Borg → robo de credenciales SSH desde un backup. Un fallo «menor» (fichero de config expuesto) se convierte en acceso al sistema.
6. Acceso SSH y user flag
Con las credenciales recuperadas, entramos por SSH como alex:
ssh alex@MACHINE_IPY leemos la flag de usuario:
cat ~/user.txt7. Escalada de privilegios
Primer reflejo tras conseguir un usuario: revisar qué podemos ejecutar con sudo sin contraseña:
sudo -lLa máquina permite escalar a través de un script ejecutado con privilegios de root (tipo backup.sh) que es abusable. Según cómo esté configurado, el vector encaja en uno de estos dos patrones clásicos:
- Inyección de PATH: si el script root llama a un binario por su nombre (sin ruta absoluta), creamos un binario malicioso con ese nombre y anteponemos su directorio al
PATHantes de invocarlo. - Script escribible: si el script —o un fichero que ejecuta— está en una ruta escribible, lo sustituimos por uno que lance una shell.
Enfoque consistente: enumerarsudo -l, localizar scripts ejecutados como root que sean legibles/escribibles, y analizar cómo usan elPATHy qué comandos invocan. Ahí está la escalada.
Una vez explotado, confirmamos privilegios y leemos la flag de root:
id
cat /root/root.txtResumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Web | Servidor HTTP | Fichero de configuración de Squid (/etc/squid/passwd) expuesto por HTTP | Fuga del hash APR1 de music_archive |
| Credenciales | Hash APR1 | Contraseña débil crackeable con rockyou | Passphrase reutilizada (squidward) |
| Backup | Repositorio Borg | Backup cifrado descargable con passphrase conocida | Credenciales SSH de alex |
| PrivEsc | sudo / script root-run | Script ejecutable como root, abusable vía PATH o escritura | Ejecución como root |
Lecciones aprendidas
- Fuga de configuración: nunca sirvas ficheros internos (
/etc/squid/) desde el document root. Un hash filtrado es un punto de partida. - Reutilización de contraseñas:
squidwardera credencial web y passphrase de Borg. Una sola contraseña débil derribó varias capas. - Backups como objetivo: un backup cifrado no es seguro si la passphrase es débil o está en otro sitio. Contienen secretos jugosos (aquí, credenciales SSH).
- Higiene de
sudoers: permitir un script root-run mal escrito (llamadas por PATH, ficheros escribibles) equivale a regalar una shell de root. Audítalo.