Overview
Athena is an easy-rated TryHackMe box that chains a leaked internal path
(found via an anonymous SMB share) into a command injection vulnerability in
a "router panel" ping tool, followed by a writable backup script abused via
a systemd service running as a second user, and finished off with a
misconfigured sudo rule that lets that user load an arbitrary kernel
module - in this case a customized build of the
Diamorphine LKM rootkit that grants
instant root via a magic signal.
Recon
nmap -A -Pn <MACHINE_IP> -o map
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Athena - Gods of olympus
139/tcp open netbios-ssn Samba smbd 4
445/tcp open netbios-ssn Samba smbd 4
Host script results:
| smb2-security-mode:
| 3.1.1:
|_ Message signing enabled but not required
|_nbstat: NetBIOS name: ROUTERPANEL, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
Three services in scope: SSH, an Apache-hosted site themed around the
goddess Athena, and Samba/SMB. The NetBIOS name ROUTERPANEL was an early
hint at what was hiding behind the web app.
Web Enumeration
The homepage (curl http://<MACHINE_IP>/) is a static lore page about
Athena - no obvious functionality, just flavor text and an image.
Directory brute-forcing turned up nothing interesting:
ffuf -u http://<MACHINE_IP>/FUZZ -w /usr/share/wordlists/dirb/big.txt
.htaccess [Status: 403, Size: 278, Words: 20, Lines: 10, Duration: 4348ms]
.htpasswd [Status: 403, Size: 278, Words: 20, Lines: 10, Duration: 4346ms]
server-status [Status: 403, Size: 278, Words: 20, Lines: 10, Duration: 57ms]
whatweb http://<MACHINE_IP>
http://<MACHINE_IP> [200 OK] Apache[2.4.41], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.41 (Ubuntu)], Meta-Author[matheuz], Title[Athena - Gods of olympus]
Nothing actionable on the web side by itself - moved to SMB.
SMB Enumeration
nxc smb <MACHINE_IP> -u guest -p ''
SMB <MACHINE_IP> 445 ROUTERPANEL [*] Unix - Samba (name:ROUTERPANEL) (domain:ROUTERPANEL) (signing:False) (SMBv1:None) (Null Auth:True)
SMB <MACHINE_IP> 445 ROUTERPANEL [-] ROUTERPANEL\guest: STATUS_LOGON_FAILURE
Guest failed, but null auth was flagged as supported - tried a blank
username instead:
nxc smb <MACHINE_IP> -u '' -p ''
SMB <MACHINE_IP> 445 ROUTERPANEL [+] ROUTERPANEL\:
Successful anonymous login. Enumerated shares:
nxc smb <MACHINE_IP> -u '' -p '' --shares
Share Permissions Remark
----- ----------- ------
public READ
IPC$ IPC Service (Samba 4.15.13-Ubuntu)
Connected and grabbed the one file on offer:
smbclient //<MACHINE_IP>/Public -N
smb: \> ls
msg_for_administrator.txt N 253 Sun Apr 16 20:54:43 2023
smb: \> get msg_for_administrator.txt
cat msg_for_administrator.txt
Dear Administrator,
I would like to inform you that a new Ping system is being developed and I left the corresponding application in a specific path, which can be accessed through the following address: /myrouterpanel
Yours sincerely,
Athena
Intern
An internal note leaking a hidden path - classic case of secrets ending up
on an anonymously readable share.
Finding the Router Panel
curl http://<MACHINE_IP>/myrouterpanel/