DVWA-13.4 CSP Bypass(绕过浏览器的安全策略)-Impossible

 
更多

Impossible Level

查看源码

impossible.php

<?php

$headerCSP = "Content-Security-Policy: script-src 'self';";

header($headerCSP);

?>
<?php
if (isset ($_POST['include'])) {
$page[ 'body' ] .= "
    " . $_POST['include'] . "
";
}
$page[ 'body' ] .= '
<form name="csp" method="POST">
    <p>Unlike the high level, this does a JSONP call but does not use a callback, instead it hardcodes the function to call.</p><p>The CSP settings only allow external JavaScript on the local server and no inline code.</p>
    <p>1+2+3+4+5=<span id="answer"></span></p>
    <input type="button" id="solve" value="Solve the sum" />
</form>

<script src="source/impossible.js"></script>
';

impossible.js

function clickButton() {
    var s = document.createElement("script");
    s.src = "source/jsonp_impossible.php";
    document.body.appendChild(s);
}

function solveSum(obj) {
    if ("answer" in obj) {
        document.getElementById("answer").innerHTML = obj['answer'];
    }
}

var solve_button = document.getElementById ("solve");

if (solve_button) {
    solve_button.addEventListener("click", function() {
        clickButton();
    });
}

jsonp_impossible.php

<?php
header("Content-Type: application/json; charset=UTF-8");

$outp = array ("answer" => "15");

echo "solveSum (".json_encode($outp).")";
?>

该级别主要还是修复了 callback 参数可被控制问题,无法进行攻击。

参考:https://zhuanlan.zhihu.com/p/110012962

打赏

本文固定链接: https://www.cxy163.net/archives/4874 | 绝缘体

该日志由 绝缘体.. 于 2020年05月06日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: DVWA-13.4 CSP Bypass(绕过浏览器的安全策略)-Impossible | 绝缘体
关键字: , , , ,

DVWA-13.4 CSP Bypass(绕过浏览器的安全策略)-Impossible:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter