2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-04-12 05:37:11 +00:00
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Post
|
|
|
|
module Meterpreter
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
2005-11-15 05:22:13 +00:00
|
|
|
# This interface is meant to be included by things that are meant to contain
|
|
|
|
# zero or more channel instances in the form of a hash.
|
2005-04-12 05:37:11 +00:00
|
|
|
#
|
|
|
|
###
|
|
|
|
module ChannelContainer
|
|
|
|
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
# Initializes the channel association hash
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
def initialize_channels
|
|
|
|
self.channels = {}
|
|
|
|
end
|
|
|
|
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
# Adds a channel to the container that is indexed by its channel identifier
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
def add_channel(channel)
|
|
|
|
self.channels[channel.cid] = channel
|
|
|
|
end
|
|
|
|
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
# Looks up a channel instance based on its channel identifier
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
def find_channel(cid)
|
|
|
|
return self.channels[cid]
|
|
|
|
end
|
|
|
|
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
# Removes a channel based on its channel identifier
|
2005-07-26 05:15:46 +00:00
|
|
|
#
|
2005-04-12 05:37:11 +00:00
|
|
|
def remove_channel(cid)
|
|
|
|
return self.channels.delete(cid)
|
|
|
|
end
|
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
#
|
|
|
|
# The hash of channels.
|
|
|
|
#
|
2005-07-26 05:15:46 +00:00
|
|
|
attr_reader :channels
|
|
|
|
|
2005-04-12 05:37:11 +00:00
|
|
|
protected
|
2005-07-26 05:15:46 +00:00
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
attr_writer :channels # :nodoc:
|
2005-04-12 05:37:11 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2008-10-19 21:03:39 +00:00
|
|
|
end; end; end
|