Module: Rex::Post::Meterpreter::SocketAbstraction
Overview
Abstraction
This class represents a channel that is streaming. This means that sequential data is flowing in either one or both directions.
Defined Under Namespace
Modules: DirectChannelWrite, SocketInterface
Instance Method Summary collapse
-
#_write(*args) ⇒ Object
Wrap the _write() call in order to catch some common, but harmless Windows exceptions.
-
#cleanup ⇒ Object
Cleans up the stream abstraction.
-
#dio_close_handler(packet) ⇒ Object
Performs a close operation on the right side of the local stream.
-
#dio_write_handler(packet, data) ⇒ Object
Performs a write operation on the right side of the local stream.
-
#initialize(client, cid, type, flags, packet, **_) ⇒ Object
Passes the initialization information up to the base class.
Instance Method Details
#_write(*args) ⇒ Object
Wrap the _write() call in order to catch some common, but harmless Windows exceptions
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 138 def _write(*args) begin super(*args) rescue ::Rex::Post::Meterpreter::RequestError => e case e.code when 10000 .. 10100 raise ::Rex::ConnectionError.new end end end |
#cleanup ⇒ Object
Cleans up the stream abstraction.
129 130 131 132 133 |
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 129 def cleanup super cleanup_abstraction end |
#dio_close_handler(packet) ⇒ Object
Performs a close operation on the right side of the local stream.
120 121 122 123 124 |
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 120 def dio_close_handler(packet) rsock.close return super(packet) end |
#dio_write_handler(packet, data) ⇒ Object
Performs a write operation on the right side of the local stream.
107 108 109 110 111 112 113 114 115 |
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 107 def dio_write_handler(packet, data) rv = Rex::ThreadSafe.select(nil, [rsock], nil, 0.01) if(rv) rsock.syswrite(data) return true else return false end end |
#initialize(client, cid, type, flags, packet, **_) ⇒ Object
Passes the initialization information up to the base class
89 90 91 92 93 94 95 96 |
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 89 def initialize(client, cid, type, flags, packet, **_) # sf: initialize_abstraction() before super() as we can get a scenario where dio_write_handler() is called # with data to write to the rsock but rsock has not yet been initialized. This happens if the channel # is registered (client.add_channel(self) in Channel.initialize) to a session and a COMMAND_ID_CORE_CHANNEL_WRITE # request comes in before we have called self.initialize_abstraction() initialize_abstraction super(client, cid, type, flags, packet) end |