🐈Cat Pictures 2

License

The following post by anthonyjsaab is licensed under CC BY 4.0arrow-up-right

0 - Introduction

Link to room: https://tryhackme.com/r/room/catpictures2arrow-up-right

Machine version: Cat Pictures II v2.4

This writeup walks you through a room on TryHackMe created by tryhackmearrow-up-right and gamercatarrow-up-right

1 - Port Scan

1a - Discovery

┌──(kali㉿kali)-[~]
└─$ sudo nmap -sS -p- -T5 10.10.208.233
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-26 12:37 EEST
Nmap scan report for 10.10.208.233
Host is up (0.11s latency).
Not shown: 65529 closed tcp ports (reset)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
222/tcp  open  rsh-spx
1337/tcp open  waste
3000/tcp open  ppp
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 273.46 seconds

1b - Versioning

2 - Lychee

2a - Landing page

http://TARGET_MACHINE_IP:80

Notables elements on this page:

  • There is a signin page accessible from the top left

  • There is mention of a software solution called Lychee

  • There is an album of cat photos!

Naturally, I explore the latter first :)

2b - The album

After clicking on the album in the landing page

Note the presence of an "about" button on the top right that gives info about the current album/image we are currently viewing

The first picture called timo-volz

Look closely at the description of the above picture: "note to self: strip metadata". Thus, we download the image and try to look for any metadata that remain embedded in the file:

The title of the photo is very interesting: ":8080/764efa883dda1e11db47671c4a3bbd9e.txt"

It seems like it is the port number and the path to another server on the target machine

3 - Nginx's TXT file

After we download the file from http://TARGET_MACHINE_URL:8080/764efa883dda1e11db47671c4a3bbd9e.txt, we can read the following:

The content of this txt file is self-explanatory, so let's get to it.

4 - Gitea

4a - About

From https://github.com/go-gitea/giteaarrow-up-right: "Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD".

4b - Relevant public pages

http://TARGET_MACHINE_IP:3000 - Landing page
http://TARGET_MACHINE_IP:3000 - Signin page

4c - Logged in

After we use the credentials found in the TXT file from before:

http://TARGET_MACHINE_IP:3000 - Dashboard of logged in user

We can see in the image above that there is a repository called "ansible" that belongs to the user we hijacked.

http://TARGET_MACHINE_IP:3000/samarium/ansible - The ansible repo we control

And we got our first flag!

4d - Planting a reverse shell command

Now onto the YAML file, which seems promising:

We can see that this YAML file, which is probably used by an Ansible server hosted on port 1337, has a whoami command. Let us change that to reverse shell. After editing the file through the browser and committing changes, the file looks like this:

We now need to setup a handler on our Kali machine and then trigger Ansible to execute the reverse shell.

5 - Ansible

http://TARGET_MACHINE_IP:1337 - Landing page

We can see that Ansible is accessible to anyone without any authentication whatsoever. After firing up a handler on Kali, we click on "Run Ansible Playbook" and we get a reverse shell!

We now have a foothold in the target machine! And we also have our second flag:

6 - PrivEsc

6a - Automated Enumeration

We are going to use PEASS. We first download it on Kali from: https://github.com/peass-ng/PEASS-ng/releases/download/20240421-825f642d/linpeas.sharrow-up-right. Then, we open an HTTP server:

Now on the target machine's remote shell:

After we execute it, here are the results:

file-download
91KB
LinPEAS output

6b - Exploit

One particular CVE caught my attention:

From the URL mentioned above, we download the ZIP file on Kali. We extract "exploit_nss.py" which is all we need. We spin up an HTTP server on Kali so that the target machine can download the exploit. Then:

We have the third and final flag!

Last updated