Tags: xss 

Rating: 0


> This is some kind of reverse captcha to tell if the visitor is indeed a robot. Can you complete it?
> Service: http://xss1.alieni.se:2999/

**No files given**


We are presented with a simple challenge:


If we follow the `?xss=hello` link, we can see this in the source code:

<script>var x ='hello'; var y = `hello`; var z = "hello";</script>

The `xss` parameter gets injected into three differently-quoted Javascript strings verbatim. We can use any one of them since our characters are not filtered. So, choosing the first one, we first inject a `'` to escape the string, then a `;` to allow us to run arbitrary code, and after our code, we put `//` to comment out the rest (to stop the browser from complaining about syntax errors).


But if we do this, we get a text prompt instead. There is another script included on the website, which overrides `window.alert`. Unfortunately, it seems `window` doesn't have a usable `prototype`, at least not in the current Chrome version. If we try `delete window.alert;`, the default `alert` function does not get restored.

Searching around for how to restore overridden functions, we find a simple technique: create an `<iframe>` and use its `window`'s `alert` function.

var iframe = document.createElement("iframe");
URL (shorter version):

And if we submit this URL, we get the flag.