Sha256: a28857b53c09288f173b97935e8e14b4a675ef609d88e2414ed8f2cf16d8e259

Contents?: true

Size: 1.07 KB

Versions: 23

Compression:

Stored size: 1.07 KB

Contents

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

23 entries across 23 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/proto/http/handler/proc.rb
librex-0.0.63 lib/rex/proto/http/handler/proc.rb
librex-0.0.54 lib/rex/proto/http/handler/proc.rb
librex-0.0.53 lib/rex/proto/http/handler/proc.rb
librex-0.0.52 lib/rex/proto/http/handler/proc.rb
librex-0.0.51 lib/rex/proto/http/handler/proc.rb
librex-0.0.50 lib/rex/proto/http/handler/proc.rb
librex-0.0.49 lib/rex/proto/http/handler/proc.rb
librex-0.0.48 lib/rex/proto/http/handler/proc.rb
librex-0.0.47 lib/rex/proto/http/handler/proc.rb
librex-0.0.46 lib/rex/proto/http/handler/proc.rb
librex-0.0.44 lib/rex/proto/http/handler/proc.rb
librex-0.0.43 lib/rex/proto/http/handler/proc.rb
librex-0.0.42 lib/rex/proto/http/handler/proc.rb
librex-0.0.41 lib/rex/proto/http/handler/proc.rb
librex-0.0.40 lib/rex/proto/http/handler/proc.rb
librex-0.0.39 lib/rex/proto/http/handler/proc.rb
librex-0.0.38 lib/rex/proto/http/handler/proc.rb
librex-0.0.37 lib/rex/proto/http/handler/proc.rb
librex-0.0.36 lib/rex/proto/http/handler/proc.rb