十二、pikachu之URL重定向

文章目录

  • 1、URL重定向概述
  • 2、实战
  • 3、URL跳转的几种方式:
    • 3.1 META标签内跳转
    • 3.2 javascript跳转
    • 3.3 header头跳转

1、URL重定向概述

  不安全的url跳转问题可能发生在一切执行了url地址跳转的地方。如果后端采用了前端传进来的(可能是用户传参,或者之前预埋在前端页面的url地址)参数作为了跳转的目的地,而又没有做判断的话,就可能发生"跳错对象"的问题。

2、实战

(1)依次点击页面上的四个链接:
十二、pikachu之URL重定向_第1张图片
  第三个链接的数据包:

十二、pikachu之URL重定向_第2张图片

  第四个链接的数据包:

十二、pikachu之URL重定向_第3张图片

  可以看到:url参数将会控制跳转到哪个页面。

(2)payload:url=https://www.baidu.com,将会跳到百度。
(3)分析源码
十二、pikachu之URL重定向_第4张图片

使用header函数进行重定向。

3、URL跳转的几种方式:

3.1 META标签内跳转

<head>

<meta http-equiv="refresh" content="10">

<meta http-equiv="refresh" content="5;url=hello.html">
head>

3.2 javascript跳转

//window.location.href方式
 <script language="javascript" type="text/javascript">
           window.location.href="target.aspx"; 
    </script>

//window.navigate方式跳转
<script language="javascript">
    window.navigate("target.aspx");
</script>

//window.loction.replace方式实现页面跳转
<script language="javascript">
    window.location.replace("target.aspx");
</script>

//self.location方式实现页面跳转
 <script language="JavaScript">
          self.location='target.aspx';
   </script>

//top.location
 <script language="javascript">
          top.location='target.aspx';
   </script>

//window.history.back
<script language="javascript">
    alert("返回");
    window.history.back(-1);
   </script>

3.3 header头跳转

  php中header函数可实现跳转,当然其他服务器端编程语言都可以实现例如java web的redirect等等。


//重定向浏览器
header("Location: http://bbs.lampbrother.net");
//确保重定向后,后续代码不会被执行
exit;
?>

你可能感兴趣的:(pikachu,安全,php)