MOCA CTF - QUALS 2024 | RaaS (Web, XSS)
Difficulty : Medium
I participated in the moca CTF quals and even though I only managed to solve one challenge only, I had alot of fun and would replay it next year.
The CTF featured 3 categories (Web, Pwn, Crypto) and was very difficult.
Described as a Warmup XSS task, this challenge is a one click XSS task, as it may seem easy at the surface this task but bypassing these filters will be a difficult challenge.
Let's first Take a look at the code.
We have two applications one for the actual web app and one for the bot.
App.py
App.js
So the challenge consist of stealing the cookie from the admin by sending a malicious one click xss payload.
Thank god the writers provided us with a way to test our payload.
There are ways to exploit this but the sure way is to inject a Javascript Uri into the button, like this.
Let's first see the filters :
From this code we would need three conditions :
It needs to not start with j
The payloads needs to not contain the string javascript
it needs to not contains (),=,$ and `` (we will return to the last one later)
The payload that we will use will be:
That payload uses as little special characters as possible and is pretty short.
to bypass the first condition i followed from this writeup, I bypassed it with %19javascript .
for the second filter i split the javascript string into two using a Tab character javasc%09ript
and for the last filter i used the url encoded value for '='.
so at last our payload would be :
if we url encode it would become :
Now we feed the payload through Burpsuite and we receive the flag.

Alternatives that didn't work :
at first I tried to use Named entities to bypass the filters, the payload would look like this :
even though it passed the filters, it wouldn't work since the & would be filtered and passed as & so it would look like this:
another payload that I think was fixed is to pass a HTML script tag in base64 and decrypt it :
that wouldn't work since the backquotes were filtered, i didn't try much more with this payload but it could've worked if we managed to replace the backquotes with something else.
Overall it was a good CTF, it was quite challenging, the challenges were creative and staff was friendly. Only problem was the architecture that was hosted on PWNX that would crash and people would reset the tasks without a vote always changing the IP address of the challenge while working on it.
Overall 7/10 .
Last updated