TryHackMe | Brooklyn Nine Nine Walkthrough

Enes Cayvarlı
8 min readFeb 18, 2023

--

Hi there, I’m glad to see you here. In this article, we’ll solve together the “Brooklyn Nine Nine” room in TryHackMe. In some sections, I’ll share brief about the subject. Don’t forget! You must always research to learn more. I hope it will be helpful for you. Let’s start!

Brooklyn Nine-Nine

Contents:

Solution 1

  • Anonymous File Transfer Protocol
  • Brute Force Attack using Hydra
  • Privilege Escalation

Solution 2

  • Using Steghide
  • Using Stegcracker
  • Privilege Escalation

Deploy and get hacking

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.

Connect to TryHackMe network and deploy the machine.

Step 1: You need openvpn configuration file to connect with VPN to machines in TryHackMe.

https://tryhackme.com/access?o=vpn

Configuration File

Step 2: Use openvpn command and start your VPN connection.

openvpn

Step 3: Can you see the IP address of the machine?

Active Machine Information

Step 4: You can check your connection.

ping
OpenVPN Access Details

Solution 1

Answer the questions below

Q1: User flag

A1: ********************************

Firstly, we need to run a nmap scan to find out which ports are open and which services are running on these ports.

Nmap (Network Mapper) is a free and open source utility for network discovery and security auditing.

nmap -A -T4 -Pn -P- 10.10.147.23

-A : Enable OS detection, version detection, script scanning and traceroute.

-T4 : Set timing template (higher is faster).

-Pn : Treat all hosts as online — skip host discovery.

-p- : You can specify “-p-” to scan ports from 1 through 65535.

Nmap Scan Result

When we look at the Nmap output, we can see that FTP is running on port 21 and that we can login as Anonymous. So, what exactly are “FTP” and “Anonymous login”?

FTP (File Transfer Protocol) is a network protocol for transmitting files between computers over Transmission Control Protocol/Internet Protocol (TCP/IP) connections. Within the TCP/IP suite, FTP is considered an application layer protocol.

Anonymous File Transfer Protocol (FTP) enables remote users to use the FTP server without an assigned user ID and password.

FTP Anonymous Login

Here’s a note for Jake. Let’s get it on our own machine. We can accomplish this with the get command.

get : Copies the remote file to the local host.

get

Amy appears to be complaining about Jake’s use of weak password. What about pissing off Holt?

note_to_jake.txt

Do you think the same as me? Jake has a weak password, and SSH is running on port 22. I think we should call the Hydra.

Hydra is a parallelized login cracker which supports numerous protocols to attack.

hydra -l jake -P /usr/share/wordlists/rockyou.txt 10.10.147.23 ssh

-l : Login with LOGIN name.

-P : Load several passwords from FILE.

[machine IP] : The IP address of the target machine.

ssh / protocol : Sets the protocol.

hydra

You’re right Amy… Jake urgently needs to change his password.

Let’s go inside using Jake’s password. But first, let me explain what SSH is.

The SSH protocol (also referred to as Secure Shell) is a method for secure remote login from one computer to another.

user.txt

Congratulations, you found the first flag!

Q2: Root flag

A2: ********************************

Our mission isn’t done yet. We must capture the last flag by raising our authority.

Note : A privilege escalation attack is a cyberattack designed to gain unauthorized privileged access into a system.

Let’s check if we have any permissions to execute specific commands as sudo.

sudo -l : The -l (list) option will print out the commands allowed (and forbidden) the user on the current host.

sudo

And we can see that we can run the less command.

Let’s research using the information provided by the system.

/usr/bin/less

https://gtfobins.github.io/gtfobins/less/#sudo

GTFOBins is a curated list of Unix binaries that can be used to bypass local security restrictions in misconfigured systems.

I think you should take note of this website. Because here you can find the privilege escalation commands.

GTFOBins
!/bin/bash

Who are we? ROOOT!

root.txt

Congratulations, you found the second flag!

Solution 2

Q1: User flag

A1: ********************************

Firstly, we need to run a nmap scan to find out which ports are open and which services are running on these ports.

Nmap (Network Mapper) is a free and open source utility for network discovery and security auditing.

nmap -A -T4 -Pn -P- 10.10.147.23

-A : Enable OS detection, version detection, script scanning and traceroute.

-T4 : Set timing template (higher is faster).

-Pn : Treat all hosts as online — skip host discovery.

-p- : You can specify “-p-” to scan ports from 1 through 65535.

Nmap Scan Result

When we access port 80 through the browser, we are greeted with a huge photo from the “Brooklyn Nine-Nine” series.

http://10.10.147.23/

We can check the page source for any important information.

The page source can give us important information. This is the original text and HTML tags typed by the author and interpreted by the browser to produce the Web page you actually SEE on the Internet. That’s why never forget to look here.

There is a question for us here when we examine the page source. Have you ever heard of steganography?

Steganography is the technique of hiding secret data within an ordinary, non-secret, file or message in order to avoid detection. The use of steganography can be combined with encryption as an extra step for hiding or protecting data.

Page Source

Then let’s download it to our machine to examine the photo.

Wget is a command-line utility for downloading files from the web.

wget

We can use the “steghide” tool to check if the photo contains any hidden data.

Steghide is steganography program which hides bits of a data file in some of the least significant bits of another file in such a way that the existence of the data file is not visible and cannot be proven.

To install steghide, follow the step below:

apt-get install steghide -y

info : Display information about <filename>.

steghide

Yes, your predictions were correct. There is something here, but it is password-protected. Maybe we might be able to crack the password using the “stegcracker” tool.

StegCracker is steganography brute-force utility to uncover hidden data inside files.

To install stegcracker, follow the step below:

apt-get install stegcracker -y
stegcracker

We succeeded! There is a file called “note.txt” embedded in the photo.

steghide
steghide extract -sf brooklyn99.jpg

extract : Extract data.

-sf : Select stego file.

note.txt

Do you think the same as me? We know Holt’s password, and SSH is running on port 22.

Let’s go inside using Holt’s password. But first, let me explain what SSH is.

The SSH protocol (also referred to as Secure Shell) is a method for secure remote login from one computer to another.

user.txt

Congratulations, you found the first flag!

Q2: Root flag

A2: ********************************

Our mission isn’t done yet. We must capture the last flag by raising our authority.

Note : A privilege escalation attack is a cyberattack designed to gain unauthorized privileged access into a system.

Let’s check if we have any permissions to execute specific commands as sudo.

sudo -l : The -l (list) option will print out the commands allowed (and forbidden) the user on the current host.

sudo

Let’s research using the information provided by the system.

/bin/nano

https://gtfobins.github.io/gtfobins/nano/#sudo

GTFOBins is a curated list of Unix binaries that can be used to bypass local security restrictions in misconfigured systems.

I think you should take note of this site. Because here you can find the privilege escalation commands.

GTFOBins

Let’s open nano as root and then press “CTRL + R” followed by “CTRL + X”.

As a result, nano opens a text box for us that can be used to execute commands.

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

And once more… Who are we? ROOOT!

root.txt

Congratulations, you found the second flag!

--

--

No responses yet