# Brooklyn99 THM

## <mark style="color:blue;">**Brooklyn99 Machine**</mark>

### *From* [*<mark style="color:red;">**TryHackMe**</mark>*](https://tryhackme.com/room/brooklynninenine) *Website with {Easy Difficulty}*

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FJ9I9nzMXRSWxEtZwQPYj%2F95b2fab20e29a6d22d6191a789dcbe1f.jpeg?alt=media\&token=35b7ea7f-2d70-41bf-9544-53ca2ea7a97e)

### <mark style="color:yellow;">**Table of Contents:**</mark>

[      • Information Gathering](#_toc102177854)

&#x20;     • [Hydra Brute-Force](#_toc102177855-1)

[      • User Flag ](#_toc102177859)

[      • Privilege Escalation ](#privilege-escalation)

[      • Root Flag ](#_toc102177860)

[      • References](#_toc102177861)

\------------------------------------------------------------------------------------

### <mark style="color:yellow;">Information Gathering</mark> <a href="#toc102177854" id="toc102177854"></a>

### <mark style="color:orange;">Nmap Scanning</mark> <a href="#toc102177855" id="toc102177855"></a>

`└──╼$ nmap –sCV 10.10.140.111`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2Fhr0xZMLYWqNrypiYhxfg%2FScreenshot_2022-10-07_11_39_01.png?alt=media\&token=7cfca68c-efe6-491e-9abb-ef3e6b5dc923)

We found an **FTP Port** Open with **Anonymous Login Allowed** and there's another two open Ports (**22** and **80**), so let's check the **FTP** port info.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FVN0lalFik7MOHXHCi3Iu%2FScreenshot_2022-10-07_11_39_46.png?alt=media&#x26;token=880ae29b-6463-42fc-aec5-163880041310" alt="test"><figcaption></figcaption></figure>

So we got this file when we login with FTP Connection "**note\_to\_jake.txt**" and have this message

`From Amy,`

`Jake please change your password. It is too weak and holt will be mad if someone hacks into the nine nine.`

### <mark style="color:orange;">Hydra Brute-Force</mark> <a href="#toc102177855" id="toc102177855"></a>

So this is a sign to try to BruteForce Jake Password, so we use hear **Hydra** to **bruteforce** jake **ssh connection** Password with this command

`└──╼$ hydra -l jake -p /usr/share/wordlists/rockyou.txt ssh://10.10.140.111 -t 4`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F4RHlry3Td9R8Vu6x4Fmo%2FScreenshot_2022-10-07_11_51_22.png?alt=media&#x26;token=8cb75baa-13fd-49ba-a12c-74cb5c3366f5" alt=""><figcaption></figcaption></figure>

so while **hydra** takt it's time to **bruteforce** jake's password, let's gather some information by **Gobuster**

### <mark style="color:orange;">Gobuster Scanning</mark> <a href="#toc102177856" id="toc102177856"></a>

`└──╼$ gobuster –w /usr/share/wordlists/dirb/common.txt dir -u http://10.10.140.111/`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FMbf4rwLowjKbcvRQXdRR%2FScreenshot_2022-10-07_11_38_45.png?alt=media\&token=d80cfd90-9eaf-4709-96ba-f616702eac5b)

We have nothing useful here, let’s take a look at the website.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FPucm51gtxQwF4ZteyLuy%2FScreenshot_2022-10-07_11_16_15.png?alt=media&#x26;token=dc5464e8-f140-4e03-bb60-9c83a76cb9c8" alt=""><figcaption></figcaption></figure>

Again nothing is useful here too, so Trying to find another something useful than that like The **Source Code** of the website.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FKRZfBsJtL0YYq7qrgdlb%2FScreenshot_2022-10-07_11_17_08.png?alt=media&#x26;token=2dda580f-1bd2-4ddc-8dbe-91f5782dfacd" alt=""><figcaption></figcaption></figure>

There's an interesting comment here that said "**Have you ever heard of steganography?",** so i think to download the website image to check it.

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FPOAKdaQ1LEmQ2CqTZfWb%2FScreenshot_2022-10-07_11_37_46.png?alt=media&#x26;token=3771934b-d72e-492e-b7d4-7ed31d174f06" alt=""><figcaption></figcaption></figure>

-we can not find anything useful in this image by using exiftool and steghide tools.

### <mark style="color:orange;">User Flag</mark> <a href="#toc102177859" id="toc102177859"></a>

-let's get back to our **Hydra Brute**-**force** and we got this credential for Jake

`jake:987654321`**,** so let's login into Jake account.

`└──╼$ ssh jake@10.10.253.221`\
`password: 987654321`

![](https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FDF6GH1U72osY2Yp0OVpA%2Fcopy2.png?alt=media\&token=291ae593-37ff-4286-ac64-6574b3fbc6ac)

So we can not find the user.txt file into jack directory let's try to find it by using find command like that

`└──╼$ find -type f -name "user.txt"`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FhlPTwktDe05tbdXyc6EP%2Fcopy3.png?alt=media&#x26;token=7286958f-5101-4442-9ea7-9b34c5e802e3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2Fxg8fYITeDrHRMtuvKfor%2FScreenshot_2022-10-08_13_58_16.png?alt=media&#x26;token=bb33271c-1bae-41bd-9e16-7d27f9205c2e" alt=""><figcaption></figcaption></figure>

and now we go the user flag in this location -> `./home/holt/user.txt`

### <mark style="color:yellow;">Privilege Escalation</mark>&#x20;

### <mark style="color:orange;">Root Flag</mark> <a href="#toc102177860" id="toc102177860"></a>

let's now try to know what is the command that we can use it as a root user by using this command

`└──╼$ sudo -l -l`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FEcYfgutt2yrPmSPgMvYS%2FScreenshot_2022-10-08_14we_38_26.png?alt=media&#x26;token=8e3328f6-a96b-4b03-8f18-cf9bb4ac3f63" alt=""><figcaption></figcaption></figure>

And i found the **`less`** command can be executed as root

so by using thins command we have two way to get the root flag

1- by using this command `└──╼$ sudo less /root/root.txt`

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FesIupL8HAyK7dJ7XXPB1%2F12.png?alt=media&#x26;token=50c4986c-f037-4b7c-9dd1-d267a9ee7e6a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FMOJ4TbrUrxIlmtIhuMD7%2FScreenshot_2022-10-08_14_43_37.png?alt=media&#x26;token=ae0eeb44-a09a-4800-bc34-3cca5bbb39c9" alt=""><figcaption></figcaption></figure>

2- By using GTFObins Website to search about `less` command

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FpgzjKiG3clxz5BnhUVsJ%2F15.png?alt=media&#x26;token=cb81242e-1834-4e5e-84b2-eba8abbed70f" alt=""><figcaption></figcaption></figure>

So let's try these commands in the machine like that by creating any file and run shell into it like that

`touch file.txt` + **Enter**

`sudo less file.txt` + **Enter**

`!/bin/sh` + **Enter**

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2FKEAxqwSCENnNvfpL3hlr%2F20.png?alt=media&#x26;token=63af9227-ff43-45e6-b3e7-85e99f9552b8" alt=""><figcaption></figcaption></figure>

Here we go now we become the **Root** user and can easily got the root flag.

Congratulation Machine has been Pwned!!

<figure><img src="https://1695281020-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiBkNGOCaSbgxYLnHH6RS%2Fuploads%2F30jjcdyl2wg8A498PiAA%2FScreenshot_2022-10-08_14_46_45.png?alt=media&#x26;token=73ffdc6d-471b-457b-afc0-384ba2231ed1" alt=""><figcaption></figcaption></figure>

### <mark style="color:yellow;">References</mark> <a href="#toc102177861" id="toc102177861"></a>

* <https://gtfobins.github.io/#less>
