Skip to content

Commit dfd9522

Browse files
committed
Merge from remote (pr merged via github)
2 parents 6c29bae + d12412d commit dfd9522

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/msf/base/sessions/scriptable.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def execute_file
5252
end
5353

5454
#
55-
# Executes the supplied script or Post module with arguments +args+
55+
# Executes the supplied script, Post module, or local exploit with arguments +args+
5656
#
5757
# Will search the script path.
5858
#
@@ -61,13 +61,12 @@ def execute_script(script_name, *args)
6161
if mod
6262
# Don't report module run events here as it will be taken care of
6363
# in +Post.run_simple+
64-
# meterpreter scripts don't need SESSION, but it's not gonna hurt
6564
opts = { 'SESSION' => self.sid }
6665
args.each do |arg|
6766
k,v = arg.split("=", 2)
6867
opts[k] = v
6968
end
70-
if mod.type == "post"
69+
if mod.type == "post"
7170
mod.run_simple(
7271
# Run with whatever the default stance is for now. At some
7372
# point in the future, we'll probably want a way to force a
@@ -77,17 +76,15 @@ def execute_script(script_name, *args)
7776
'LocalOutput' => self.user_output,
7877
'Options' => opts
7978
)
80-
elsif mod.type == "exploit"
79+
elsif mod.type == "exploit"
8180
# well it must be a local, we're not currently supporting anything else
8281
if mod.exploit_type == "local"
8382
# get a copy of the session exploit's datastore if we can
8483
original_exploit_datastore = self.exploit.datastore || {}
85-
copy_of_orig_exploit_datastore = original_exploit_datastore.clone
84+
copy_of_orig_exploit_datastore = original_exploit_datastore.dup
8685
# we don't want to inherit a couple things, like AutoRunScript's
87-
to_neuter = ['AutoRunScript', 'InitialAutoRunScript']
86+
to_neuter = ['AutoRunScript', 'InitialAutoRunScript', 'LPORT']
8887
to_neuter.each { |setting| copy_of_orig_exploit_datastore.delete(setting) }
89-
# @TODO: if opts are the same, we don't need another handler, set
90-
# DisablePayloadHandler => true in that case?
9188

9289
# merge in any opts that were passed in, defaulting to the
9390
# copy of the datastore (of the exploit) that spawned the session
@@ -96,8 +93,8 @@ def execute_script(script_name, *args)
9693
# try to run this local exploit, which is likely to be exception prone
9794
begin
9895
new_session = mod.exploit_simple(
99-
'PAYLOAD' => local_exploit_opts['PAYLOAD'],
100-
'TARGET' => local_exploit_opts['TARGET'],
96+
'Payload' => local_exploit_opts['PAYLOAD'],
97+
'Target' => local_exploit_opts['TARGET'],
10198
'LocalInput' => self.user_input,
10299
'LocalOutput' => self.user_output,
103100
'Options' => local_exploit_opts
@@ -118,7 +115,7 @@ def execute_script(script_name, *args)
118115
end # end if local
119116
end # end if exploit
120117

121-
else # else no mod
118+
else
122119
full_path = self.class.find_script_path(script_name)
123120

124121
# No path found? Weak.
@@ -128,10 +125,9 @@ def execute_script(script_name, *args)
128125
end
129126
framework.events.on_session_script_run(self, full_path)
130127
execute_file(full_path, args)
131-
end # end if mod
128+
end
132129
end
133130

134131
end
135132

136133
end
137-

0 commit comments

Comments
 (0)