XSS cookie stealing
Inject the XSS Attack Code
Below are four versions of the same attack.
1. alert()
Before Stealing the Cookie
alert()
Before Stealing the CookieRun this version of the attack code if you want to see the cookie in a JS alert()
as confirmation that the injection is successfully exploiting the vulnerability on the target site. Note that the cookie will not upload to your Python listener until the victim closes the JS alert()
dialog.
2. Silent One-Liner
This one is the same but no alert()
and all on one line.
3. <img>
Tag Instead of <script>
Tags
<img>
Tag Instead of <script>
TagsDon't use this one! It works but calls onerror()
in a loop, filling up your stolen cookie log:
4. <img>
Tag and Without the Infinite Loop
<img>
Tag and Without the Infinite LoopThis one works and will only steal the cookie once. I adapted it from a posting on the old [kirupa.com][4] forum.
Last updated