简介
本质是url转跳,叫url转跳漏洞也叫开放重定向漏洞,多用于钓鱼场景。
重定向的类型:
1.永久重定向
状态码301和308
2.临时重定向
状态码302、303、307
3.特殊重定向
状态码300、304
Open HTTP Redirect(Security Level: low)
代码分析
<?php
if (array_key_exists ("redirect", $_GET) && $_GET['redirect'] != "") {
header ("location: " . $_GET['redirect']);
exit;
}
http_response_code (500);
?>
<p>Missing redirect target.</p>
<?php
exit;
?>
1.首先通过 array_key_exists 函数判断 $_GET 数组中是否存在 redirect 键值,如果存在且不为空,则调用 header 函数,否则返回 500 状态码。
2.调用 header 函数,将 Location 字段设置为 $_GET['redirect'] 的值,完成重定向操作。exit 函数用于终止脚本的执行,确保 header 函数的执行效果
漏洞利用
都点一下试试
注意url
后面应该是能跟网址的
http://192.168.21.128/dvwa/vulnerabilities/open_redirect/source/low.php?redirect=https://baidu.com
Open HTTP Redirect(Security Level: medium)
代码分析
<?php
if (array_key_exists ("redirect", $_GET) && $_GET['redirect'] != "") {
if (preg_match ("/http:\/\/|https:\/\//i", $_GET['redirect'])) {
http_response_code (500);
?>
<p>Absolute URLs not allowed.</p>
<?php
exit;
} else {
header ("location: " . $_GET['redirect']);
exit;
}
}
http_response_code (500);
?>
<p>Missing redirect target.</p>
<?php
exit;
?>
过滤了http和https,可以使用别的方法进行转跳
漏洞利用
http://192.168.21.128/dvwa/vulnerabilities/open_redirect/source/medium.php?redirect=../../../index.php
这个就只能在网站内进行转跳了
Authorisation Bypass(Security Level: high)
代码分析
<?php
if (array_key_exists ("redirect", $_GET) && $_GET['redirect'] != "") {
if (strpos($_GET['redirect'], "info.php") !== false) {
header ("location: " . $_GET['redirect']);
exit;
} else {
http_response_code (500);
?>
<p>You can only redirect to the info page.</p>
<?php
exit;
}
}
http_response_code (500);
?>
<p>Missing redirect target.</p>
<?php
exit;
?>
重定向被锁定到info.php
漏洞利用
Authorisation Bypass(Security Level: impossible)
代码分析
<?php
$target = "";
if (array_key_exists ("redirect", $_GET) && is_numeric($_GET['redirect'])) {
switch (intval ($_GET['redirect'])) {
case 1:
$target = "info.php?id=1";
break;
case 2:
$target = "info.php?id=2";
break;
case 99:
$target = "https://digi.ninja";
break;
}
if ($target != "") {
header ("location: " . $target);
exit;
} else {
?>
Unknown redirect target.
<?php
exit;
}
}
?>
Missing redirect target.
指定重定向的网站并且无法控制