> For the complete documentation index, see [llms.txt](https://maurvan.gitbook.io/ctf-writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maurvan.gitbook.io/ctf-writeups/various-challenges/index/brooklyn-nine-nine-room.md).

# Brooklyn Nine-Nine (room)

## Challenge

> This room is aimed for beginner level hackers but anyone can try to hack this box. There are two main intended ways to root the box.

## Solution

We only receive an IP address, so we will use [nmap](https://nmap.org/) on it to check what is running.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2Fwbw1vbWjByxtRHOyIjUe%2Fnmap.PNG?alt=media&amp;token=75d766c0-8b20-49b7-a674-2eafcf44d6fb" alt=""><figcaption></figcaption></figure>

We can see there are 3 services open. The SSH will probably be interesting but later since we don't have credentials yet.

But the HTTP service shows there is a website hosted. We open the page in a browser.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2Fd7u4RnyU8CTRIBHqikT7%2Fb99_site.PNG?alt=media&amp;token=f61ace31-f00b-4c5a-9cb6-57d404fa6781" alt=""><figcaption></figcaption></figure>

There is something interesting in the code source when we inspect the page.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2FkKi7wQCPSD0EYJHrQ0FK%2Fb99_body.PNG?alt=media&amp;token=22ace46b-9caa-4e27-b219-192b0c2a5144" alt=""><figcaption></figcaption></figure>

I then downloaded the picture so I could try some of my steganography tools on it. The only one that gave me something was [stegseek](https://github.com/RickdeJager/stegseek) which was able to extract a txt file.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2FULKCeXV3QnCSn3BtTurQ%2Fholt_pwd.PNG?alt=media&amp;token=0b8379b8-72bd-49cd-853a-a6c1ccff2c56" alt=""><figcaption></figcaption></figure>

Great! Now we've got a password to work with!

Time to try to connect.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2Ft9lQJZ0l0KkXooJrQFFe%2Fwere_in.PNG?alt=media&amp;token=8278d9e0-ea92-4480-b43c-e8eec2d90160" alt=""><figcaption></figcaption></figure>

And we're in!

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2F2I5o5FsUyDCGBgwkBX1b%2Fholt_ls.PNG?alt=media&amp;token=2b96ac47-9564-432f-a442-7e5367ee81e7" alt=""><figcaption></figcaption></figure>

We have found the first flag.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2FX82kTuwyFrVS9iwPQj6o%2Fflag1.PNG?alt=media&amp;token=8da55a63-8def-43df-afe8-2b76cc6d9a22" alt=""><figcaption></figcaption></figure>

Now we have to find a way to escalate our privilege and become root.

When checking sudo configuration I found something interesting. User holt can run nano as root!

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2Fm7QCTpXUl2DWFB0EJa5R%2Fsudo_conf.PNG?alt=media&amp;token=3ad3cb88-bce8-4c1c-a7ac-7bb0c3e9001d" alt=""><figcaption></figcaption></figure>

Using [GTFOBins](https://gtfobins.github.io/) we can just copy/paste their way to gain privileges.

So, first type "sudo nano" which will open the nano editor. Then do CTRL+R and CTRL+X. You should see this at the bottom of your nano editor.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2FczKherC4FA3kNwXcw4rc%2Fcmd.PNG?alt=media&amp;token=dcaeb170-218c-4424-8642-191558a0adf0" alt=""><figcaption></figcaption></figure>

Type this:

```
reset; sh 1>&0 2>&0
```

And you should have root access!

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2Ffld5SOifDt2hONrNvudF%2Fwhoami.PNG?alt=media&amp;token=2eeb9626-1647-4b2e-a976-fca1956ceb66" alt=""><figcaption></figcaption></figure>

Now you only need to move to the root folder and read the root.txt file that is hidden there.

<figure><img src="https://1102212211-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa46Jmz9dIuFnWcXn3ooO%2Fuploads%2FS9a4d6UYs4lnp7nHtjSg%2Froot_txt.PNG?alt=media&amp;token=6eef2605-9d50-4b83-8c84-6653518a16ea" alt=""><figcaption></figcaption></figure>

And we have the 2nd flag! Well done.
