So I've been trying to program a website with a user/password form from scratch.
<html>
<head>
<title>Password Generator</title>
</head>
<body>
<h1>Password Generator</h1>
<h3> Let's start: </h3><h3>
<form action="pwd.php" method="GET">
<table style="width:100px">
<tbody>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<input name="name" value="Name" type="text">
</td>
</tr>
<tr>
<td>
<b>Size: </b>
</td>
<td>
<input min="10" max="1000" name="strength" type="range">
</td>
</tr>
</tbody>
</table>
<table style="width:100%">
<tbody>
<tr>
<td></td>
<td>
<input name"gen"="" value="Generate" type="submit">
</td>
</tr>
</tbody>
</table>
</form>
<img src="pwd.php?name=strength">
</h3>
</body>
</html>
Now i tested my website for XSS vulnerability and found out that I can insert JS using the forms for example: <input name="name" value="Name" onclick="alert('XSS');" type="submit">
I just need to change the HTML a little bit using the Mozilla Inspector and I can execute JS remotely on my website.
I read I can use JS to prevent this but I don't understand how it works. I mean I can modify JS using the Inspector so how would that work?
hopefully someone can explain that to me!
kind regards
Raavgo