grr/client/grr_response_client/vfs_handlers/registry.py
def ListFiles(self, ext_attrs=None):
    """A generator of all keys and values."""
    del ext_attrs  # Unused.

    if not self.IsDirectory():
      return

    if self.hive is None:
      for name in dir(_winreg):
        if name.startswith("HKEY_"):
          response = rdf_client_fs.StatEntry(st_mode=stat.S_IFDIR)
          response_pathspec = self.pathspec.Copy()
          response_pathspec.last.path = utils.JoinPath(
              response_pathspec.last.path, name)
          response.pathspec = response_pathspec

          yield response
      return

    try:
      with OpenKey(self.hive, self.local_path) as key:
        (self.number_of_keys, self.number_of_values,
         self.last_modified) = QueryInfoKey(key)

        # First keys - These will look like directories.
        for i in range(self.number_of_keys):
          try:
            name = EnumKey(key, i)
            key_name = utils.JoinPath(self.local_path, name)

            try:
              # Store the default value in the stat response for values.
              with OpenKey(self.hive, key_name) as subkey:
                value, value_type = QueryValueEx(subkey, "")
            except OSError:
              value, value_type = None, None

            response = self._Stat(name, value, value_type)
            # Keys look like Directories in the VFS.
            response.st_mode = stat.S_IFDIR

            yield response
          except OSError:
            pass

        # Now Values - These will look like files.
        for i in range(self.number_of_values):
          try:
            name, value, value_type = EnumValue(key, i)
            response = self._Stat(name, value, value_type)

            # Values look like files in the VFS.
            response.st_mode = stat.S_IFREG

            yield response

          except OSError:
            pass
    except OSError as e:
      raise IOError("Unable to list key %s: %s" % (self.key_name, e))
A generator of all keys and values.
A generator of all keys and values.
A generator of all keys and values .
def ListFiles(self, ext_attrs=None):
    del ext_attrs  
    if not self.IsDirectory():
      return
    if self.hive is None:
      for name in dir(_winreg):
        if name.startswith("HKEY_"):
          response = rdf_client_fs.StatEntry(st_mode=stat.S_IFDIR)
          response_pathspec = self.pathspec.Copy()
          response_pathspec.last.path = utils.JoinPath(
              response_pathspec.last.path, name)
          response.pathspec = response_pathspec
          yield response
      return
    try:
      with OpenKey(self.hive, self.local_path) as key:
        (self.number_of_keys, self.number_of_values,
         self.last_modified) = QueryInfoKey(key)
        for i in range(self.number_of_keys):
          try:
            name = EnumKey(key, i)
            key_name = utils.JoinPath(self.local_path, name)
            try:
              with OpenKey(self.hive, key_name) as subkey:
                value, value_type = QueryValueEx(subkey, "")
            except OSError:
              value, value_type = None, None
            response = self._Stat(name, value, value_type)
            response.st_mode = stat.S_IFDIR
            yield response
          except OSError:
            pass
        for i in range(self.number_of_values):
          try:
            name, value, value_type = EnumValue(key, i)
            response = self._Stat(name, value, value_type)
            response.st_mode = stat.S_IFREG
            yield response
          except OSError:
            pass
    except OSError as e:
      raise IOError("Unable to list key %s: %s" % (self.key_name, e))
def ListFiles ( self , ext_attrs = None ) : del ext_attrs if not self . IsDirectory ( ) : return if self . hive is None : for name in dir ( _winreg ) : if name . startswith ( "HKEY_" ) : response = rdf_client_fs . StatEntry ( st_mode = stat . S_IFDIR ) response_pathspec = self . pathspec . Copy ( ) response_pathspec . last . path = utils . JoinPath ( response_pathspec . last . path , name ) response . pathspec = response_pathspec yield response return try : with OpenKey ( self . hive , self . local_path ) as key : ( self . number_of_keys , self . number_of_values , self . last_modified ) = QueryInfoKey ( key ) for i in range ( self . number_of_keys ) : try : name = EnumKey ( key , i ) key_name = utils . JoinPath ( self . local_path , name ) try : with OpenKey ( self . hive , key_name ) as subkey : value , value_type = QueryValueEx ( subkey , "" ) except OSError : value , value_type = None , None response = self . _Stat ( name , value , value_type ) response . st_mode = stat . S_IFDIR yield response except OSError : pass for i in range ( self . number_of_values ) : try : name , value , value_type = EnumValue ( key , i ) response = self . _Stat ( name , value , value_type ) response . st_mode = stat . S_IFREG yield response except OSError : pass except OSError as e : raise IOError ( "Unable to list key %s: %s" % ( self . key_name , e ) )
A generator of all keys and values.
A generator of all keys and values .
"""A generator of all keys and values.""" # Unused. # First keys - These will look like directories. # Store the default value in the stat response for values. # Keys look like Directories in the VFS. # Now Values - These will look like files. # Values look like files in the VFS.
self
ext_attrs