Encode this SMB message into a series of bytes suitable to be embedded with a NetBIOS session message. AssertionError will be raised if this SMB message has not been initialized with a Payload instance @return: a string containing the encoded SMB message
(self)
| 158 | return bool(self.flags2 & SMB_FLAGS2_EXTENDED_SECURITY) |
| 159 | |
| 160 | def encode(self): |
| 161 | """ |
| 162 | Encode this SMB message into a series of bytes suitable to be embedded with a NetBIOS session message. |
| 163 | AssertionError will be raised if this SMB message has not been initialized with a Payload instance |
| 164 | |
| 165 | @return: a string containing the encoded SMB message |
| 166 | """ |
| 167 | assert self.payload |
| 168 | |
| 169 | self.pid = os.getpid() |
| 170 | self.payload.prepare(self) |
| 171 | |
| 172 | parameters_len = len(self.parameters_data) |
| 173 | assert parameters_len % 2 == 0 |
| 174 | |
| 175 | headers_data = struct.pack(self.HEADER_STRUCT_FORMAT, |
| 176 | b'\xFFSMB', self.command, self.status.internal_value, self.flags, |
| 177 | self.flags2, (self.pid >> 16) & 0xFFFF, self.security, self.tid, |
| 178 | self.pid & 0xFFFF, self.uid, self.mid, int(parameters_len / 2)) |
| 179 | return headers_data + self.parameters_data + struct.pack('<H', len(self.data)) + self.data |
| 180 | |
| 181 | def decode(self, buf): |
| 182 | """ |