Changeset 253 for trunk/python


Ignore:
Timestamp:
06/12/11 22:27:42 (13 years ago)
Author:
tim
Message:

added preliminary interface to security descriptors in pyregfi
misc bug fixes

Location:
trunk/python/pyregfi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/pyregfi/__init__.py

    r252 r253  
    295295
    296296
    297 ## Registry security record and descriptor
    298 # XXX: Access to security descriptors not yet implemented
     297
     298## Represents a registry SK record which contains a security descriptor
     299#
    299300class Security(_StructureWrapper):
    300     pass
     301    ## Number of keys referencing this SK record
     302    ref_count = 1
     303
     304    ## The absolute file offset of the SK record's cell in the Hive file
     305    offset = 0xCAFEBABE
     306
     307    ## The @ref SecurityDescriptor for this SK record
     308    descriptor = object()
     309
     310    def __init__(self, hive, base):
     311        super(Security, self).__init__(hive, base)
     312        # XXX: add checks for NULL pointers
     313        self.descriptor = winsec.SecurityDescriptor(base.contents.sec_desc.contents)
     314
     315    ## Loads the "previous" Security record in the hive
     316    #
     317    # @note
     318    # SK records are included in a circular, doubly-linked list.
     319    # To iterate over all SK records, be sure to check for the repetition of
     320    # the SK record you started with to determine when all have been traversed.
     321    def next_security(self):
     322        return Security(self._hive,
     323                        regfi.regfi_next_sk(self._hive.file, self._base))
     324
     325    ## Loads the "previous" Security record in the hive
     326    #
     327    # @note
     328    # SK records are included in a circular, doubly-linked list.
     329    # To iterate over all SK records, be sure to check for the repetition of
     330    # the SK record you started with to determine when all have been traversed.
     331    def prev_security(self):
     332        return Security(self._hive,
     333                        regfi.regfi_prev_sk(self._hive.file, self._base))
     334
    301335
    302336## Abstract class for ValueList and SubkeyList
     
    10381072del Key.name,Key.name_raw,Key.offset,Key.modified,Key.flags
    10391073del Hive.root,Hive.modified,Hive.sequence1,Hive.sequence2,Hive.major_version,Hive.minor_version
     1074del Security.ref_count,Security.offset,Security.descriptor
  • trunk/python/pyregfi/structures.py

    r252 r253  
    2121REGFI_DATA_TYPE = c_uint32
    2222REGFI_NTTIME = c_uint64
     23
     24REGFI_REGF_SIZE = 0x1000
    2325
    2426# Prototype everything first so we don't have to worry about reference order
     
    9496read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t, use_errno=True)
    9597
     98
     99from winsec import *
    96100
    97101REGFI_VK._fields_ = [('offset', c_uint32),
     
    113117REGFI_SK._fields_ = [('offset', c_uint32),
    114118                     ('cell_size', c_uint32),
    115                      ('sec_desc', c_void_p), #XXX
     119                     ('sec_desc', POINTER(WINSEC_DESC)),
    116120                     ('hbin_off', c_uint32),
    117121                     ('prev_sk_off', c_uint32),
     
    261265regfi.regfi_fetch_sk.restype = POINTER(REGFI_SK)
    262266
     267regfi.regfi_next_sk.argtypes = [POINTER(REGFI_FILE), POINTER(REGFI_SK)]
     268regfi.regfi_next_sk.restype = POINTER(REGFI_SK)
     269
     270regfi.regfi_prev_sk.argtypes = [POINTER(REGFI_FILE), POINTER(REGFI_SK)]
     271regfi.regfi_prev_sk.restype = POINTER(REGFI_SK)
     272
    263273regfi.regfi_fetch_data.argtypes = [POINTER(REGFI_FILE), POINTER(REGFI_VK)]
    264274regfi.regfi_fetch_data.restype = POINTER(REGFI_DATA)
     
    283293regfi.regfi_get_parentkey.restype = POINTER(REGFI_NK)
    284294
    285 regfi.regfi_nt2unix_time.argtypes = [POINTER(REGFI_NTTIME)]
     295regfi.regfi_nt2unix_time.argtypes = [REGFI_NTTIME]
    286296regfi.regfi_nt2unix_time.restype = c_double
    287297
Note: See TracChangeset for help on using the changeset viewer.