CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/lib/rex/post/meterpreter/channels/pools/stream_pool.rb
Views: 1904
# -*- coding: binary -*-12require 'rex/io/stream_abstraction'3require 'rex/post/meterpreter/channels/pool'4require 'rex/post/meterpreter/extensions/stdapi/tlv'56module Rex7module Post8module Meterpreter9module Channels10module Pools1112###13#14# StreamPool15# ----------16#17# This class represents a channel that is associated with a18# streaming pool that has no definite end-point. While this19# may seem a paradox given the stream class of channels, it's20# in fact dinstinct because streams automatically forward21# traffic between the two ends of the channel whereas22# stream pools are always requested data in a single direction.23#24###25class StreamPool < Rex::Post::Meterpreter::Channels::Pool2627include Rex::IO::StreamAbstraction2829##30#31# Constructor32#33##3435# Initializes the file channel instance36def initialize(client, cid, type, flags, packet, **_)37super(client, cid, type, flags, packet)3839initialize_abstraction40end4142##43#44# Streaming pools don't support tell, seek, or eof.45#46##4748#49# This method returns the current offset into the pool.50#51def tell52raise NotImplementedError53end5455#56# This method seeks to an offset in the pool.57#58def seek59raise NotImplementedError60end6162#63# This method returns whether or not eof has been returned.64#65def eof66return false67end6869#70# Transfers data to the local half of the pool for reading.71#72def dio_write_handler(packet, data)73rv = Rex::ThreadSafe.select(nil, [rsock], nil, 0.01)74if(rv)75rsock.write(data)76return true77else78return false79end80end8182#83# Closes the local half of the pool stream.84#85def dio_close_handler(packet)86rsock.close8788return super(packet)89end9091#92# Cleans up resources used by the channel.93#94def cleanup95super9697cleanup_abstraction98end99100end101102end; end; end; end; end103104105106