Class: Rex::Proto::Http::Handler::Proc

Inherits:
Rex::Proto::Http::Handler show all
Defined in:
lib/rex/proto/http/handler/proc.rb

Overview

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

Defined Under Namespace

Classes: UnitTest

Instance Method Summary collapse

Methods inherited from Rex::Proto::Http::Handler

relative_resource_required?

Constructor Details

#initialize(server, procedure, virt_dir = false) ⇒ Proc

Initializes the proc handler with the supplied procedure



18
19
20
21
22
23
# 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

Instance Method Details

#on_request(cli, req) ⇒ Object

Called when a request arrives.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rex/proto/http/handler/proc.rb', line 35

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: #{$!}\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?Boolean

Returns true if the procedure is representing a virtual directory.

Returns:

  • (Boolean)


28
29
30
# File 'lib/rex/proto/http/handler/proc.rb', line 28

def relative_resource_required?
	virt_dir	
end