Module: Rex::Post::Meterpreter::Ui::Console::InteractiveChannel

Includes:
Ui::Interactive
Defined in:
lib/rex/post/meterpreter/ui/console/interactive_channel.rb

Overview

Mixin that is meant to extend the base channel class from meterpreter in a manner that adds interactive capabilities.

Instance Attribute Summary

Attributes included from Ui::Interactive

#completed, #interacting, #on_command_proc, #on_print_proc

Attributes included from Ui::Subscriber::Input

#user_input

Attributes included from Ui::Subscriber::Output

#user_output

Instance Method Summary collapse

Methods included from Ui::Interactive

#detach, #interact

Methods included from Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Ui::Subscriber::Input

#gets

Methods included from Ui::Subscriber::Output

#flush, #print, #print_debug, #print_error, #print_good, #print_line, #print_status

Instance Method Details

#_interactObject

Interacts with self.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 19

def _interact
	# If the channel has a left-side socket, then we can interact with it.
	if (self.lsock)
		self.interactive(true)

		interact_stream(self)

		self.interactive(false)
	else
		print_error("Channel #{self.cid} does not support interaction.")

		self.interacting = false
	end
end

#_interact_completeObject

Closes the channel like it aint no thang.



56
57
58
59
60
61
62
63
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 56

def _interact_complete
	begin
		self.interactive(false)

		self.close
	rescue IOError
	end
end

#_interruptObject

Called when an interrupt is sent.



37
38
39
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 37

def _interrupt
	prompt_yesno("Terminate channel #{self.cid}?")	
end

#_remote_fd(stream) ⇒ Object

Returns the remote file descriptor to select on



89
90
91
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 89

def _remote_fd(stream)
	self.lsock
end

#_stream_read_local_write_remote(channel) ⇒ Object

Reads data from local input and writes it remotely.



68
69
70
71
72
73
74
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 68

def _stream_read_local_write_remote(channel)
	data = user_input.gets
	return if not data

	self.on_command_proc.call(data.strip) if self.on_command_proc
	self.write(data)
end

#_stream_read_remote_write_local(channel) ⇒ Object

Reads from the channel and writes locally.



79
80
81
82
83
84
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 79

def _stream_read_remote_write_local(channel)
	data = self.lsock.sysread(16384)

	self.on_print_proc.call(data.strip) if self.on_print_proc
	user_output.print(data)
end

#_suspendObject

Suspends interaction with the channel.



44
45
46
47
48
49
50
51
# File 'lib/rex/post/meterpreter/ui/console/interactive_channel.rb', line 44

def _suspend
	# Ask the user if they would like to background the session
	if (prompt_yesno("Background channel #{self.cid}?") == true)
		self.interactive(false)

		self.interacting = false
	end
end