2005-07-16 07:32:11 +00:00
|
|
|
module Msf
|
|
|
|
module Session
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Basic
|
|
|
|
# -----
|
|
|
|
#
|
|
|
|
# This class implements an interactive session using raw input/output in
|
|
|
|
# only the most basic fashion.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Basic
|
|
|
|
|
|
|
|
include Session
|
|
|
|
include Interactive
|
|
|
|
|
2005-07-16 08:12:58 +00:00
|
|
|
#
|
|
|
|
# Description of the session
|
|
|
|
#
|
|
|
|
def desc
|
2005-07-16 16:06:44 +00:00
|
|
|
"Basic I/O"
|
2005-07-16 08:12:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Basic session
|
|
|
|
#
|
|
|
|
def type
|
|
|
|
"basic"
|
|
|
|
end
|
|
|
|
|
2005-07-16 07:32:11 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
#
|
|
|
|
# Performs the actual raw interaction with the remote side. This can be
|
|
|
|
# overriden by derived classes if they wish to do this another way.
|
|
|
|
#
|
|
|
|
def _interact
|
2005-07-17 02:04:39 +00:00
|
|
|
while self.interacting
|
2005-07-16 07:32:11 +00:00
|
|
|
# Select input and rstream
|
2005-07-17 07:06:05 +00:00
|
|
|
sd = Rex::ThreadSafe.select([ user_input.fd, rstream.fd ])
|
2005-07-16 07:32:11 +00:00
|
|
|
|
|
|
|
# Cycle through the items that have data
|
2005-07-17 07:06:05 +00:00
|
|
|
# From the rstream? Write to user_output.
|
2005-07-16 07:32:11 +00:00
|
|
|
sd[0].each { |s|
|
|
|
|
if (s == rstream.fd)
|
|
|
|
data = rstream.get
|
|
|
|
|
2005-07-17 07:06:05 +00:00
|
|
|
user_output.print(data)
|
|
|
|
# From user_input? Write to rstream.
|
|
|
|
elsif (s == user_input.fd)
|
|
|
|
data = user_input.gets
|
2005-07-16 07:32:11 +00:00
|
|
|
|
|
|
|
rstream.put(data)
|
|
|
|
end
|
|
|
|
} if (sd)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|