点击劫持和防御

原页面source.php

<?php
 //header('X-Frame-Options:DENY'); 
 ?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        html,body{
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>
<body>
<script type="text/javascript">
    //if(parent != self) top.location.href = 'source.php';
</script>
<form action="hij.php">
    <input type="text" name="name">
    <input type="submit" name="">
</form>
</body>
</html>

劫持页面hij.html

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        html,body{
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>
<body>
<iframe src="source.php" style="border:0px solid white"></iframe>
<form action="hij.php" style="position:absolute;top:0px;left:0px;z-index:1">
    <input type="text" name="_name">
    <input type="submit" name="">
</form>
</body>
</html>

收集信息的页面hij.php

<?php
    echo 'hello hijack';
?>

攻击方法:
首先自己写一个页面,接着用iframe引入其他的页面,然后自己利用定位和z-index对原页面进行覆盖和’重绘’,当用户在输入时,以为是正常的页面,其实用户输入是在恶意页面进行的,最后也会提交到恶意者的服务器中。

防御方法:
1利用 header(‘X-Frame-Options:DENY’);
2 if(parent != self) top.location.href = ‘source.php’;这里要用top.location.href,否则会在iframe里不断加载source.php。因为 top.location.href代表的是最高层的window

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值