Class: Rex::Script::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/script/base.rb

Direct Known Subclasses

Meterpreter, Shell

Defined Under Namespace

Classes: OutputSink

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, path) ⇒ Base

Returns a new instance of Base.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rex/script/base.rb', line 17

def initialize(client, path)
	self.client    = client
	self.framework = client.framework
	self.path      = path
	self.sink      = OutputSink.new

	if(client.framework.db and client.framework.db.active)
		self.workspace = client.framework.db.find_workspace( client.workspace.to_s ) || client.framework.db.workspace
	end

	# Convenience aliases
	self.session   = self.client
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



14
15
16
# File 'lib/rex/script/base.rb', line 14

def args
  @args
end

#clientObject

Returns the value of attribute client.



14
15
16
# File 'lib/rex/script/base.rb', line 14

def client
  @client
end

#errorObject

Returns the value of attribute error.



14
15
16
# File 'lib/rex/script/base.rb', line 14

def error
  @error
end

#frameworkObject

Returns the value of attribute framework.



14
15
16
# File 'lib/rex/script/base.rb', line 14

def framework
  @framework
end

#pathObject

Returns the value of attribute path.



14
15
16
# File 'lib/rex/script/base.rb', line 14

def path
  @path
end

#sessionObject

Returns the value of attribute session.



15
16
17
# File 'lib/rex/script/base.rb', line 15

def session
  @session
end

#sinkObject

Returns the value of attribute sink.



15
16
17
# File 'lib/rex/script/base.rb', line 15

def sink
  @sink
end

#workspaceObject

Returns the value of attribute workspace.



15
16
17
# File 'lib/rex/script/base.rb', line 15

def workspace
  @workspace
end

Instance Method Details

#completedObject



35
36
37
# File 'lib/rex/script/base.rb', line 35

def completed
	raise Rex::Script::Completed
end

#outputObject



31
32
33
# File 'lib/rex/script/base.rb', line 31

def output
	client.user_output || self.sink
end


51
# File 'lib/rex/script/base.rb', line 51

def print(*args);         output.print(*args);          end


53
# File 'lib/rex/script/base.rb', line 53

def print_error(*args);   output.print_error(*args);    end


54
# File 'lib/rex/script/base.rb', line 54

def print_good(*args);    output.print_good(*args);     end


55
# File 'lib/rex/script/base.rb', line 55

def print_line(*args);    output.print_line(*args);     end


52
# File 'lib/rex/script/base.rb', line 52

def print_status(*args);  output.print_status(*args);   end

#run(args = []) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rex/script/base.rb', line 39

def run(args=[])
	self.args = args = args.flatten
	begin
		eval(::File.read(self.path, ::File.size(self.path)), binding )
	rescue ::Interrupt
	rescue ::Rex::Script::Completed
	rescue ::Exception => e
		self.error = e
		raise e
	end
end