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

Method prepare

pager_lib/smb/smb2_structs.py:371–404  ·  view source on GitHub ↗
(self, message)

Source from the content-addressed store, hash-verified

369 message.command = SMB2_COM_CREATE
370
371 def prepare(self, message):
372 buf = self.filename.encode('UTF-16LE')
373 filename_len = len(buf)
374 if self.create_context_data:
375 n = SMB2Message.HEADER_SIZE + self.STRUCTURE_SIZE + len(buf)
376 if n % 8 != 0:
377 buf += b'\0'*(8-n%8)
378 create_context_offset = SMB2Message.HEADER_SIZE + self.STRUCTURE_SIZE + len(buf)
379 else:
380 create_context_offset = n
381 buf += self.create_context_data
382 else:
383 create_context_offset = 0
384 if not buf:
385 buf = b'\0'
386
387 assert create_context_offset % 8 == 0
388 message.data = struct.pack(self.STRUCTURE_FORMAT,
389 57, # Structure size. Must be 57 as mandated by [MS-SMB2] 2.2.13
390 0, # SecurityFlag. Must be 0
391 self.oplock,
392 self.impersonation,
393 0, # SmbCreateFlags. Must be 0
394 0, # Reserved. Must be 0
395 self.access_mask, # DesiredAccess. [MS-SMB2] 2.2.13.1
396 self.file_attributes,
397 self.share_access,
398 self.create_disp,
399 self.create_options,
400 SMB2Message.HEADER_SIZE + self.STRUCTURE_SIZE, # NameOffset
401 filename_len, # Length of encoded filename in bytes
402 create_context_offset, # CreateContextOffset
403 len(self.create_context_data) # CreateContextLength
404 ) + buf
405
406class SMB2CreateResponse(Structure):
407 """

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected