> For the complete documentation index, see [llms.txt](https://last-kyubi.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://last-kyubi.gitbook.io/home/menu/ctf-writeups/hackthebox-cap-writeup.md).

# \[HackTheBox] Cap WriteUp

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2Ft8JSe1XLcIXfYkPCc1Oe%2FScreenshot%202024-12-02%20alle%2000.24.32.png?alt=media&amp;token=d87244f3-acfc-4ee8-8efc-5b2d7ed23c4f" alt="" width="356"><figcaption><p>HackTheBox - Cap</p></figcaption></figure>

Tonight we'll play an easy box, the one which I choose is Cap.

Once the box is started, i run an Nmap scan against the target, which revealed the presence of a software called *gunicorn* running on port 80.

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FdAuFqxtSss2TlYyXf6q1%2FScreenshot%202024-12-02%20alle%2000.26.33.png?alt=media&amp;token=9b3045c5-25e0-4d44-b9d0-67620ee859e6" alt="" width="272"><figcaption><p>Nmap scan result</p></figcaption></figure>

Let's visit it!

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FT0jQGdzsqhDffPD3Kpl7%2FScreenshot%202024-12-02%20alle%2000.28.07.png?alt=media&amp;token=b17d5bab-3e2a-45d2-bb33-f4c2ecd6dee3" alt=""><figcaption><p>Dashboard - Gunicorn</p></figcaption></figure>

At a first glance, we can observe that in homepage there are network traffic information. Let's play around..

<div align="center"><figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FxjZcB4HcGSOfP41kKYbh%2FScreenshot%202024-12-02%20alle%2000.30.19.png?alt=media&amp;token=454b86d8-f7e7-4a7c-8edd-144612566ae1" alt="" width="375"><figcaption></figcaption></figure></div>

<div align="center"><figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2F0TDI4z36E6itqnSfFhu7%2FScreenshot%202024-12-02%20alle%2000.31.15.png?alt=media&amp;token=d6642012-8651-4b30-94a3-fab6ca974395" alt="" width="375"><figcaption></figcaption></figure></div>

The */ip* endpoint is giving as output the result of "ifconfig" command, while "*/netstat*" is showing the whole command's output.

While playing around with the *security snapshot* function in menu, it appears that we can download network traffic logs, and currently we are at number 2: let's try to download 1 and 0, hoping that we can find something interesting.

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FXmD7iqpfqjlwx5JVjbPK%2FScreenshot%202024-12-02%20alle%2000.36.03.png?alt=media&amp;token=a9028493-cbf3-4b0d-81ad-a02034812ee2" alt=""><figcaption></figcaption></figure>

the endpoint "*/data/0*" contains some credentials in cleartext which, by analyzing the pcap extraction, were used to login with the user *n\*\*\*\*n* into the FTP service.

Redirecting to data which does not belong to our user is called an **IDOR**.

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2F0bL3P5WxYo5JiwAyDqzW%2FScreenshot%202024-12-02%20alle%2000.36.46.png?alt=media&amp;token=4aa58abb-0fb9-4556-9429-ed6d331e2e82" alt="" width="375"><figcaption></figcaption></figure>

Once logged in with the user, we came in front of user.txt, which contains the first flag:

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FFXlhuNbJ3SqS8jcw2Z1J%2FScreenshot%202024-12-02%20alle%2000.41.25.png?alt=media&amp;token=61d038d6-8d36-4833-bafa-2b859110996c" alt=""><figcaption></figcaption></figure>

The box cames with other services enabled, like ssh, so let's spray these credentials.

Apparently, the user n\*\*\*\*n cannot run sudo, so let's import LinPEAS inside the machine.

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2F908g1qlOY6aWBcB4ZljX%2FScreenshot%202024-12-02%20alle%2000.47.58.png?alt=media&amp;token=e8ee69aa-6b32-40f7-8a82-65a94ade93e5" alt=""><figcaption></figcaption></figure>

Here we have python3.8 with *cap\_setuid* and *cap\_net\_bind\_service* enabled. According to [GTFOBins](https://gtfobins.github.io/gtfobins/python/#suid) we can leverage the *cap\_setuid* to achieve root on machine. Let's try! :)

<figure><img src="https://2757105280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnZbAVJD115uDdr5hrn1b%2Fuploads%2FyaTeTjndZNZPLlDlLsRf%2FScreenshot%202024-12-02%20alle%2000.57.22.png?alt=media&amp;token=69c48425-d796-44d3-821f-be2cec300a04" alt=""><figcaption></figcaption></figure>

That was an easy box which works as a light introduction in packet analysis and IDOR vulnerability.

Enjoy! :)
