(self, message)
| 337 | PAYLOAD_STRUCT_SIZE = struct.calcsize(PAYLOAD_STRUCT_FORMAT) |
| 338 | |
| 339 | def decode(self, message): |
| 340 | assert message.command == SMB_COM_NEGOTIATE |
| 341 | |
| 342 | if not message.isReply: |
| 343 | raise ProtocolError('Not a SMB_COM_NEGOTIATE reply', message.raw_data, message) |
| 344 | |
| 345 | self.security_mode, self.max_mpx_count, self.max_number_vcs, self.max_buffer_size, \ |
| 346 | self.max_raw_size, self.session_key, self.capabilities, self.system_time, self.server_time_zone, \ |
| 347 | self.challenge_length = ( 0, ) * 10 |
| 348 | |
| 349 | data_len = len(message.parameters_data) |
| 350 | if data_len < 2: |
| 351 | raise ProtocolError('Not enough data to decode SMB_COM_NEGOTIATE dialect_index field', message.raw_data, message) |
| 352 | |
| 353 | self.dialect_index = struct.unpack('<H', message.parameters_data[:2])[0] |
| 354 | if self.dialect_index == NT_LAN_MANAGER_DIALECT: |
| 355 | if data_len != (0x11 * 2): |
| 356 | raise ProtocolError('NT LAN Manager dialect selected in SMB_COM_NEGOTIATE but parameters bytes count (%d) does not meet specs' % data_len, |
| 357 | message.raw_data, message) |
| 358 | else: |
| 359 | _, self.security_mode, self.max_mpx_count, self.max_number_vcs, self.max_buffer_size, \ |
| 360 | self.max_raw_size, self.session_key, self.capabilities, self.system_time, self.server_time_zone, \ |
| 361 | self.challenge_length = struct.unpack(self.PAYLOAD_STRUCT_FORMAT, message.parameters_data[:self.PAYLOAD_STRUCT_SIZE]) |
| 362 | elif self.dialect_index == 0xFFFF: |
| 363 | raise ProtocolError('Server does not support any of the pysmb dialects. Please email pysmb to add in support for your OS', |
| 364 | message.raw_data, message) |
| 365 | else: |
| 366 | raise ProtocolError('Unknown dialect index (0x%04X)' % self.dialect_index, message.raw_data, message) |
| 367 | |
| 368 | data_len = len(message.data) |
| 369 | if not message.hasExtendedSecurity: |
| 370 | self.challenge, self.domain = '', '' |
| 371 | if self.challenge_length > 0: |
| 372 | if data_len >= self.challenge_length: |
| 373 | self.challenge = message.data[:self.challenge_length] |
| 374 | |
| 375 | s = b'' |
| 376 | offset = self.challenge_length |
| 377 | while offset < data_len: |
| 378 | _s = message.data[offset:offset+2] |
| 379 | if _s == b'\0\0': |
| 380 | self.domain = DataFaultToleranceStrategy.data_bytes_decode(s)#.decode('UTF-16LE') |
| 381 | break |
| 382 | else: |
| 383 | s += _s |
| 384 | offset += 2 |
| 385 | else: |
| 386 | raise ProtocolError('Not enough data to decode SMB_COM_NEGOTIATE (without security extensions) Challenge field', message.raw_data, message) |
| 387 | else: |
| 388 | if data_len < 16: |
| 389 | raise ProtocolError('Not enough data to decode SMB_COM_NEGOTIATE (with security extensions) ServerGUID field', message.raw_data, message) |
| 390 | |
| 391 | self.server_guid = message.data[:16] |
| 392 | self.security_blob = message.data[16:] |
| 393 | |
| 394 | @property |
| 395 | def supportsExtendedSecurity(self): |
nothing calls this directly
no test coverage detected