teach exploit how to parse datastore options too

GSoC/Meterpreter_Web_Console
Brent Cook 2017-09-25 08:09:39 -05:00
parent d8e5cc60bb
commit fbbfa0e0c3
2 changed files with 46 additions and 28 deletions

View File

@ -121,6 +121,7 @@ class Exploit
#
def cmd_exploit(*args)
force = false
module_opts = []
opts = {
'Encoder' => mod.datastore['ENCODER'],
'Payload' => mod.datastore['PAYLOAD'],
@ -138,31 +139,42 @@ class Exploit
opts['RunAsJob'] = true
end
@@exploit_opts.parse(args) { |opt, idx, val|
@@exploit_opts.parse(args) do |opt, idx, val|
case opt
when '-e'
opts['Encoder'] = val
when '-f'
force = true
when '-j'
opts['RunAsJob'] = true
when '-J'
opts['RunAsJob'] = false
when '-n'
opts['Nop'] = val
when '-o'
opts['OpttionStr'] = val
when '-p'
opts['Payload'] = val
when '-t'
opts['Target'] = val.to_i
when '-z'
opts['Background'] = true
when '-h'
when '-e'
opts['Encoder'] = val
when '-f'
force = true
when '-j'
opts['RunAsJob'] = true
when '-J'
opts['RunAsJob'] = false
when '-n'
opts['Nop'] = val
when '-o'
module_opts.push(val)
when '-p'
opts['Payload'] = val
when '-t'
opts['Target'] = val.to_i
when '-z'
opts['Background'] = true
when '-h'
cmd_exploit_help
return false
else
if val[0] != '-' && val.match?('=')
module_opts.push(val)
else
cmd_exploit_help
return false
end
end
}
end
unless module_opts.empty?
opts['OptionStr'] = module_opts.join(',')
end
minrank = RankingName.invert[framework.datastore['MinimumRank']] || 0
if minrank > mod.rank

View File

@ -20,7 +20,7 @@ module Msf
@@generate_opts = Rex::Parser::Arguments.new(
"-p" => [ true, "The platform of the payload" ],
"-n" => [ true, "Prepend a nopsled of [length] size on to the payload" ],
"-f" => [ true, "Output format: #{supported_formats.join(',')}" ],
"-f" => [ true, "Output format: #{@@supported_formats.join(',')}" ],
"-E" => [ false, "Force encoding" ],
"-e" => [ true, "The encoder to use" ],
"-s" => [ true, "NOP sled length." ],
@ -67,6 +67,13 @@ module Msf
"Payload"
end
def cmd_generate_help
print_line "Usage: generate [options]"
print_line
print_line "Generates a payload."
print @@generate_opts.usage
end
#
# Generates a payload.
#
@ -111,16 +118,15 @@ module Msf
when '-x'
template = val
when '-h'
print(
"Usage: generate [options]\n\n" \
"Generates a payload.\n" +
@@generate_opts.usage
)
return true
cmd_generate_help
return false
else
(key, val) = val.split('=')
if key && val
mod.datastore[key] = val
else
cmd_generate_help
return false
end
end
end