References: =========== - [MS-CIFS]: 2.2.4.55.1 - [MS-SMB]: 2.2.4.7.1
| 537 | |
| 538 | |
| 539 | class ComTreeConnectAndxRequest(Payload): |
| 540 | """ |
| 541 | References: |
| 542 | =========== |
| 543 | - [MS-CIFS]: 2.2.4.55.1 |
| 544 | - [MS-SMB]: 2.2.4.7.1 |
| 545 | """ |
| 546 | |
| 547 | PAYLOAD_STRUCT_FORMAT = '<HH' |
| 548 | PAYLOAD_STRUCT_SIZE = struct.calcsize(PAYLOAD_STRUCT_FORMAT) |
| 549 | |
| 550 | def __init__(self, path, service, password = ''): |
| 551 | self.path = path |
| 552 | self.service = service |
| 553 | self.password = password + '\0' |
| 554 | |
| 555 | def initMessage(self, message): |
| 556 | Payload.initMessage(self, message) |
| 557 | message.command = SMB_COM_TREE_CONNECT_ANDX |
| 558 | |
| 559 | def prepare(self, message): |
| 560 | password_len = len(self.password) |
| 561 | message.parameters_data = \ |
| 562 | self.DEFAULT_ANDX_PARAM_HEADER + \ |
| 563 | struct.pack(self.PAYLOAD_STRUCT_FORMAT, |
| 564 | 0x08 | \ |
| 565 | ((message.hasExtendedSecurity and 0x0004) or 0x00) | \ |
| 566 | ((message.tid and message.tid != 0xffff and 0x0001) or 0x00), # Disconnect tid, if message.tid must be non-zero |
| 567 | password_len) |
| 568 | |
| 569 | padding = b'' |
| 570 | if password_len % 2 == 0: |
| 571 | padding = b'\0' |
| 572 | |
| 573 | # Note that service field is never encoded in UTF-16LE. [MS-CIFS]: 2.2.1.1 |
| 574 | message.data = self.password.encode('UTF-8') + padding + self.path.encode('UTF-16LE') + b'\0\0' + self.service.encode('UTF-8') + b'\0' |
| 575 | |
| 576 | |
| 577 | class ComTreeConnectAndxResponse(Payload): |
no outgoing calls
no test coverage detected