Path: blob/master/lib/rex/proto/http/handler/proc.rb
19592 views
# -*- coding: binary -*-1require 'erb'23module Rex4module Proto5module Http67###8#9# This class is used to wrapper the calling of a procedure when a request10# arrives.11#12###13class Handler::Proc < Handler1415#16# Initializes the proc handler with the supplied procedure17#18def initialize(server, procedure, virt_dir = false)19super(server)2021self.procedure = procedure22self.virt_dir = virt_dir || false23end2425#26# Returns true if the procedure is representing a virtual directory.27#28def relative_resource_required?29virt_dir30end3132#33# Called when a request arrives.34#35def on_request(cli, req)36begin37procedure.call(cli, req)38rescue Errno::EPIPE, ::Errno::ECONNRESET, ::Errno::ENOTCONN, ::Errno::ECONNABORTED => e39elog('Proc::on_request: Client closed connection prematurely', LogSource, error: e)40rescue => e41elog('Proc::on_request', LogSource, error: e)42if self.server and self.server.context43exploit = self.server.context['MsfExploit']44if exploit45exploit.print_error("Exception handling request: #{$!}")46end47end48end49end5051protected5253attr_accessor :procedure # :nodoc:54attr_accessor :virt_dir # :nodoc:5556end5758end59end60end616263