Pyrat

This is the description of the box:

Pyrat receives a curious response from an HTTP server, which leads to a potential Python code execution vulnerability. With a cleverly crafted payload, it is possible to gain a shell on the machine. Delving into the directories, the author uncovers a well-known folder that provides a user with access to credentials. A subsequent exploration yields valuable insights into the application's older version. Exploring possible endpoints using a custom script, the user can discover a special endpoint and ingeniously expand their exploration by fuzzing passwords. The script unveils a password, ultimately granting access to the root.

Nmap tells us two ports are open, 22 and 8000.

Let's start with 8000

Using curl gives us a response saying "Try a more basic connection".

I tried with

and didn't think I got a respone. It just printed a new line but turns out I'm in a python interpreter. I try it out with:

Let's see if I can get a reverse shell from this.

On attacker machine:

On victim:

It works. That will help us move a bit more easily.

I got stuck here trying to figure out the clue "Delving into the directories, the author uncovers a well-known folder that provides a user with access to credentials."

After a bit of research I figured out it was probably git (and git config) related.

Searching for this:

find / -type f -name "config" -path "/.git/" 2>/dev/null

Returns:

/opt/dev/.git/config

And this file contains the following:

We can SSH to the machine as think and get the user.txt file which contains the first flag.

Time to get the Root flag.

To see the commit history we run

git log --oneline --graph --all to find all the commits in the repository. The result is only one commit that looks very promising. We checkout that branch and see that it deleted a file.

We checkout the commit right before the deletion instead and take a look at the source code.

I tried connecting from the attacker machine again to experiment with the input data. On the first try I put admin and I got prompted for a password. Let's try fuzzing the password here.

The following script will try to find the password using the rockyou.txt wordlist.

We quickly find the password and can now connect as root.

Last updated