# XSS

&#x20;the developer decided to completely block the word `script`: if the request matches `script`, the execution stops.

Fortunately (or unfortunately depending on what side you are on), there are a lot of ways to get JavaScript to be run (non-exhaustive list):

* with the `<a` tag and for the following events: `onmouseover` (you will need to pass your mouse over the link), `onmouseout`, `onmousemove`, `onclick` ...
* with the `<a` tag directly in the URL: `<a href='javascript:alert(1)'...` (you will need to click the link to trigger the JavaScript code and remember that this won't work since you cannot use `script` in this example).
* with the `<img` tag directly with the event `onerror`: `<img src='zzzz' onerror='alert(1)' />`.
* with the `<div` tag and for the following events: `onmouseover` (you will need to pass your mouse over the link), `onmouseout`, `onmousemove`, `onclick`...
* ...

You can use any of these techniques to get the alert box to pop-up.

the `<script>` tag is accepted and gets echoed back. But as soon as you try to inject a call to alert, the PHP script stops its execution. The problem seems to come from a filter on the word `alert`.

Using JavaScript's `eval` and `String.fromCharCode()`, you should be able to get an alert box without using the word `alert` directly. String.fromCharCode() will decode an integer (decimal value) to the corresponding character.

You can write a small tool to transform your payload to this format using your favorite scripting language.

Using this trick and the ascii table, you can easily generate the string: `alert(1)` and call eval on it.

Here, the source code of the HTML page is a bit different. If you read it, you will see that the value you are sending is echoed back inside JavaScript code. To get your alert box, you will not need to inject a script tag, you will just need to correctly complete the pre-existing JavaScript code and add your own payload, then you will need to get rid of the code after your injection point by commenting it out (using `//`) or by adding some dummy code (`var $dummy = "`) to close it correctly.

This example is similar to the one before. This time, you won't be able to use special characters, since they will be HTML-encoded. As you will see, you don't really need any of these characters.

This issue is common in PHP web applications, because the well-known function used to HTML-encode characters (`htmlentities`) does not encode single quotes (`'`), unless you told it to do so, using the `ENT_QUOTES` flag.
