Cap - HackTheBox

131885085-6f7f605b-d841-42de-98b2-39de0ee3d544 (4)

Comence con un escaneo de Nmap para detectar puertos abiertos.

┌──(root💀kali)-[/home/…/HTB/Cap/machine/nmap]
└─# nmap -sS --min-rate=5000 -vvv -n -Pn --open 10.10.10.245 -o targeted.txt
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
Warning: The -o option is deprecated. Please use -oN
Starting Nmap 7.91 ( https://nmap.org ) at 2021-10-10 11:11 EDT
Initiating SYN Stealth Scan at 11:11
Scanning 10.10.10.245 [1000 ports]
Discovered open port 21/tcp on 10.10.10.245
Discovered open port 22/tcp on 10.10.10.245
Discovered open port 80/tcp on 10.10.10.245
Completed SYN Stealth Scan at 11:11, 1.52s elapsed (1000 total ports)
Nmap scan report for 10.10.10.245
Host is up, received user-set (1.1s latency).
Scanned at 2021-10-10 11:11:51 EDT for 2s
Not shown: 608 closed ports, 389 filtered ports
Reason: 608 resets and 389 no-responses
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT   STATE SERVICE REASON
21/tcp open  ftp 	syn-ack ttl 63
22/tcp open  ssh 	syn-ack ttl 63
80/tcp open  http	syn-ack ttl 63
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 1.62 seconds

Tenia 3 puertos abiertos, hice otro escaneo pare enumerar la version de cada puerto abierto.

┌──(root💀kali)-[/home/…/HTB/Cap/machine/nmap]
└─# nmap -sCV -p21,22,80 10.10.10.245 -o webScan.txt                                                                                    	130 ⨯
Starting Nmap 7.91 ( https://nmap.org ) at 2021-10-10 11:29 EDT
Nmap scan report for 10.10.10.245
Host is up (0.045s latency).

PORT   STATE SERVICE VERSION
21/tcp open  ftp 	vsftpd 3.0.3
22/tcp open  ssh 	OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 fa:80:a9:b2:ca:3b:88:69:a4:28:9e:39:0d:27:d5:75 (RSA)
|   256 96:d8:f8:e3:e8:f7:71:36:c5:49:d5:9d:b6:a4:c9:0c (ECDSA)
|_  256 3f:d0:ff:91:eb:3b:f6:e1:9f:2e:8d:de:b3:de:b2:18 (ED25519)
80/tcp open  http	gunicorn
| fingerprint-strings:
|   FourOhFourRequest:
| 	HTTP/1.0 404 NOT FOUND
| 	Server: gunicorn
| 	Date: Sun, 10 Oct 2021 15:30:32 GMT
| 	Connection: close
| 	Content-Type: text/html; charset=utf-8
| 	Content-Length: 232
| 	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
| 	<title>404 Not Found</title>
| 	<h1>Not Found</h1>
| 	<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
|   GetRequest:
| 	HTTP/1.0 200 OK
| 	Server: gunicorn
| 	Date: Sun, 10 Oct 2021 15:30:26 GMT
| 	Connection: close
| 	Content-Type: text/html; charset=utf-8
| 	Content-Length: 19386
| 	<!DOCTYPE html>
| 	<html class="no-js" lang="en">
| 	<head>                                                                                                                                 	 
| 	<meta charset="utf-8">
| 	<meta http-equiv="x-ua-compatible" content="ie=edge">
| 	<title>Security Dashboard</title>
| 	<meta name="viewport" content="width=device-width, initial-scale=1">
| 	<link rel="shortcut icon" type="image/png" href="/static/images/icon/favicon.ico">
| 	<link rel="stylesheet" href="/static/css/bootstrap.min.css">
| 	<link rel="stylesheet" href="/static/css/font-awesome.min.css">
| 	<link rel="stylesheet" href="/static/css/themify-icons.css">
| 	<link rel="stylesheet" href="/static/css/metisMenu.css">
| 	<link rel="stylesheet" href="/static/css/owl.carousel.min.css">
| 	<link rel="stylesheet" href="/static/css/slicknav.min.css">
| 	<!-- amchar
|   HTTPOptions:
| 	HTTP/1.0 200 OK
| 	Server: gunicorn
| 	Date: Sun, 10 Oct 2021 15:30:27 GMT
| 	Connection: close
| 	Content-Type: text/html; charset=utf-8
| 	Allow: OPTIONS, GET, HEAD
| 	Content-Length: 0
|   RTSPRequest:
| 	HTTP/1.1 400 Bad Request
| 	Connection: close
| 	Content-Type: text/html
| 	Content-Length: 196
| 	<html>
| 	<head>
| 	<title>Bad Request</title>
| 	</head>
| 	<body>
| 	<h1><p>Bad Request</p></h1>
| 	Invalid HTTP Version &#x27;Invalid HTTP Version: &#x27;RTSP/1.0&#x27;&#x27;
| 	</body>
|_	</html>
|_http-server-header: gunicorn
|_http-title: Security Dashboard
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port80-TCP:V=7.91%I=7%D=10/10%Time=616306DE%P=x86_64-pc-linux-gnu%r(Get
SF:Request,1AD7,"HTTP/1\.0\x20200\x20OK\r\nServer:\x20gunicorn\r\nDate:\x2
SF:0Sun,\x2010\x20Oct\x202021\x2015:30:26\x20GMT\r\nConnection:\x20close\r
SF:\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length:\x2019
SF:386\r\n\r\n<!DOCTYPE\x20html>\n<html\x20class=\"no-js\"\x20lang=\"en\">
SF:\n\n<head>\n\x20\x20\x20\x20<meta\x20charset=\"utf-8\">\n\x20\x20\x20\x
SF:20<meta\x20http-equiv=\"x-ua-compatible\"\x20content=\"ie=edge\">\n\x20
SF:\x20\x20\x20<title>Security\x20Dashboard</title>\n\x20\x20\x20\x20<meta
SF:\x20name=\"viewport\"\x20content=\"width=device-width,\x20initial-scale
SF:=1\">\n\x20\x20\x20\x20<link\x20rel=\"shortcut\x20icon\"\x20type=\"imag
SF:e/png\"\x20href=\"/static/images/icon/favicon\.ico\">\n\x20\x20\x20\x20
SF:<link\x20rel=\"stylesheet\"\x20href=\"/static/css/bootstrap\.min\.css\"
SF:>\n\x20\x20\x20\x20<link\x20rel=\"stylesheet\"\x20href=\"/static/css/fo
SF:nt-awesome\.min\.css\">\n\x20\x20\x20\x20<link\x20rel=\"stylesheet\"\x2
SF:0href=\"/static/css/themify-icons\.css\">\n\x20\x20\x20\x20<link\x20rel
SF:=\"stylesheet\"\x20href=\"/static/css/metisMenu\.css\">\n\x20\x20\x20\x
SF:20<link\x20rel=\"stylesheet\"\x20href=\"/static/css/owl\.carousel\.min\
SF:.css\">\n\x20\x20\x20\x20<link\x20rel=\"stylesheet\"\x20href=\"/static/
SF:css/slicknav\.min\.css\">\n\x20\x20\x20\x20<!--\x20amchar")%r(HTTPOptio
SF:ns,B3,"HTTP/1\.0\x20200\x20OK\r\nServer:\x20gunicorn\r\nDate:\x20Sun,\x
SF:2010\x20Oct\x202021\x2015:30:27\x20GMT\r\nConnection:\x20close\r\nConte
SF:nt-Type:\x20text/html;\x20charset=utf-8\r\nAllow:\x20OPTIONS,\x20GET,\x
SF:20HEAD\r\nContent-Length:\x200\r\n\r\n")%r(RTSPRequest,121,"HTTP/1\.1\x
SF:20400\x20Bad\x20Request\r\nConnection:\x20close\r\nContent-Type:\x20tex
SF:t/html\r\nContent-Length:\x20196\r\n\r\n<html>\n\x20\x20<head>\n\x20\x2
SF:0\x20\x20<title>Bad\x20Request</title>\n\x20\x20</head>\n\x20\x20<body>
SF:\n\x20\x20\x20\x20<h1><p>Bad\x20Request</p></h1>\n\x20\x20\x20\x20Inval
SF:id\x20HTTP\x20Version\x20&#x27;Invalid\x20HTTP\x20Version:\x20&#x27;RTS
SF:P/1\.0&#x27;&#x27;\n\x20\x20</body>\n</html>\n")%r(FourOhFourRequest,18
SF:9,"HTTP/1\.0\x20404\x20NOT\x20FOUND\r\nServer:\x20gunicorn\r\nDate:\x20
SF:Sun,\x2010\x20Oct\x202021\x2015:30:32\x20GMT\r\nConnection:\x20close\r\
SF:nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length:\x20232
SF:\r\n\r\n<!DOCTYPE\x20HTML\x20PUBLIC\x20\"-//W3C//DTD\x20HTML\x203\.2\x2
SF:0Final//EN\">\n<title>404\x20Not\x20Found</title>\n<h1>Not\x20Found</h1
SF:>\n<p>The\x20requested\x20URL\x20was\x20not\x20found\x20on\x20the\x20se
SF:rver\.\x20If\x20you\x20entered\x20the\x20URL\x20manually\x20please\x20c
SF:heck\x20your\x20spelling\x20and\x20try\x20again\.</p>\n");
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

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

Comence enumerando FTP y ver si tenia acceso con el usuario anonymous, pero no hubo suerte.

https://imgur.com/M0KV2nt.png

Vi lo que tenia el servidor web.

https://imgur.com/fjq868h.png

Tambien enumere las distinas secciones que tenia, en Security Snapshot habia lo siguiente.

https://imgur.com/M7s4QRE.png

El numero de la URL me llamo la atencion, pero segui enumerando para ver si encontraba otra cosa,Network Status tenia lo siguiente.

https://imgur.com/eEWyvQV.png

Al parecer era un comando ejecutado a nivel de sistema, volviendo a la Security Snapshot vi que me descargaba un archivo .pcap, estos archivos contienen informacion de trafico de paquetes, puse uno en la URL y me reporto lo siguiente.

https://imgur.com/L6Fq5l3.png

Al escanerlo con WireShark no encontré nada interesante, volvi a probar y puse un 0 en la URL y la respuesta fue diferente.

https://imgur.com/76R4oOs.png

Decidi descargarmelo y ver que contenia.

https://imgur.com/gQhR0pr.png

Al verlo con WireShark encontré una credencial en texto plano.

https://imgur.com/Zff14Xl.png

Probe a autenticarme a SSH con la credencial que habia conseguido y el usuario nathan que habia en la web y funciono.

https://imgur.com/7jst8af.png

Ya pude visualizar la “flag” del usuario.

0fXqDsB


ESCALADA DE PRIVILEGIOS

Para la escalada de privilgios empece enumerando permisos SUID, pero no encontre nada interesante.

https://imgur.com/O0SWvUL.png

Tras enumerar las cababilities encontre /usr/bin/python3.8 = cap_setuid, esta capabilitie me permitia cambiarme el UID y operar con otro, lo que hice fue cambia mi UID a 0 que corresponde a root y ya pude visualizar la “flag”.

7ZWOToK

Leave a comment