class Rex::Proto::Http::Handler::Proc

This class is used to wrapper the calling of a procedure when a request arrives.

Public Class Methods

new(server, procedure, virt_dir = false) click to toggle source

Initializes the proc handler with the supplied procedure

Calls superclass method Rex::Proto::Http::Handler::new
# File lib/rex/proto/http/handler/proc.rb, line 18
def initialize(server, procedure, virt_dir = false)
  super(server)

  self.procedure = procedure
  self.virt_dir  = virt_dir || false
end

Public Instance Methods

on_request(cli, req) click to toggle source

Called when a request arrives.

# File lib/rex/proto/http/handler/proc.rb, line 35
def on_request(cli, req)
  begin
    procedure.call(cli, req)
  rescue Errno::EPIPE, ::Errno::ECONNRESET, ::Errno::ENOTCONN, ::Errno::ECONNABORTED
    elog("Proc::on_request: Client closed connection prematurely", LogSource)
  rescue
    elog("Proc::on_request: #{$!.class}: #{$!}\n\n#{$@.join("\n")}", LogSource)
    if self.server and self.server.context
      exploit = self.server.context['MsfExploit']
      if exploit
        exploit.print_error("Exception handling request: #{$!}")
      end
    end
  end
end
relative_resource_required?() click to toggle source

Returns true if the procedure is representing a virtual directory.

# File lib/rex/proto/http/handler/proc.rb, line 28
def relative_resource_required?
  virt_dir
end