Add a new TTY session type for customization
git-svn-id: file:///home/svn/framework3/trunk@6140 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
5600b0b67d
commit
44caffbd87
|
@ -0,0 +1,86 @@
|
||||||
|
require 'msf/base'
|
||||||
|
|
||||||
|
module Msf
|
||||||
|
module Sessions
|
||||||
|
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
###
|
||||||
|
class TTY
|
||||||
|
|
||||||
|
#
|
||||||
|
# This interface supports basic interaction.
|
||||||
|
#
|
||||||
|
include Msf::Session::Basic
|
||||||
|
|
||||||
|
#
|
||||||
|
# This interface supports interacting with a single command shell.
|
||||||
|
#
|
||||||
|
include Msf::Session::Provider::SingleCommandShell
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the type of session.
|
||||||
|
#
|
||||||
|
def self.type
|
||||||
|
"tty"
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the session description.
|
||||||
|
#
|
||||||
|
def desc
|
||||||
|
"Interactive TTY"
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_cmd(cmd)
|
||||||
|
write_shell(cmd)
|
||||||
|
return rstream.get
|
||||||
|
end
|
||||||
|
#
|
||||||
|
# Calls the class method.
|
||||||
|
#
|
||||||
|
def type
|
||||||
|
self.class.type
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# The shell will have been initialized by default.
|
||||||
|
#
|
||||||
|
def init_shell
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Read from the command shell.
|
||||||
|
#
|
||||||
|
def read_shell(length = nil)
|
||||||
|
if length.nil?
|
||||||
|
rv = rstream.get
|
||||||
|
else
|
||||||
|
rv = rstream.read(length)
|
||||||
|
end
|
||||||
|
return rv
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Writes to the command shell.
|
||||||
|
#
|
||||||
|
def write_shell(buf)
|
||||||
|
rstream.write(buf)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Closes the shell.
|
||||||
|
#
|
||||||
|
def close_shell()
|
||||||
|
rstream.close
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue