I am learning about XSS (for ethical purposes), and I was wondering how to execute some JavaScript code without using tags. This is within the
HT
You can use the onclick
attribute that is presented in HTML elements so you can create something like this:
"The search term" <p> <a href="" onclick="alert('I excuted JavaScript!');">Click me to see the JavaScript work!</a> </p> "returned no results"
Now when clicking on the element the JavaScript will be executed.
'';!--"<XSS>=&{()}
)<>
won't matter, because you are already inside a HTML Tag. You can look if this Tag supports Events and use some kind of onload=alert(1)
or other event. If <>
is allowed, you can break out and create your own tag '><img src=0 onerror=alert(1)>
<>
are important. With these you can open a new Tag and the whole world is below your feet (or so...)'"
, then you can basically write ';alert(1)
<XSS>
disappears entirely: the application uses some kind of strip_tags
. If you are outside of a HTML Tag and no HTML Tags are whitelisted, I unfortunatly don't know any method to achieve an XSS.
There are various methods to achieve this and too much to name them all. Look on these two sites, which have a lot of the methods and concept to construct your own. It comes down to: What the page allows to go through.
Another one was mentioned at: https://stackoverflow.com/a/53430230/895245
<a href="javascript:alert(1)">asdf</a>
Works on Chromium 81.
More important perhaps is the question of how to sanitize against it, see e.g.: