MCPcopy Create free account
hub / github.com/RedTeamPentesting/wspcoerce / CPMCreateQueryIn

Class CPMCreateQueryIn

wspcoerce/packets.py:397–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395# Only the necessary strcuts are included for coercion
396@dataclass
397class CPMCreateQueryIn:
398 target_uri: str
399
400 def to_bytes(self) -> bytes:
401 header = WspMessageHeader(_msg=WspMessageType.CPMCREATEQUERY)
402 body = self._get_body_bytes()
403
404 header._ulChecksum = CalculateChecksum(body, WspMessageType.CPMCREATEQUERY)
405
406 return header.to_bytes() + body
407
408 def _get_body_bytes(self) -> bytes:
409 temp_buffer = bytearray()
410
411 # length, will be updated later
412 temp_buffer.extend(struct.pack("<I", 0))
413
414 temp_buffer.append(0x01) # CColumnSetPresent
415 AlignWrite(temp_buffer, 4)
416 CColumnSet().to_bytes(temp_buffer)
417
418 temp_buffer.append(0x01) # CRestrictionPresent
419 restriction_array = CRestrictionArray(
420 restrictions=[
421 CRestriction(
422 ulType=RTPROPERTY,
423 Weight=1000,
424 Restriction=CPropertyRestriction(
425 relop=PREQ,
426 Property=PropSpec(
427 guid=uuid.UUID("b725f130-47ef-101a-a5f1-02608c9eebac"),
428 ulKind=PRSPEC_PROPID,
429 propid=0x16,
430 ),
431 prval=self.target_uri,
432 ),
433 )
434 ]
435 )
436
437 restriction_array.to_bytes(temp_buffer)
438
439 temp_buffer.append(0x00) # CSortSetPresent (not used)
440 temp_buffer.append(0x00) # CCategorizationSetPresent (not used)
441
442 AlignWrite(temp_buffer, 4)
443
444 rowset_props = CRowsetProperties(
445 uBooleanOptions=0x00000001,
446 ulMaxOpenRows=0,
447 ulMemUsage=0,
448 cMaxResults=10,
449 cCmdTimeout=30,
450 )
451 rowset_props.to_bytes(temp_buffer)
452
453 pid_mapper = CPidMapper(
454 PropSpecs=[PropSpec(guid=NULL_UUID, ulKind=PRSPEC_PROPID, propid=0x16)]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected