Sha256: 557880f2cbaf64b0c6f6c18bed2684fca8ba9ada5684672b8dfb43570c9b1639

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

# -*- coding: binary -*-
require 'erb'

module Rex
module Proto
module Http

###
#
# This class is used to wrapper the calling of a procedure when a request
# arrives.
#
###
class Handler::Proc < Handler

  #
  # Initializes the proc handler with the supplied procedure
  #
  def initialize(server, procedure, virt_dir = false)
    super(server)

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

  #
  # Returns true if the procedure is representing a virtual directory.
  #
  def relative_resource_required?
    virt_dir
  end

  #
  # Called when a request arrives.
  #
  def on_request(cli, req)
    begin
      procedure.call(cli, req)
    rescue Errno::EPIPE
      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

protected

  attr_accessor :procedure # :nodoc:
  attr_accessor :virt_dir  # :nodoc:

end

end
end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
dstruct-0.0.1 lib/rex/proto/http/handler/proc.rb
rex-2.0.3 lib/rex/proto/http/handler/proc.rb
librex-0.0.999 lib/rex/proto/http/handler/proc.rb
rex-2.0.2 lib/rex/proto/http/handler/proc.rb
librex-0.0.71 lib/rex/proto/http/handler/proc.rb
librex-0.0.70 lib/rex/proto/http/handler/proc.rb