Skip to content

Commit ab8270d

Browse files
committed
adds some additional protection against capilization issues
1 parent d69fbf0 commit ab8270d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/msf/base/sessions/scriptable.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def execute_script(script_name, *args)
6565
opts = { 'SESSION' => self.sid }
6666
args.each do |arg|
6767
k,v = arg.split("=", 2)
68-
opts[k] = v
68+
# case doesn't matter in datastore, but it does in hashes, let's normalize
69+
opts[k.downcase] = v
6970
end
7071
if mod.type == "post"
7172
mod.run_simple(
@@ -83,22 +84,35 @@ def execute_script(script_name, *args)
8384
# get a copy of the session exploit's datastore if we can
8485
original_exploit_datastore = self.exploit.datastore || {}
8586
copy_of_orig_exploit_datastore = original_exploit_datastore.clone
87+
# convert datastore opts to a hash to normalize casing issues
88+
local_exploit_opts = {}
89+
copy_of_orig_exploit_datastore.each do |k,v|
90+
local_exploit_opts[k.downcase] = v
91+
end
8692
# we don't want to inherit a couple things, like AutoRunScript's
8793
to_neuter = %w{AutoRunScript InitialAutoRunScript LPORT TARGET}
8894
to_neuter.each do |setting|
89-
copy_of_orig_exploit_datastore.delete(setting)
95+
local_exploit_opts.delete(setting.downcase)
9096
end
9197

9298
# merge in any opts that were passed in, defaulting all other settings
9399
# to the values from the datastore (of the exploit) that spawned the
94100
# session
95-
local_exploit_opts = copy_of_orig_exploit_datastore.merge(opts)
101+
print_debug "local_exploit_opts"
102+
print_error local_exploit_opts.inspect
103+
print_error "lport:#{local_exploit_opts['lport']},LPORT:#{local_exploit_opts['LPORT']}"
104+
print_error "payload:#{local_exploit_opts['payload']},PAYLOAD:#{local_exploit_opts['PAYLOAD']}"
105+
local_exploit_opts = local_exploit_opts.merge(opts)
106+
print_error "after merge"
107+
print_error local_exploit_opts.inspect
108+
print_error "lport:#{local_exploit_opts['lport']},LPORT:#{local_exploit_opts['LPORT']}"
109+
print_error "payload:#{local_exploit_opts['payload']},PAYLOAD:#{local_exploit_opts['PAYLOAD']}"
96110

97111
# try to run this local exploit, which is likely to be exception prone
98112
begin
99113
new_session = mod.exploit_simple(
100-
'Payload' => local_exploit_opts['PAYLOAD'],
101-
'Target' => local_exploit_opts['TARGET'],
114+
'Payload' => local_exploit_opts.delete('payload'),
115+
'Target' => local_exploit_opts.delete('target'),
102116
'LocalInput' => self.user_input,
103117
'LocalOutput' => self.user_output,
104118
'Options' => local_exploit_opts

0 commit comments

Comments
 (0)