DVWA靶场之十六:未验证的重定向漏洞(Open HTTP Redirect)

DVWA靶场之十六:未验证的重定向漏洞(Open HTTP Redirect)


当 Web 应用程序接受不受信任的输入时,可能会发生未经验证的重定向和转发,这可能导致 Web 应用程序将请求重定向到包含在不受信任输入中的 URL。通过将不受信任的 URL 输入修改为恶意网站,攻击者可以成功发起网络钓鱼诈骗并窃取用户凭据。

如上所述,这种攻击的常见用途是创建一个 URL,该 URL 最初指向真实网站,然后重定向受害者到攻击者控制的网站。该网站可能是目标登录页面的克隆版本以窃取凭据,也可能是请求信用卡信息以支付目标网站上的服务费用,或者只是一个充满广告的垃圾页面。

目标:

重定向页面,将用户从 DVWA 网站移出或移至网站上与预期不同的页面。


1. Low:直接重定向

php 复制代码
<?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;
?>

redirect 参数作为 location的值。可以重定向到任何网站:

比如127.0.0.1/vulnerabilities/open_redirect/source/low.php?redirect=https://www.baidu.com

就可以重定向到百度


2. Medium:过滤了协议名

php 复制代码
<?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;
?>

意义不大,去掉协议名字即可。

比如127.0.0.1/vulnerabilities/open_redirect/source/medium.php?redirect=//www.baidu.com


3. High:必须包含子串

php 复制代码
<?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" 的路径

要简洁地绕过此限制,只需附加一个无效参数即可。原URL中的 info.php 会被新参数截断,从而实现跳转:
http://127.0.0.1/vulnerabilities/open_redirect/source/high.php?redirect=https://www.baidu.com?a=info.php


4. impossible 白名单

php 复制代码
<?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.

只接受数字参数,完全避免字符串注入。这一等级直接判断目标是 info.php?id=1 或者 info.php?id=2 或者 info.php?id=99,其他一概拒绝。

相关推荐
一次旅行4 天前
网络安全总结
安全·web安全
DianSan_ERP4 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
red1giant_star4 天前
手把手教你用Vulhub复现ecshop collection_list-sqli漏洞(附完整POC)
安全
呉師傅4 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
ZeroNews内网穿透4 天前
谷歌封杀OpenClaw背后:本地部署或是出路
运维·服务器·数据库·安全
2501_946205524 天前
晶圆机器人双臂怎么选型?适配2-12寸晶圆的末端效应器有哪些?
服务器·网络·机器人
linux kernel4 天前
第七部分:高级IO
服务器·网络
数字护盾(和中)4 天前
BAS+ATT&CK:企业主动防御的黄金组合
服务器·网络·数据库
~远在太平洋~4 天前
Debian系统如何删除多余的kernel
linux·网络·debian
一名优秀的码农4 天前
vulhub系列-14-Os-hackNos-1(超详细)
安全·web安全·网络安全·网络攻击模型·安全威胁分析