Created
December 8, 2023 14:30
-
-
Save LIttleAncientForestKami/6c1d140f987d4ae0fb39ddd28dd94ff5 to your computer and use it in GitHub Desktop.
Content Security Policy demo with XSS attack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>XSS Demo</title> | |
<meta http-equiv="Content-Security-Policy" content="" /> | |
</head> | |
<body> | |
<h1>XSS Demo</h1> | |
<form> | |
<label for="input">Enter your name:</label> | |
<input type="text" id="input" name="input" placeholder="<script>alert(1)</script>"> | |
<button type="button" onclick="displayGreeting();">Submit</button> | |
</form> | |
<script> | |
function displayGreeting() { | |
var userInput = document.getElementById('input').value; | |
var greeting = 'Hello, ' + userInput + '!'; | |
document.write('<p>' + greeting + '</p>'); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment