Class: RubySMB::SMB1::Pipe
- Includes:
- Dcerpc
- Defined in:
- lib/ruby_smb/smb1/pipe.rb
Overview
Represents a pipe on the Remote server that we can perform various I/O operations on.
Constant Summary collapse
- STATUS_DISCONNECTED =
0x0001
- STATUS_LISTENING =
0x0002
- STATUS_OK =
0x0003
- STATUS_CLOSED =
0x0004
Instance Attribute Summary
Attributes inherited from File
#attributes, #fid, #last_access, #last_change, #last_write, #name, #size, #size_on_disk, #tree
Instance Method Summary collapse
-
#is_connected? ⇒ Boolean
True if pipe is connected, false otherwise.
-
#peek(peek_size: 0) ⇒ RubySMB::SMB1::Packet::Trans::PeekNmpipeResponse
Performs a peek operation on the named pipe.
-
#peek_available ⇒ Integer
The number of bytes available to be read from the pipe.
-
#peek_state ⇒ Integer
Pipe status.
Methods included from Dcerpc
#bind, #net_share_enum_all, #request
Methods inherited from File
#append, #close, #delete, #delete_packet, #initialize, #read, #read_packet, #rename, #rename_packet, #send_recv_read, #send_recv_write, #set_header_fields, #write, #write_packet
Constructor Details
This class inherits a constructor from RubySMB::SMB1::File
Instance Method Details
#is_connected? ⇒ Boolean
Returns True if pipe is connected, false otherwise.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_smb/smb1/pipe.rb', line 59 def is_connected? begin state = peek_state rescue RubySMB::Error::UnexpectedStatusCode => e if e. == 'STATUS_INVALID_HANDLE' return false end raise e end state == STATUS_OK end |
#peek(peek_size: 0) ⇒ RubySMB::SMB1::Packet::Trans::PeekNmpipeResponse
Performs a peek operation on the named pipe
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_smb/smb1/pipe.rb', line 22 def peek(peek_size: 0) packet = RubySMB::SMB1::Packet::Trans::PeekNmpipeRequest.new packet.fid = @fid packet.parameter_block.max_data_count = peek_size packet = @tree.set_header_fields(packet) raw_response = @tree.client.send_recv(packet) response = RubySMB::SMB1::Packet::Trans::PeekNmpipeResponse.read(raw_response) unless response.valid? raise RubySMB::Error::InvalidPacket.new( expected_proto: RubySMB::SMB1::SMB_PROTOCOL_ID, expected_cmd: RubySMB::SMB1::Packet::Trans::PeekNmpipeRequest::COMMAND, received_proto: response.smb_header.protocol, received_cmd: response.smb_header.command ) end unless response.status_code == WindowsError::NTStatus::STATUS_BUFFER_OVERFLOW or response.status_code == WindowsError::NTStatus::STATUS_SUCCESS raise RubySMB::Error::UnexpectedStatusCode, response.status_code.name end response end |
#peek_available ⇒ Integer
Returns The number of bytes available to be read from the pipe.
46 47 48 49 50 |
# File 'lib/ruby_smb/smb1/pipe.rb', line 46 def peek_available packet = peek # Only 1 of these should be non-zero packet.data_block.trans_parameters.read_data_available or packet.data_block.trans_parameters. end |
#peek_state ⇒ Integer
Returns Pipe status.
53 54 55 56 |
# File 'lib/ruby_smb/smb1/pipe.rb', line 53 def peek_state packet = peek packet.data_block.trans_parameters.pipe_state end |