MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / ComTransactionResponse

Class ComTransactionResponse

pager_lib/smb/smb_structs.py:768–819  ·  view source on GitHub ↗

Contains information about a SMB_COM_TRANSACTION response from the server After decoding, each instance contains the following attributes: - total_params_count (integer) - total_data_count (integer) - setup_bytes (string) - data_bytes (string) - params_bytes (string)

Source from the content-addressed store, hash-verified

766
767
768class ComTransactionResponse(Payload):
769 """
770 Contains information about a SMB_COM_TRANSACTION response from the server
771
772 After decoding, each instance contains the following attributes:
773 - total_params_count (integer)
774 - total_data_count (integer)
775 - setup_bytes (string)
776 - data_bytes (string)
777 - params_bytes (string)
778
779 References:
780 ===========
781 - [MS-CIFS]: 2.2.4.33.2
782 """
783
784 PAYLOAD_STRUCT_FORMAT = '<HHHHHHHHHH'
785 PAYLOAD_STRUCT_SIZE = struct.calcsize(PAYLOAD_STRUCT_FORMAT)
786
787 def decode(self, message):
788 assert message.command == SMB_COM_TRANSACTION
789
790 if not message.status.hasError:
791 if len(message.parameters_data) < self.PAYLOAD_STRUCT_SIZE:
792 raise ProtocolError('Not enough data to decode SMB_COM_TRANSACTION parameters', message.raw_data, message)
793
794 self.total_params_count, self.total_data_count, _, \
795 params_bytes_len, params_bytes_offset, params_bytes_displ, \
796 data_bytes_len, data_bytes_offset, data_bytes_displ, \
797 setup_count = struct.unpack(self.PAYLOAD_STRUCT_FORMAT, message.parameters_data[:self.PAYLOAD_STRUCT_SIZE])
798
799 if setup_count > 0:
800 setup_bytes_len = setup_count * 2
801
802 if len(message.parameters_data) < self.PAYLOAD_STRUCT_SIZE + setup_bytes_len:
803 raise ProtocolError('Not enough data to decode SMB_COM_TRANSACTION parameters', message.raw_data, message)
804
805 self.setup_bytes = message.parameters_data[self.PAYLOAD_STRUCT_SIZE:self.PAYLOAD_STRUCT_SIZE+setup_bytes_len]
806 else:
807 self.setup_bytes = ''
808
809 offset = message.HEADER_STRUCT_SIZE + self.PAYLOAD_STRUCT_SIZE + setup_count * 2 + 2 # constant 2 is for the ByteCount field in the SMB header (i.e. field which indicates number of data bytes after the SMB parameters)
810
811 if params_bytes_len > 0:
812 self.params_bytes = message.data[params_bytes_offset-offset:params_bytes_offset-offset+params_bytes_len]
813 else:
814 self.params_bytes = ''
815
816 if data_bytes_len > 0:
817 self.data_bytes = message.data[data_bytes_offset-offset:data_bytes_offset-offset+data_bytes_len]
818 else:
819 self.data_bytes = ''
820
821
822class ComTransaction2Request(Payload):

Callers 1

_decodePayloadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected