Overview

Nibbles is an easy HackTheBox Linux machine running Nibbleblog 4.0.3, a blogging platform hidden behind a mostly blank landing page whose source code gives away its location. Default administrative credentials grant access to the admin panel, and CVE-2015-6967, a known arbitrary file upload vulnerability in this version, is exploited manually to plant a PHP webshell and get a reverse shell. Privilege escalation is a straightforward case of a sudo-permitted script also being writable by the same user, letting a root user be created outright.

Attack Chain

  • Scan the target and identify SSH and HTTP
  • Find a mostly blank landing page and locate /nibbleblog in the page source
  • Fuzz /nibbleblog and confirm it’s running Nibbleblog 4.0.3 via its README
  • Log in to the admin panel with default credentials, admin:nibbles
  • Identify CVE-2015-6967, an authenticated arbitrary file upload vulnerability affecting this version
  • Manually exploit the vulnerability to upload a PHP webshell to a predictable plugin path
  • Trigger the webshell and use an nc mkfifo reverse shell payload to catch a shell
  • Read the user flag
  • Find a sudo-permitted script, monitor.sh, that’s also writable by the current user
  • Edit the script to add a new root-equivalent user
  • Run the script with sudo to trigger the edit, then switch to the new user
  • Read the root flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan.

export IP=10.129.215.169; export NAME=NIBBLES; echo $IP; echo $NAME; ping $IP -c 1

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -Pn -p- -v -oA scans/nmap_allports_$NAME

The open TCP ports are:

22,80

We export the discovered ports and run a service and version scan.

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

nmap $IP -p$ports -sC -sV -oA scans/nmap_initial_$NAME -v

nmap results


Web Enumeration

Finding Nibbleblog

Browsing to port 80 shows a basic text page with nothing else.

basic text landing page

We look at the source code and find a new endpoint, /nibbleblog.

source code reveals /nibbleblog

We fuzz the site.

dirsearch -u http://$IP:$PORT/nibbleblog -t 100 -o ./scans/dirsearch_${NAME}_${PORT}_nibble_default.txt

We find a few endpoints.

dirsearch finds several endpoints

/nibbleblog is a basic blogging setup.

Nibbleblog setup

We view the /README endpoint and find the version, Nibbleblog 4.0.3.

README reveals the version

/admin.php is a login portal.

admin login portal

We’re able to log in with default credentials, admin:nibbles.

logging in with default credentials


Foothold

Exploiting CVE-2015-6967

CVE-2015-6967 is an arbitrary file upload vulnerability affecting Nibbleblog 4.0.3:

https://nvd.nist.gov/vuln/detail/CVE-2015-6967

According to the advisory, we can upload a malicious PHP file to /content/private/plugins/my_image/image.php. Public exploits exist, but we do it manually.

manually exploiting the upload vulnerability - step 1

manually exploiting the upload vulnerability - step 2

We navigate to /nibbleblog/content/private/plugins/my_image/image.php and have a webshell.

webshell accessible at the plugin path

Reverse Shell

We use an nc mkfifo reverse shell payload.

nc mkfifo reverse shell payload

We catch our shell on port 443 with penelope.

shell caught with penelope

We read the user flag.

user flag


Privilege Escalation

An Editable Sudo Script

We check our privileges with sudo -l.

We can run /home/nibbler/personal/stuff/monitor.sh as root.

sudo -l shows monitor.sh

We’re able to edit the script.

the script is writable

We edit it to add a new root-equivalent user.

useradd -o -u 0 -s /bin/bash toor ; echo toor:toor | chpasswd

the modified script

We execute the script through sudo. A few error messages appear, but they don’t concern us.

executing the modified script

We check /etc/passwd and see our toor user was added.

toor user added to /etc/passwd

We switch to our new root user.

switching to the toor user

We read the root flag.

root flag


Key Takeaways

Nibbles is a clean demonstration of two everyday mistakes. Default administrative credentials on a self-hosted application are effectively no authentication at all once discovered, and they immediately opened the door to a documented, unpatched file upload vulnerability. The privilege escalation is even simpler: granting sudo access to a script only provides a meaningful security boundary if that same script is also protected from modification by the user running it, here, both conditions were controlled by the same low-privileged account, collapsing the intended privilege separation entirely.