Skip to content

Instantly share code, notes, and snippets.

@jonasfj
Created January 27, 2016 06:49
Show Gist options
  • Save jonasfj/80e26e48cd126f859a04 to your computer and use it in GitHub Desktop.
Save jonasfj/80e26e48cd126f859a04 to your computer and use it in GitHub Desktop.
Example XSS
<b>Hi, <span id="name"></span>,</b><br>
Enter your deepest secret and I'll remeber it:<br>
<input type="text" id="secret"><button onClick="save()">Save</button>
<script>
// Load name from location.hash
document.getElementById("name").innerHTML = decodeURIComponent(window.location.hash);
// Load existing secret
document.getElementById("secret").value = (localStorage.secret || 42);
// Save secret
function save() {
localStorage.secret = document.getElementById("secret").value;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment