Post

Hack The Box Mirai

Mirai

Se procede con la fase de reconocimiento lanzando primeramente un ping a la dirección IP 10.10.10.48.

1
2
3
4
5
6
7
❯ ping -c 1 10.10.10.48
PING 10.10.10.48 (10.10.10.48) 56(84) bytes of data.
64 bytes from 10.10.10.48: icmp_seq=1 ttl=63 time=137 ms

--- 10.10.10.48 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 136.993/136.993/136.993/0.000 ms

De acuerdo con el TTL de traza ICMP, se puede determinar que se trata de una máquina con sistema operativo Linux. A continuación se procede con la ejecución de nmap para determinar los puertos abiertos de la máquina y exportanto la información al archivo allPorts.

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
❯ nmap -p- --open -T5 -v -n 10.10.10.48 -oG allPorts
Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-27 14:05 CST
Initiating Ping Scan at 14:05
Scanning 10.10.10.48 [4 ports]
Completed Ping Scan at 14:05, 0.16s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 14:05
Scanning 10.10.10.48 [65535 ports]
Discovered open port 53/tcp on 10.10.10.48
Discovered open port 80/tcp on 10.10.10.48
Discovered open port 22/tcp on 10.10.10.48
Discovered open port 1195/tcp on 10.10.10.48
Discovered open port 32400/tcp on 10.10.10.48
Discovered open port 32469/tcp on 10.10.10.48
Completed SYN Stealth Scan at 14:06, 39.69s elapsed (65535 total ports)
Nmap scan report for 10.10.10.48
Host is up (0.14s latency).
Not shown: 65529 closed tcp ports (reset)
PORT      STATE SERVICE
22/tcp    open  ssh
53/tcp    open  domain
80/tcp    open  http
1195/tcp  open  rsf-1
32400/tcp open  plex
32469/tcp open  unknown

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 40.01 seconds
           Raw packets sent: 68248 (3.003MB) | Rcvd: 68201 (2.728MB)

Mediante la función extractPorts definida a nivel de zsh , se obtiene la información más relevante de la captura grepeable.

1
2
3
4
5
6
7
8
9
10
11
❯ extractPorts allPorts
───────┬───────────────────────────────────────────────
       │ File: extractPorts.tmp
───────┼───────────────────────────────────────────────
   1   │ 
   2   │ [*] Extracting information...
   3   │ 
   4   │     [*] IP Address: 10.10.10.48
   5   │     [*] Open ports: 22,53,80,1195,32400,32469
   6   │ 
   7   │ [*] Ports copied to clipboard

A continuación se lanza una serie de scripts para determinar el servicio y versión que corren para los puertos detectados.

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
❯ nmap -sC -sV -p22,53,80,1195,32400,32469 10.10.10.48 -oN targeted
Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-27 14:08 CST
Nmap scan report for 10.10.10.48
Host is up (0.14s latency).

PORT      STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 6.7p1 Debian 5+deb8u3 (protocol 2.0)
| ssh-hostkey: 
|   1024 aa:ef:5c:e0:8e:86:97:82:47:ff:4a:e5:40:18:90:c5 (DSA)
|   2048 e8:c1:9d:c5:43:ab:fe:61:23:3b:d7:e4:af:9b:74:18 (RSA)
|   256 b6:a0:78:38:d0:c8:10:94:8b:44:b2:ea:a0:17:42:2b (ECDSA)
|_  256 4d:68:40:f7:20:c4:e5:52:80:7a:44:38:b8:a2:a7:52 (ED25519)
53/tcp    open  domain  dnsmasq 2.76
| dns-nsid: 
|_  bind.version: dnsmasq-2.76
80/tcp    open  http    lighttpd 1.4.35
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
|_http-server-header: lighttpd/1.4.35
1195/tcp  open  upnp    Platinum UPnP 1.0.5.13 (UPnP/1.0 DLNADOC/1.50)
32400/tcp open  http    Plex Media Server httpd
|_http-favicon: Plex
|_http-title: Unauthorized
| http-auth: 
| HTTP/1.1 401 Unauthorized\x0D
|_  Server returned status 401 but no WWW-Authenticate header.
|_http-cors: HEAD GET POST PUT DELETE OPTIONS
32469/tcp open  upnp    Platinum UPnP 1.0.5.13 (UPnP/1.0 DLNADOC/1.50)
Service Info: OS: 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 22.08 seconds

Vamos a empezar analizando los servicio HTTP y vemos los puertos 80 y 32400; así que antes de ver vía web vamos a usar whatweb:

1
2
3
4
❯ whatweb http://10.10.10.48/
http://10.10.10.48/ [404 Not Found] Country[RESERVED][ZZ], HTTPServer[lighttpd/1.4.35], IP[10.10.10.48], UncommonHeaders[x-pi-hole], lighttpd[1.4.35]
❯ whatweb http://10.10.10.48:32400/
http://10.10.10.48:32400/ [401 Unauthorized] Country[RESERVED][ZZ], IP[10.10.10.48], Script, Title[Unauthorized], UncommonHeaders[x-plex-protocol,x-plex-content-original-length,x-plex-content-compressed-length]

Ahora vamos a tratar de ver el contenido vía web y tenemos que para el puerto 80 no se observa nada y sobre el 32400 tenemos el servicio Plex, del cual si buscamos un poco, vemos que no presenta credenciales por defecto.

""

Como por el puerto 80 no observamos nada, podríamos pensar que se está aplicando virtual hosting, así que de acuerdo con la plataforma HackTheBox, podríamos tratar de agregar al archivo /etc/hosts el dominio mira.htb y trataremos de visualizar la web nuevamente.

""

Ahora si nos muestra contenido y algo curioso, un banner indicando que If you have an ongoing use for this website, please ask the owner of the Pi-hole in your network to have it whitelisted., traduciendo: Si tiene un uso continuo de este sitio web, solicite al propietario del Pi-hole en su red que lo incluya en la lista blanca.. Aqui nos está indicando que se trata de la aplicación Pi-hole la cual se utiliza para el bloqueo de anuncios y rastreadores en Internet a nivel de red en Linux y que actúa como un sumidero de DNS, destinado para su uso en una red privada.

Si buscamos un poco sobre Pi-hole, encontraremos que se encuentra asociada a una raspberry, por lo que existen credenciales default de acceso por ssh, las cuales son pi : raspberry. Asi que vamos a tratar de acceder por ssh a ver si tenemos suerte.

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
❯ ssh pi@10.10.10.48
The authenticity of host '10.10.10.48 (10.10.10.48)' can't be established.
ECDSA key fingerprint is SHA256:UkDz3Z1kWt2O5g2GRlullQ3UY/cVIx/oXtiqLPXiXMY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.10.48' (ECDSA) to the list of known hosts.
pi@10.10.10.48's password: 

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Aug 27 14:47:50 2017 from localhost

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.


SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $ whoami
pi
pi@raspberrypi:~ $

Ya nos encontramos dentro de la máquina y podemos visualizar la flag (user.txt). Ahora vamos a tratar de escalar privilegios, por lo que vamos a enumrar un poco el sistema.

1
2
3
pi@raspberrypi:~/Desktop $ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),101(input),108(netdev),117(i2c),998(gpio),999(spi)
pi@raspberrypi:~/Desktop $

Nos encontramos dentro del grupo sudo, por lo que ya podemos ser el usuario root:

1
2
3
4
pi@raspberrypi:~/Desktop $ sudo su
root@raspberrypi:/home/pi/Desktop# whoami
root
root@raspberrypi:/home/pi/Desktop# 

A este punto podriamos tratar de visualizar la flag (root.txt), pero al hacer, nos aparece una leyenda.

1
2
3
4
5
6
7
root@raspberrypi:/home/pi/Desktop# cd /root/
root@raspberrypi:~# ls -l
total 4
-rw-r--r-- 1 root root 76 Aug 14  2017 root.txt
root@raspberrypi:~# cat root.txt 
I lost my original root.txt! I think I may have a backup on my USB stick...
root@raspberrypi:~#

Nos indica que la flag original se encuentra dentro de una USB stick; por lo que vamos a validar si se tiene una USB conectada al equipo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@raspberrypi:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
aufs            8.5G  2.8G  5.3G  34% /
tmpfs           100M  4.8M   96M   5% /run
/dev/sda1       1.3G  1.3G     0 100% /lib/live/mount/persistence/sda1
/dev/loop0      1.3G  1.3G     0 100% /lib/live/mount/rootfs/filesystem.squashfs
tmpfs           250M     0  250M   0% /lib/live/mount/overlay
/dev/sda2       8.5G  2.8G  5.3G  34% /lib/live/mount/persistence/sda2
devtmpfs         10M     0   10M   0% /dev
tmpfs           250M  8.0K  250M   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           250M     0  250M   0% /sys/fs/cgroup
tmpfs           250M  8.0K  250M   1% /tmp
/dev/sdb        8.7M   93K  7.9M   2% /media/usbstick
tmpfs            50M     0   50M   0% /run/user/999
tmpfs            50M     0   50M   0% /run/user/1000
root@raspberrypi:~# 

Vemos una montura bajo la ruta /media/usbstick asi que vamos a echarle un ojo:

1
2
3
4
5
6
7
8
9
10
11
root@raspberrypi:~# cd /media/usbstick
root@raspberrypi:/media/usbstick# ls -l
total 13
-rw-r--r-- 1 root root   129 Aug 14  2017 damnit.txt
drwx------ 2 root root 12288 Aug 14  2017 lost+found
root@raspberrypi:/media/usbstick# cat damnit.txt 
Damnit! Sorry man I accidentally deleted your files off the USB stick.
Do you know if there is any way to get them back?

-James
root@raspberrypi:/media/usbstick# 

Tenemos un mensaje de James quien nos dice que accidentalmente borró los archivos dentro de la USB. En este punto, podríamos tratar de obsevar el histórico bajo la partición asociada a la USB:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
root@raspberrypi:/media/usbstick# strings /dev/sdb
>r &
/media/usbstick
lost+found
root.txt
damnit.txt
>r &
>r &
/media/usbstick
lost+found
root.txt
damnit.txt
>r &
/media/usbstick
2]8^
lost+found
root.txt
damnit.txt
>r &
3d3e4831
Damnit! Sorry man I accidentally deleted your files off the USB stick.
Do you know if there is any way to get them back?
-James
root@raspberrypi:/media/usbstick#

De esta forma ya podríamos visualizar la flag (root.txt).

This post is licensed under CC BY 4.0 by the author.