Path: blob/master/lib/msf/base/sessions/tty.rb
59979 views
# -*- coding: binary -*-123module Msf4module Sessions56###7#8# This class provides basic interaction with a command shell on the remote9# endpoint. This session is initialized with a stream that will be used10# as the pipe for reading and writing the command shell.11#12###13class TTY1415#16# This interface supports basic interaction.17#18include Msf::Session::Basic1920#21# This interface supports interacting with a single command shell.22#23include Msf::Session::Provider::SingleCommandShell2425#26# Returns the type of session.27#28def self.type29"tty"30end3132#33# Returns the session description.34#35def desc36"Interactive TTY"37end3839def run_cmd(cmd)40shell_write(cmd)41return rstream.get42end43#44# Calls the class method.45#46def type47self.class.type48end4950#51# The shell will have been initialized by default.52#53def shell_init54return true55end5657#58# Read from the command shell.59#60def shell_read(length = nil)61if length.nil?62rv = rstream.get63else64rv = rstream.read(length)65end66return rv67end6869#70# Writes to the command shell.71#72def shell_write(buf)73rstream.write(buf)74end7576#77# Closes the shell.78#79def shell_close()80rstream.close81end8283def self.can_cleanup_files84true85end8687end8889end90end919293