防止<a target=“_blank“>注入攻击网站

文章讨论了HTML链接如何利用`window.opener`属性进行潜在的恶意重定向,并提出了添加`rel=noreferer,noopener`来增强`target=_blank`链接的安全性,防止钓鱼攻击。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<li>
  <a href="bad.example.com" target="_blank">Vulnerable target using html link to 
   open the new page</a>
</li>


if (window.opener) {
window.opener.location = "https://phish.example.com";
}

解决措施:

add rel="noreferer, ,noopener" to avoid this issue wherever target="blank" is placed.

<a href="xxxx"rel="noreferer,noopener" target="_blank" style="text-decoration:none;">
  <button type="button">Download Now</button>
</a>

<?php $link=mysqli_connect("localhost","user","123456","database","3307"); if(!empty($_POST["tijiao"])) { //$sql="delete from xxnews where ID=".$_GET["dID"]; //$rs=mysqli_query($link,$sql); $title=$_POST["title"]; $author=$_POST["author"]; $newsDate=$_POST["newsDate"]; $source=$_POST["source"]; $content=$_POST["content"]; $sql="update from xxnews where ID=".$_POST["uID"]; $rs=mysqli_query($link,$sql); //$link=mysqli_connect("localhost","user","123456","database","3307"); // $sql="update xxnews set title='".$title."',author='".$author."',newsDate='".$newsDate."',source='".$source."',content='".$content."' where ID=".$_GET["uID"]; // $rs=mysqli_query($link,$sql); } ?> <div class="head1"> XX新闻中心 </div> <?php $link=mysqli_connect("localhost","user","123456","database","3307"); $sql="SELECT * FROM xxnews WHERE ID = ".$_POST["ID"]; $rs=mysqli_query($link,$sql); while($rows=mysqli_fetch_array($rs)) { echo "<form action='update.php?uID=".$rows["ID"]."' method='post' target='_blank'>"; echo "<div class='head2'>"; echo "标题:<input type='text' name='title' value='".$rows["title"]."' />"; echo "</div>"; echo "<div class='head3'>"; echo "作者:<input type='text' name='author' value='".$rows["author"]."' />       "; echo "时间:"; date_default_timezone_set('PRC'); echo "<input type='text' name='newsDate' value='".date('Y-m-d', time())."' />"; echo "        来源:<input type='text' name='source' value='".$rows["source"]."' />       <input type='submit' name='tijiao' value='修改新闻' class='tijiao' />"; echo "</div>"; echo "<div class='content'>"; echo "<textarea class='content1' name='content'>"; echo $rows["content"]; echo "</textarea>"; echo "</div>"; echo "</form>"; } ?> <div class="footer"> XX新闻<br /> 地址:广东省肇庆市端州区广东工商职业技术大学星湖校区<br /> 电话:123456789 </div>这段代码有什么问题
06-12
public function searching(){ if(isset($_GET["keyword"])){ $keyword = $_GET["keyword"]; $News = D('News'); $where['title'] = array('like', '%'.$keyword.'%'); //$where['date'] = array('like','%'.$keyword.'%'); $where['caiyong'] = 1; $where['_logic'] = 'and'; import('ORG.Util.Page');// �����ҳ�� $count = $News->where($where)->count();// ��ѯ����Ҫ����ܼ�¼�� $Page = new Page($count,5);// ʵ������ҳ�� �����ܼ�¼����ÿҳ��ʾ�ļ�¼�� $show = $Page->show();// ��ҳ��ʾ��� // ���з�ҳ���ݲ�ѯ ע��limit�����IJ���Ҫʹ��Page������� $result = $News->where($where)->relation(true)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select(); if ($result){ echo " <ul class='media-list'> "; foreach ($result as $key=>$v){ if ($result[$key]['link_type'] == 1){ $url = $result[$key]['links']; }else{ $url = "/Index/article/number/".$result[$key]['number']; } echo "<li>"; echo "<a href='".$url."' target='_blank'>".cut($result[$key]['title'], 15)."</a>"; echo "</li>"; } echo "</ul>"; echo "<a style='color:#ff0000;' href='/Index/search/?keyword=".$_GET["keyword"]."'>�鿴����...</a>"; }else{ echo "��ʱû����������..."; } } } public function search(){ if(isset($_GET["keyword"]) and $_GET["keyword"] != null){ $keyword = $_GET["keyword"]; $News = D('News'); $Theme = D('Theme_article'); if($_GET['type'] == '1' || $_GET['type'] == null){ $where['title'] = array('like', '%'.$keyword.'%'); //$where['content'] = array('like', '%'.$keyword.'%'); $where['_logic'] = 'or'; $map['_complex'] = $where; $map['caiyong'] = '1'; import('ORG.Util.Page');// $count = $News->where($map)->count();// 以上是一段搜索功能代码,如何屏蔽指定字眼比如屏蔽“马斯”
03-10
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值