Skip to main content

Cap HTB Walkthrough

Welcome to another Hack the Box challenge. Today, we are going to try and pwn the Cap machine on Hack The Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment and subscribe to my YouTube channel (https://www.youtube.com/@BoltechTechnologies1) and follow me on LinkedIn (https://www.linkedin.com/in/isiaq-ibrahim-468588156/) for more updates.


About the Machine

The HTB machine "Cap" is an easy-level Linux machine with an HTTP server that allows users to capture non-encrypted traffic. It provides opportunities to exploit vulnerabilities, including an insecure direct object reference (IDOR) on its website. The capture contains plaintext credentials and can be used to gain foothold. A Linux capability is then leveraged to escalate to root.

Cap Hack the Box Walkthrough

About the Vulnerability

Cap HTB machine has two security flaws. One, is a website with an insecure direct object reference (IDOR) vulnerability, that stores a Wireshark packet file and also allow you to view and download other users Wireshark packet file by editing the URL header. This vulnerability allow users of the website access FTP credentials of other users, thereby allowing SSH access as that user.


How to pwn the machine

Like every other machine, the first step is downloading the lab access file on Hack the Box and connecting Kali Linux terminal to Hack the Box server by running the following command in Kali Linux terminal:

sudo openvpn cap.ovpn

After connecting Kali Linux terminal with Hack the Box server, the next step was performing Nmap enumeration to find open ports that are available on the host machine by running the following commands in the terminal:

nmap enumeration nmap -sV -Pn -T5 -vvvv cap.ovpn

I found three ports open on the targets machine, which includes 21/tcp, 22/tcp and 80/tcp. Once, the nmap scan has been successfully completed, the next step was adding the IP address of the cap machine to the /etc/hosts file by running the following commands in the terminal:

sudo nano /etc/hosts

sudo nano /etc/hosts 10.10.10.245 cap.ovpn

Once I have added this to the /etc/hosts file, to save the file, I pressed and hold Ctrl + X to save, press Y to modify the buffer and X to exit. Next, I visited 10.10.10.245 on my browser and I was redirected to the security dashboard of the cap machine.

10.10.10.245 cap.ovpn

I navigated my way around the dashboard, looking for vulnerabilities that I could exploit, but I couldn’t find any. I stumbled upon an interesting thing on the Security Snapshot tab, I noticed that the path in the URL includes a number at the end. I changed the value of this number several times and discovered some changes in the data (Number of Packets, IP Packets, TCP Packets, and UDP Packets).

cap htb walkthrough

security snapshot cap.ovpn

Initially in the URL bar of the security snapshot is the following URL 10.10.10.245/data/8, I changed the value of the last character (8) to 7, 6, 5, 4, 3, 2, 1, and 0. I noticed an increase in the number of data types for Number of Packets, IP Packets, TCP Packets, and UDP Packets.

After changing the URL to 10.10.10.245/data/0, I clicked on the “Download” button to download the Wireshark file on my Kali Linux. Then, I opened the Wireshark file by running the following command in my terminal:

wireshark enumeration

This launched the Wireshark interface and I filtered my pane by switching to the “Hash” pane area which shows a hexadecimal representation of the packet’s contents, allowing for quick verification and comparison.

wireshark filter wireshark forensics

I found a request with a PASS header value of Buck3tH4TF0RM3! which looks suspicious. I right clicked and chose “follow” and clicked on “TCP Stream”

wireshark network filter

This opened the request in a text editor and I found the following credentials (user: Nathan and password: Buck3tH4TF0RM3!)

Nathan cap htb walkthrough

Once I had copied the password, the next step was obtaining a secure encrypted connection to user Nathan by typing the following command on the terminal:

ssh nathan@10.10.10.245

reverse shell nathan

I pasted the password of user Nathan from the Wireshark file I analyzed as Buck3tH4TF0RM3! and it worked. I got a shell as user Nathan. Like I always do, I listed all the files in the directory by running the ls command and there I found the user.txt file. To read the content of the file, I ran the cat command and there I got my user flag!

cat user.txt user flag

Hurray, I got the user flag!!!

cap machine hack the box walkthrough writeup

The next step was obtaining the root user flag. Firstly, I tried some privilege escalation but none of it worked. Then I tried to locate some files with specific permissions on a Linux system by running the following command:

-perm /4000 specifies that the command should search for files with the execution bit set (4) and the read and write bits for owner (2) and group (0). The 2>/dev/null part redirects any error messages to the null device, suppressing them from the output. The find command searches the root directory (/) and its subdirectories for files matching the specified criteria, printing the absolute path of each matching file to the console.

find / -perm /4000 2>/dev/null

Afterwards, I created a Python file that allows me to run sudo (admin) privileges by creating a file called exploit.py

To create the file, I ran the following command in my terminal:

nano exploit.py

This opened the GNU interface, then I pasted the following lines of code inside to gain privilege into the system.

privilege escalation

I pressed and hold Ctrl + X, then press Y and Enter to save the file. Next, I ran the exploit.py file against python by running the following command:

This command executed the exploit.py file and I was able to obtain the shell at root. Next I listed all the files and couldn’t find the flag, then I changed the folder to root and listed all the files in the directory, there I found the root .txt file.

python exploit.py

To read the content of the file, I ran the cat root.txt and there I got my flag.

cap machine hack the box walkthrough writeup

That’s how I got the root flag. If you enjoy reading my writeup and would love to see more of it, kindly consider subscribing to my YouTube channel and following me on my other social media accounts.

Subscribe to my YouTube channel: https://www.youtube.com/@BoltechTechnologies1

Follow me on LinkedIn: https://www.linkedin.com/in/isiaq-ibrahim-468588156/

Follow me on Twitter: https://x.com/Isiaq_Ibrahim99

Follow me on Twitter: https://x.com/BoltechNG

Follow me on Medium: https://medium.com/@ibrahimbolaji50.ib 

This walkthrough was first published on Medium on August 31st 2024. The walkthrough had 27 views and 15 reads on Medium and 1,999 views on YouTube.

cap htb machine medium writeup


Cap HTB Walkthrough Boltech Technologies

Comments

Popular posts from this blog

Fluffy HTB Walkthrough

Welcome to another Hack the Box exercise. In this blog post, I will show you how I pwned the Fluffy machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment, and subscribe to my YouTube channel ( https://www.youtube.com/@BoltechTechnologies1 ) and also follow me on LinkedIn ( https://www.linkedin.com/in/isiaq-ibrahim-468588156/ ) for more updates. About the Machine Fluffy is an easy-rated Windows machine on Hack the Box that takes players through a well-structured series of Active Directory exploitation techniques, emphasizing real-world misconfigurations in a corporate domain environment. The box begins with SMB enumeration using valid credentials to access interesting files, including a PDF that references a real-world CVE—CVE-2025-...

TombWatcher HTB Walkthrough

Hello and welcome to another Hack the Box walkthrough. In this blog post, I am going to show you how to pwn the TombWatcher machine on hack the box. If you are new to this channel, please don’t forget to like, comment, and subscribe to my YouTube channel for more awesome content. Also, don’t forget to follow me on LinkedIn and X for more HTB walkthrough and cybersecurity related contents.   About the Machine TombWatcher is a medium-difficulty Windows Active Directory machine that challenges players to exploit misconfigurations in Active Directory Certificate Services (AD CS). The initial foothold is gained through enumeration of vulnerable certificate templates, specifically one that allows low-privileged users to enroll certificates with the Certificate Request Agent application policy. This enables an ESC1-style attack, where a user (cert_admin) can request a certificate on behalf of a high-privileged account like Administrator, ultimately leading to domain compromise. Ad...

Puppy HTB Walkthrough

Welcome to another Hack the Box exercise. In this walkthrough, I have documented how I owned the Puppy machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment and subscribe to my YouTube channel and follow me on LinkedIn for more updates. About the Machine Puppy is an easy-difficulty Linux machine. The first step in pwning the Puppy machine like I have always done in my previous writeups is to connect my Kali Linux terminal with Hack the Box server. To establish this connection, I ran the following command in the terminal: Copy sudo openvpn puppy.ovpn Once the connection was successful, I started the target machine and I was assigned an IP address 10.10.11.70. The next step was adding puppy.htb to my /etc/hos...

Editor HTB Walkthrough

Welcome to another Hack the Box exercise. In this walkthrough, I have documented how I owned the Editor machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment and subscribe to my YouTube channel and follow me on LinkedIn for more updates. About the Machine Editor is an Easy Linux machine that combines web exploitation, credential reuse, and privilege escalation in a realistic attack chain. The initial foothold is obtained by exploiting a vulnerable version of XWiki (CVE-2025-24893) running on port 8080, which allows remote code execution and provides shell access as the low-privileged xwiki user. Further enumeration of configuration files reveals database credentials that are reused by the system user oliver , granting SSH acc...

Planning HTB Walkthrough

Welcome to another Hack the Box exercise. In this blog post, I will show you how I owned the Planning machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment, and subscribe to my YouTube channel and also follow me on LinkedIn for more updates. About the Machine Planning is an easy Linux machine on HackTheBox that demonstrates a well-paced attack chain involving reconnaissance, password reuse, enumeration of internal services, and Docker exploitation. The box is themed around a fictional project management environment where users manage infrastructure using tools like Grafana and Docker containers. Once on the box as a low-privileged user, we analyze cron jobs and discover a Docker container being regularly backed up. The backup pro...

Chemistry HTB Walkthrough

Welcome to another Hack the Box exercise. In this walkthrough, I have documented how I pwned the Chemistry machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment and subscribe to my YouTube channel ( https://www.youtube.com/@BoltechTechnologies1 ) and follow me on LinkedIn ( https://www.linkedin.com/in/isiaq-ibrahim-468588156/ ) for more updates. About the Machine Chemistry is an easy-difficulty Linux machine that showcases a Remote Code Execution (RCE) vulnerability in the `pymatgen` (CVE-2024-23346) Python library by uploading a malicious `CIF` file to the hosted `CIF Analyzer` website on the target. After discovering and cracking hashes, we authenticate to the target via SSH as `rosa` user. For privilege escalation, we expl...

Eureka HTB Walkthrough

Welcome to another Hack the Box walkthrough. In this blog post, I have demostrated how I owned the Eureka machine on Hack the Box. Hack The Box is a cybersecurity platform that helps you bridge knowledge gaps and prepares you for cyber security jobs. You can also test and grow your penetration testing skills, from gathering information to reporting. If you are new to this blog, please do not forget to like, comment and subscribe to my  YouTube channel  and follow me on  LinkedIn  for more updates. About the Machine Eureka is a hard Linux machine which incorporated a password leakage in heapdump and a vulnerability in the Eureka service on the intranet port, by registering a fake microservice instance and obtaining user credentials. The Linux machine also feature an array comparison vulnerability by modifying a log file to achieve privilege escalation. The first step in pwning the Eureka machine like I have always done in my previous writeups is to connect my Kali...