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

#rstream

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #next_session, #on_command_proc, #on_print_proc, #orig_suspend, #orig_usr1

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, #machine_id, #payload_uuid, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #via, #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::Basic

#_interact

Methods included from Msf::Session::Interactive

#_interact, #_interact_complete, #_interrupt, #_suspend, #_usr1, #cleanup, #initialize, #interactive?, #kill, #tunnel_local, #tunnel_peer, #user_want_abort?

Methods included from Rex::Ui::Interactive

#_interact, #_interact_complete, #_interrupt, #_local_fd, #_remote_fd, #_stream_read_local_write_remote, #_stream_read_remote_write_local, #_suspend, #detach, #handle_suspend, #handle_usr1, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1

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_blank_line, #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_source, #name, #name=, #register?, #session_host, #session_host=, #session_port, #session_port=, #session_type, #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.


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

def self.type
  "tty"
end

Instance Method Details

#descObject

Returns the session description.


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

def desc
  "Interactive TTY"
end

#run_cmd(cmd) ⇒ Object


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

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

#shell_closeObject

Closes the shell.


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

def shell_close()
  rstream.close
end

#shell_initObject

The shell will have been initialized by default.


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

def shell_init
  return true
end

#shell_read(length = nil) ⇒ Object

Read from the command shell.


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

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.


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

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

#typeObject

Calls the class method.


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

def type
  self.class.type
end