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

Class ComNTTransactRequest

pager_lib/smb/smb_structs.py:1314–1383  ·  view source on GitHub ↗

References: =========== - [MS-CIFS]: 2.2.4.62.1

Source from the content-addressed store, hash-verified

1312
1313
1314class ComNTTransactRequest(Payload):
1315 """
1316 References:
1317 ===========
1318 - [MS-CIFS]: 2.2.4.62.1
1319 """
1320 PAYLOAD_STRUCT_FORMAT = '<BHIIIIIIIIBH'
1321 PAYLOAD_STRUCT_SIZE = struct.calcsize(PAYLOAD_STRUCT_FORMAT)
1322
1323 def __init__(self, function, max_params_count, max_data_count, max_setup_count,
1324 total_params_count = 0, total_data_count = 0,
1325 params_bytes = b'', setup_bytes = b'', data_bytes = b''):
1326 self.function = function
1327 self.total_params_count = total_params_count or len(params_bytes)
1328 self.total_data_count = total_data_count or len(data_bytes)
1329 self.max_params_count = max_params_count
1330 self.max_data_count = max_data_count
1331 self.max_setup_count = max_setup_count
1332 self.params_bytes = params_bytes
1333 self.setup_bytes = setup_bytes
1334 self.data_bytes = data_bytes
1335
1336 def initMessage(self, message):
1337 Payload.initMessage(self, message)
1338 message.command = SMB_COM_NT_TRANSACT
1339
1340 def prepare(self, message):
1341 setup_bytes_len = len(self.setup_bytes)
1342 params_bytes_len = len(self.params_bytes)
1343 data_bytes_len = len(self.data_bytes)
1344
1345 padding0 = b''
1346 offset = message.HEADER_STRUCT_SIZE + self.PAYLOAD_STRUCT_SIZE + setup_bytes_len + 2 # constant 2 is for the ByteCount field in the SMB header (i.e. field which indicates number of data bytes after the SMB parameters)
1347 if offset % 4 != 0:
1348 padding0 = b'\0'*(4-offset%4)
1349 offset += (4-offset%4)
1350
1351 if params_bytes_len > 0:
1352 params_bytes_offset = offset
1353 else:
1354 params_bytes_offset = 0
1355
1356 offset += params_bytes_len
1357 padding1 = b''
1358 if offset % 4 != 0:
1359 padding1 = b'\0'*(4-offset%4)
1360 offset += (4-offset%4)
1361
1362 if data_bytes_len > 0:
1363 data_bytes_offset = offset
1364 else:
1365 data_bytes_offset = 0
1366
1367 message.parameters_data = \
1368 struct.pack(self.PAYLOAD_STRUCT_FORMAT,
1369 self.max_setup_count,
1370 0x00, # Reserved1. Must be 0x00
1371 self.total_params_count,

Callers 1

sendEnumSnapshotsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected