Exemple #1
0
    def __bytes__(self) -> bytes:

        dependencies_ndr = Pointer(
            representation=UnidimensionalConformantArray(
                representation=tuple(
                    bytes([byte])
                    for byte in '\x00'.join(self.dependencies).encode(encoding='utf-16-le')
                )
            )
        ) if len(self.dependencies) != 0 else NullPointer()

        password_ndr = Pointer(
            representation=UnidimensionalConformantArray(
                representation=tuple(
                    bytes([byte])
                    for byte in (self.password + '\x00').encode(encoding='utf-16-le')
                )
            )
        ) if self.password is not None else NullPointer()

        return b''.join([
            self.service_handle,
            struct_pack('<I', self.service_type.value if self.service_type is not None else SERVICE_NO_CHANGE),
            struct_pack('<I', self.start_type.value if self.start_type is not None else SERVICE_NO_CHANGE),
            struct_pack('<I', self.error_control.value if self.error_control is not None else SERVICE_NO_CHANGE),
            ndr_pad(
                data=bytes(
                    Pointer(representation=ConformantVaryingString(representation=self.binary_path_name))
                    if self.binary_path_name is not None else NullPointer()
                )
            ),
            ndr_pad(
                data=bytes(
                    Pointer(representation=ConformantVaryingString(representation=self.load_order_group))
                    if self.load_order_group is not None else NullPointer()
                )
            ),
            struct_pack('<I', self.tag_id),
            ndr_pad(data=bytes(dependencies_ndr)),
            struct_pack(
                '<I',
                (0 if isinstance(dependencies_ndr, NullPointer) else len(dependencies_ndr.representation) - UnidimensionalConformantArray.STRUCTURE_SIZE)
            ),
            ndr_pad(
                data=bytes(
                    Pointer(representation=ConformantVaryingString(representation=self.service_start_name))
                    if self.service_start_name is not None else NullPointer()
                )
            ),
            ndr_pad(data=bytes(password_ndr)),
            struct_pack(
                '<I',
                (0 if isinstance(password_ndr, NullPointer) else len(password_ndr.representation) - UnidimensionalConformantArray.STRUCTURE_SIZE)
            ),
            bytes(
                Pointer(representation=ConformantVaryingString(representation=self.display_name))
                if self.display_name is not None else NullPointer()
            )
        ])
    def __bytes__(self) -> bytes:

        service_name_bytes = bytes(ConformantVaryingString(representation=self.service_name))

        return b''.join([
            self.sc_manager_handle,
            ndr_pad(service_name_bytes),
            struct_pack('<I', int(self.desired_access))
        ])
Exemple #3
0
    def __bytes__(self) -> bytes:

        machine_name_bytes = bytes(
            Pointer(representation=ConformantVaryingString(representation=self.machine_name or ''))
        )

        database_name_bytes = bytes(
            Pointer(
                representation=ConformantVaryingString(
                    representation=self.database_name.value if self.database_name else ''
                )
            )
        )

        return b''.join([
            ndr_pad(machine_name_bytes),
            ndr_pad(database_name_bytes),
            struct_pack('<I', int(self.desired_access))
        ])
Exemple #4
0
 def __bytes__(self) -> bytes:
     return b''.join([
         self.service_handle,
         struct_pack('<I', self.argc),
         bytes(
             Pointer(representation=b''.join([
                 struct_pack('<I', len(self.argv)), b''.join(
                     struct_pack('<I',
                                 Pointer(representation=b'').referent_id)
                     for _ in self.argv), b''.join(
                         ndr_pad(data=bytes(
                             ConformantVaryingString(
                                 representation=argument_string)))
                         for argument_string in self.argv)
             ])) if self.argv else NullPointer())
     ])