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

Method encode

pager_lib/smb/smb2_structs.py:69–84  ·  view source on GitHub ↗

Encode this SMB2 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 SMB2 message

(self)

Source from the content-addressed store, hash-verified

67 self.parameters_data = b''
68
69 def encode(self):
70 """
71 Encode this SMB2 message into a series of bytes suitable to be embedded with a NetBIOS session message.
72 AssertionError will be raised if this SMB message has not been initialized with a Payload instance
73
74 @return: a string containing the encoded SMB2 message
75 """
76 assert self.payload
77
78 self.pid = os.getpid()
79 self.payload.prepare(self)
80
81 headers_data = struct.pack(self.HEADER_STRUCT_FORMAT,
82 b'\xFESMB', self.HEADER_SIZE, 0, self.status, self.command, 0, self.flags) + \
83 struct.pack(self.SYNC_HEADER_STRUCT_FORMAT, self.next_command_offset, self.mid, self.pid, self.tid, self.session_id, self.signature)
84 return headers_data + self.data
85
86 def decode(self, buf):
87 """

Callers 3

prepareMethod · 0.45
prepareMethod · 0.45
prepareMethod · 0.45

Calls 1

prepareMethod · 0.45

Tested by

no test coverage detected