Files
metasploit-gs/data/msfweb/app/controllers/payloads_controller.rb
T
HD Moore d69a1f6ff0 Adding the new msfweb tree, using rails 2.2.3 and newer prototype
git-svn-id: file:///home/svn/framework3/trunk@6651 4d416f70-5f16-0410-b530-b9f4589650da
2009-06-14 15:17:53 +00:00

73 lines
1.7 KiB
Ruby

# Author: LMH <lmh@info-pull.com>
# Description: The payload controller of msfweb v.3. Handles views, listing
# and other actions related to payload modules. Code and processing goes here.
# Instance variables, final values, etc, go into views.
class PayloadsController < ApplicationController
layout 'windows'
def list
end
def view
@tmod = get_view_for_module("payload", params[:refname])
unless @tmod
render_text "Unknown module specified."
end
# Catch non-standard payloads
begin
@tmod.generate
rescue => e
render_text "This interface does not support generic payloads."
end
@module_step = (params[:step] || 0).to_i
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
}
badchars_buff = ""
badchars.split(/,|\s+/).each do |c|
c.strip!
next if c.length == 0
if(c =~ /^0x/)
badchars_buff << c.hex.chr
else
badchars_buff << c.to_i.chr
end
end
begin
@generation = modinst.generate_simple(
'Encoder' => (pencoder == '__default') ? nil : pencoder,
'BadChars' => badchars_buff,
'Format' => pformat || 'c',
'OptionStr' => payload_opts,
'MaxSize' => (max_size == 0) ? nil : max_size)
rescue
@generation = $!
end
end
# end of view method
end
def generate
end
end