Format

1. Initial recon

1.1. nmap

nmap -sC -sV 10.10.11.213

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 c397ce837d255d5dedb545cdf20b054f (RSA)
|   256 b3aa30352b997d20feb6758840a517c1 (ECDSA)
|_  256 fab37d6e1abcd14b68edd6e8976727d7 (ED25519)
80/tcp   open  http    nginx 1.18.0
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: nginx/1.18.0
3000/tcp open  http    nginx 1.18.0
|_http-title: Did not follow redirect to http://microblog.htb:3000/
|_http-server-header: nginx/1.18.0
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

add microblog.htb to /etc/hosts

1.2. Dirbuster

dirb http://10.10.11.213

Leads us to app.microblog.htb. also add this to /etc/hosts

2. Achieving Local File Inclusion

  1. Make a blog

  2. Make a h1 or txt

  3. Capture the request in BurpSuite then we can change the ID parameter in the request to achieve lfi

/etc/passwd

/etc/hosts

3. User.txt

3.1. Becoming pro

We can see in the sourcecode found at http://microblog.htb:3000/cooper/microblog/src/branch/main/microblog/sunny/edit/index.php that there is calls to system, definitely an opportunity here to achieve a reverse shell within the $blogName parameter, we just need to be Pro.

Since the web app uses REDIS as its database we can use the following curl command to make ourselves pro

Furthermore, from the sourcecode above we can indentify that our uploads will be at /var/www/microblog/asdf/uploads so we can upload a php reverse shell, in the same way we achieved LFI earlier.

So, we can make a h1 or a txt on our blog and edit the parameters of the POST request to be

and visit http://asdf.microblog.htb/uploads/revshell.php while our netcat listener is running to catch a reverse shell.

It's also interesting to note as well from the source code that we can see that files that are written to the /content/ folder are wrapped in <div></div> tags, meaning that we are not able to simply upload our reverse shell to /content. Furthermore we can see that our /uploads directory is created when we are pro, in the provisionProUser function as seen in the codeblock above

3.2. enumerating the database

With our reverse shell we can connect to the redis database using redis-cli -s /run/redis/redis.sock

Then, KEYS * to reveal the database keys, more specifically the cooper.dooper key Then, HGETALL cooper.dooper to dump the database, including the password for the user cooper

now we can ssh into the machine with the credentials cooper:zooperdoopercooper

user.txt can be found at /home/cooper

4. root.txt

sudo -l reveals that we can run /usr/bin/license as root

we can see that in the source code that there is a variable secret being loaded in from the file /root/license/secret so we can take advantage of this and use a format string to extract it.

Again, connecting to the redis database using redis-cli -s /run/redis/redis.sock we can then run the command

then sudo /usr/bin/license -p asdf to reveal the secret unCR4ckaBL3Pa$$w0rd

and then ssh into the machine as root with the password.

as always root.txt is found at /root

Was this helpful?