Class: Msf::Sessions::TTY

Inherits:
Object
  • Object
show all
Includes:
Msf::Session::Basic, Msf::Session::Provider::SingleCommandShell
Defined in:
lib/msf/base/sessions/tty.rb

Overview

This class provides basic interaction with a command shell on the remote endpoint. This session is initialized with a stream that will be used as the pipe for reading and writing the command shell.

Instance Attribute Summary

Attributes included from Msf::Session::Interactive

#ring, #rstream

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #on_command_proc, #on_print_proc

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Attributes included from Msf::Session

#alive, #db_record, #exploit, #exploit_datastore, #exploit_task, #exploit_uuid, #framework, #info, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #workspace

Attributes included from Framework::Offspring

#framework

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Msf::Session::Provider::SingleCommandShell

#set_shell_token_index, #shell_command_token, #shell_command_token_unix, #shell_command_token_win32, #shell_read_until_token

Methods included from Msf::Session::Interactive

#cleanup, #initialize, #interactive?, #kill, #tunnel_local, #tunnel_peer

Methods included from Rex::Ui::Interactive

#detach, #interact

Methods included from Rex::Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

Methods included from Rex::Ui::Subscriber::Output

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

Methods included from Msf::Session

#alive?, #cleanup, #dead?, #initialize, #inspect, #interactive?, #kill, #log_file_name, #log_from_local, #log_from_remote, #log_source, #name, #name=, #register?, #session_host, #session_host=, #session_port, #session_port=, #set_from_exploit, #set_via, #tunnel_local, #tunnel_peer, #tunnel_to_s, #via_exploit, #via_payload

Class Method Details

.typeObject

Returns the type of session.


30
31
32
# File 'lib/msf/base/sessions/tty.rb', line 30

def self.type
  "tty"
end

Instance Method Details

#descObject

Returns the session description.


37
38
39
# File 'lib/msf/base/sessions/tty.rb', line 37

def desc
  "Interactive TTY"
end

#run_cmd(cmd) ⇒ Object


41
42
43
44
# File 'lib/msf/base/sessions/tty.rb', line 41

def run_cmd(cmd)
  shell_write(cmd)
  return rstream.get
end

#shell_closeObject

Closes the shell.


81
82
83
# File 'lib/msf/base/sessions/tty.rb', line 81

def shell_close()
  rstream.close
end

#shell_initObject

The shell will have been initialized by default.


55
56
57
# File 'lib/msf/base/sessions/tty.rb', line 55

def shell_init
  return true
end

#shell_read(length = nil) ⇒ Object

Read from the command shell.


62
63
64
65
66
67
68
69
# File 'lib/msf/base/sessions/tty.rb', line 62

def shell_read(length = nil)
  if length.nil?
    rv = rstream.get
  else
    rv = rstream.read(length)
  end
  return rv
end

#shell_write(buf) ⇒ Object

Writes to the command shell.


74
75
76
# File 'lib/msf/base/sessions/tty.rb', line 74

def shell_write(buf)
  rstream.write(buf)
end

#typeObject

Calls the class method.


48
49
50
# File 'lib/msf/base/sessions/tty.rb', line 48

def type
  self.class.type
end