通过在运行时删除页面源代码来阻止JavaScript代码运行

Preventing JavaScript code from running by removing from the page source at runtime

本文关键字:JavaScript 运行 代码 源代码 运行时 删除      更新时间:2023-09-26

有人在我朋友的网站上输入了XSS代码。它在页面源中插入<script>alert(0)</script>。你可以在这里看到。

是否有一种方法可以在运行时从页面中删除这个,以防止它被执行?

他明天有一个关于它的报告,他不能访问数据库来删除它

作为一个真正快速的修复。如果他可以访问javascript,他可以像下面这样做一个简单的技巧。

   alert = function() {}

您可以在加载数据之前禁用http://technoflexusdatastreamapi.appspot.com/landingpage上的alert:

$('.viewDataLink').click(function ()
{
    $("#scriptShow").hide();
    $("#showData").show();
    $("#progressAnimation").show();
    var tmpAlert = alert;
    window.alert = function () { };
    $("#showData").load("/listData", function (response, status, xhr)
    {
        if (status == "success")
        {
            $("#progressAnimation").hide();
            window.alert = tmpAlert;
        }
    });
});