动态脚本黑客回调

发布于 2024-12-13 22:57:08 字数 1021 浏览 1 评论 0原文

我有一个仅包含字符串的页面,需要从不同域中的页面读取它。我尝试通过动态脚本 hack 来完成此操作(以避免安全限制),并且可以读取该字符串,但无法将其带入回调中以继续在变量中使用它。

我的问题是我只需要使用 javascript 来完成它。

这是我当前使用的代码:

index.html:

<html>
<head>
<script type="text/javascript">
    function xss_ajax(url) {
        var script_id = null;
        var script = document.createElement('script');
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src', url);
        script.setAttribute('id', 'script_id');

        script_id = document.getElementById('script_id');
        if(script_id){
            document.getElementsByTagName('head')[0].removeChild(script_id);
        }

        document.getElementsByTagName('head')[0].appendChild(script);
    }

    var url = "http://otherdomain.com/ping.html";

    xss_ajax(url);
</script>
</head>
<body>
</body>
</html>

ping.html:

1|1739

非常感谢,抱歉我的英语。

I have a page that only contains a string and need to read it from a page in a different domain. I have tried to do it via a dynamic script hack (to avoid the security restrictions) and can read that string but cant bring it in a callback to keep working with it in a variable.

My problem is that I need to do it only using javascript.

Here is the code that I am currently using:

index.html:

<html>
<head>
<script type="text/javascript">
    function xss_ajax(url) {
        var script_id = null;
        var script = document.createElement('script');
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src', url);
        script.setAttribute('id', 'script_id');

        script_id = document.getElementById('script_id');
        if(script_id){
            document.getElementsByTagName('head')[0].removeChild(script_id);
        }

        document.getElementsByTagName('head')[0].appendChild(script);
    }

    var url = "http://otherdomain.com/ping.html";

    xss_ajax(url);
</script>
</head>
<body>
</body>
</html>

ping.html:

1|1739

Very much thanks and sorry my english.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最后的乘客 2024-12-20 22:57:08

来自 ping.html 的结果没有定义任何变量,如果您说

对象

   result = [1,1739];

创建了一个像您声明的那样的

var result = [];

,那么您可以使用它。

Your result from ping.html dose not have any variables defined, if you say

made an object like

   result = [1,1739];

and in index.html you declared

var result = [];

then you could work with that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文