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

Class ComTransaction2Response

pager_lib/smb/smb_structs.py:904–955  ·  view source on GitHub ↗

Contains information about a SMB_COM_TRANSACTION2 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

902
903
904class ComTransaction2Response(Payload):
905 """
906 Contains information about a SMB_COM_TRANSACTION2 response from the server
907
908 After decoding, each instance contains the following attributes:
909 - total_params_count (integer)
910 - total_data_count (integer)
911 - setup_bytes (string)
912 - data_bytes (string)
913 - params_bytes (string)
914
915 References:
916 ===========
917 - [MS-CIFS]: 2.2.4.46.2
918 """
919
920 PAYLOAD_STRUCT_FORMAT = '<HHHHHHHHHBB'
921 PAYLOAD_STRUCT_SIZE = struct.calcsize(PAYLOAD_STRUCT_FORMAT)
922
923 def decode(self, message):
924 assert message.command == SMB_COM_TRANSACTION2
925
926 if not message.status.hasError:
927 if len(message.parameters_data) < self.PAYLOAD_STRUCT_SIZE:
928 raise ProtocolError('Not enough data to decode SMB_COM_TRANSACTION2 parameters', message.raw_data, message)
929
930 self.total_params_count, self.total_data_count, _, \
931 params_bytes_len, params_bytes_offset, params_bytes_displ, \
932 data_bytes_len, data_bytes_offset, data_bytes_displ, \
933 setup_count, _ = struct.unpack(self.PAYLOAD_STRUCT_FORMAT, message.parameters_data[:self.PAYLOAD_STRUCT_SIZE])
934
935 if setup_count > 0:
936 setup_bytes_len = setup_count * 2
937
938 if len(message.parameters_data) < self.PAYLOAD_STRUCT_SIZE + setup_bytes_len:
939 raise ProtocolError('Not enough data to decode SMB_COM_TRANSACTION parameters', message.raw_data, message)
940
941 self.setup_bytes = message.parameters_data[self.PAYLOAD_STRUCT_SIZE:self.PAYLOAD_STRUCT_SIZE+setup_bytes_len]
942 else:
943 self.setup_bytes = ''
944
945 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)
946
947 if params_bytes_len > 0:
948 self.params_bytes = message.data[params_bytes_offset-offset:params_bytes_offset-offset+params_bytes_len]
949 else:
950 self.params_bytes = ''
951
952 if data_bytes_len > 0:
953 self.data_bytes = message.data[data_bytes_offset-offset:data_bytes_offset-offset+data_bytes_len]
954 else:
955 self.data_bytes = ''
956
957
958class ComCloseRequest(Payload):

Callers 1

_decodePayloadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected