Download
Recon
HTTP (80)

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

There's no preview button, only download.
If we register we can upload files privately and also delete them.

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.

It's executing an unsafe SQL query, the client is Prisma. 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

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. Recipe

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.

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-nodejshttps://www.elttam.com/blog/plorming-your-primsa-orm/
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 aiohttp

SSH (22)
Creds:
wesley:dunkindonuts
User.txt
Privilege Escalation (postgres)


First I wanted to check if linpeas was right with CVE: CVE-2021-3560-Polkit-Privilege-Esclation
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/postgresql. In the example we see it's using env() so somewhere it's getting passed credentials from environment.
Privilege Escalation (root)
Postgres has home and we can write to files. Because this user logs in frequently we can hijack the .bashrc
Note: How were you supposed to fucking find this, I have no clue...
Ippsec: HackTheBox - Download 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 pushback
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?
Root.txt
Last updated