Download

Recon

nmap_scan.log

HTTP (80)

Writeup.png

We can upload files basically, but since it's not PHP or something no code exec.

Writeup-1.png

There's no preview button, only download.

If we register we can upload files privately and also delete them.

Writeup-2.png

Routes:

LFI

In the downloads I started testing for basic SQLi in the path, but nothing promising. It's either interacting with database or with files. Messing with slashes reveals it's most likely files.

Writeup-3.png

It's executing an unsafe SQL query, the client is Prismaarrow-up-right. We can't read files outside application root, nginx complains that it's a bad request.

home.js is getting files based on where query and the author is basically querying for JSON object; if we can change the user in our session we can access other users files

Without digging to much source code, ChatGPT says that cookies are generally signed with HMAC

Writeup-4.png

Our download_session.sig cookie is length of 40, meaning SHA1

Note: 41 because of newline, SHA1 length is 40

Cookie signing process takes the key=value, gets SHA1 HMAC value and stored it inside cookie.sig value. Recipearrow-up-right

Writeup-5.png

For some odd reason the application didn't like = in cookies and that took way too long to figure out...

Some users have upload, but it's not in Hey <USERNAME>!. Upload by <USERNAME> has them.

Writeup-6.png

If we change the cookies any of them we can access the files. Above pdfs are only samples, No information disclosure.

https://book.hacktricks.xyz/pentesting-web/orm-injection#prisma-orm-nodejsarrow-up-righthttps://www.elttam.com/blog/plorming-your-primsa-orm/arrow-up-right

From the source we know the column name so we can bruteforce the md5 hashed passwords (and hopefully crack them)

The above blog had template which was using Threading, but when dealing with HTTP it's better to use something like aiohttparrow-up-right

Writeup-7.png

SSH (22)

Creds: wesley:dunkindonuts

User.txt

Privilege Escalation (postgres)

Writeup-8.png
Writeup-9.png

First I wanted to check if linpeas was right with CVE: CVE-2021-3560-Polkit-Privilege-Esclationarrow-up-right

No success there.

Sudo is also not vulnerable.

Anyway.. let's leave that for now because frankly I have no clue what's going on and second we need postgres user.

There's no .env in application and postgres is somehow working. Prisma supports connecting postgres so that must be it. https://www.prisma.io/docs/orm/overview/databases/postgresqlarrow-up-right. In the example we see it's using env() so somewhere it's getting passed credentials from environment.

Privilege Escalation (root)

postgres-cheatsheet.mdarrow-up-right

Postgres has home and we can write to files. Because this user logs in frequently we can hijack the .bashrc

https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/PostgreSQL%20Injection.md#postgresql-file-writearrow-up-right

Note: How were you supposed to fucking find this, I have no clue...

Ippsec: HackTheBox - Downloadarrow-up-right explains a bit better, but I guess you just have to know the trend or smth.... 🤔

The oldest privesc: injecting careless administrators' terminals using TTY pushbackarrow-up-right

Basically it's because pts is preserved and new is not created for running user (I think? 💭) and it happens because su [-|-l|--login] username

Write to .bashrc for postgres

.bashrc doesn't work, try .profile

What goes in ~/.profile and ~/.bashrc?arrow-up-right

Root.txt

Last updated