diff --git a/data/msfweb/app/controllers/payloads_controller.rb b/data/msfweb/app/controllers/payloads_controller.rb index 7e141e6a31..b6668cb61a 100644 --- a/data/msfweb/app/controllers/payloads_controller.rb +++ b/data/msfweb/app/controllers/payloads_controller.rb @@ -15,11 +15,36 @@ class PayloadsController < ApplicationController unless @tmod render_text "Unknown module specified." end + + @module_step = (params[:step] || 0).to_i - if params[:step] - @module_step = params[:step] + if @module_step == 1 + modinst = Payload.create(@tmod.refname) + badchars = params[:badchars] + pencoder = params[:encoder] + pformat = params[:format] + max_size = (params[:max_size] || 0).to_i + payload_opts = '' + + params.each_pair { |k, v| + next if (v == nil or v.length == 0) + if (k =~ /^opt_(.*)$/) + payload_opts += "#{$1}=#{v} " + end + } + + begin + @generation = modinst.generate_simple( + 'Encoder' => (pencoder == '__default') ? nil : pencoder, + 'BadChars' => badchars, + 'Format' => pformat || 'c', + 'OptionStr' => payload_opts, + 'MaxSize' => (max_size == 0) ? nil : max_size) + rescue + @generation = $! + end end - + # end of view method end def generate diff --git a/data/msfweb/app/models/payload.rb b/data/msfweb/app/models/payload.rb index ccc6eb9c25..eb58ace958 100644 --- a/data/msfweb/app/models/payload.rb +++ b/data/msfweb/app/models/payload.rb @@ -4,4 +4,9 @@ class Payload $msframework.payloads.each_module { |n,m| mods << m.new } mods end + + def self.create(refname) + modinst = $msframework.payloads.create(refname) + modinst + end end diff --git a/data/msfweb/app/views/payloads/view.rhtml b/data/msfweb/app/views/payloads/view.rhtml index 6671547f9c..299a5473f6 100644 --- a/data/msfweb/app/views/payloads/view.rhtml +++ b/data/msfweb/app/views/payloads/view.rhtml @@ -1,5 +1,5 @@
Operating system: | <%= @tmod.platform_to_s %> |
+ | |
---|---|
Options | +
<%=@generation%>