docstring
stringlengths
52
499
function
stringlengths
67
35.2k
__index_level_0__
int64
52.6k
1.16M
Scans an encrypted volume node for supported formats. Args: scan_context (SourceScannerContext): source scanner context. scan_node (SourceScanNode): source scan node. Raises: BackEndError: if the scan node cannot be unlocked. ValueError: if the scan context or scan node is invalid.
def _ScanEncryptedVolumeNode(self, scan_context, scan_node): if scan_node.type_indicator == definitions.TYPE_INDICATOR_APFS_CONTAINER: # TODO: consider changes this when upstream changes have been made. # Currently pyfsapfs does not support reading from a volume as a device. # Also see: https...
391,474
Scans a volume system root node for supported formats. Args: scan_context (SourceScannerContext): source scanner context. scan_node (SourceScanNode): source scan node. auto_recurse (Optional[bool]): True if the scan should automatically recurse as far as possible. Raises: Val...
def _ScanVolumeSystemRootNode( self, scan_context, scan_node, auto_recurse=True): if scan_node.type_indicator == definitions.TYPE_INDICATOR_VSHADOW: # For VSS add a scan node for the current volume. path_spec = self.ScanForFileSystem(scan_node.path_spec.parent) if path_spec: sca...
391,475
Retrieves the volume identifiers. Args: volume_system (VolumeSystem): volume system. Returns: list[str]: sorted volume identifiers.
def GetVolumeIdentifiers(self, volume_system): volume_identifiers = [] for volume in volume_system.volumes: volume_identifier = getattr(volume, 'identifier', None) if volume_identifier: volume_identifiers.append(volume_identifier) return sorted(volume_identifiers)
391,476
Scans for supported formats. Args: scan_context (SourceScannerContext): source scanner context. auto_recurse (Optional[bool]): True if the scan should automatically recurse as far as possible. scan_path_spec (Optional[PathSpec]): path specification to indicate where the source...
def Scan(self, scan_context, auto_recurse=True, scan_path_spec=None): if not scan_context: raise ValueError('Invalid scan context.') scan_context.updated = False if scan_path_spec: scan_node = scan_context.GetScanNode(scan_path_spec) else: scan_node = scan_context.GetUnscannedS...
391,477
Scans the path specification for a supported file system format. Args: source_path_spec (PathSpec): source path specification. Returns: PathSpec: file system path specification or None if no supported file system type was found. Raises: BackEndError: if the source cannot be sc...
def ScanForFileSystem(self, source_path_spec): if source_path_spec.type_indicator == ( definitions.TYPE_INDICATOR_APFS_CONTAINER): # TODO: consider changes this when upstream changes have been made. # Currently pyfsapfs does not support reading from a volume as a device. # Also see: h...
391,478
Scans the path specification for a supported storage media image format. Args: source_path_spec (PathSpec): source path specification. Returns: PathSpec: storage media image path specification or None if no supported storage media image type was found. Raises: BackEndError: if...
def ScanForStorageMediaImage(self, source_path_spec): try: type_indicators = analyzer.Analyzer.GetStorageMediaImageTypeIndicators( source_path_spec, resolver_context=self._resolver_context) except RuntimeError as exception: raise errors.BackEndError(( 'Unable to process sour...
391,479
Scans the path specification for a supported volume system format. Args: source_path_spec (PathSpec): source path specification. Returns: PathSpec: volume system path specification or None if no supported volume system type was found. Raises: BackEndError: if the source cannot...
def ScanForVolumeSystem(self, source_path_spec): if source_path_spec.type_indicator == definitions.TYPE_INDICATOR_VSHADOW: # It is technically possible to scan for VSS-in-VSS but makes no sense # to do so. return None if source_path_spec.IsVolumeSystemRoot(): return source_path_spe...
391,480
Initializes a file-like object. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(NTFSFile, self).__init__(resolver_context) self._file_system = None self._fsntfs_data_stream = None self._fsntfs_file_entry = None
391,482
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSError: if the ...
def _Open(self, path_spec=None, mode='rb'): if not path_spec: raise ValueError('Missing path specification.') data_stream = getattr(path_spec, 'data_stream', None) self._file_system = resolver.Resolver.OpenFileSystem( path_spec, resolver_context=self._resolver_context) file_entry =...
391,484
Reads a byte string from the file-like object at the current offset. The function will read a byte string of the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: ...
def read(self, size=None): if not self._is_open: raise IOError('Not opened.') if self._fsntfs_data_stream: return self._fsntfs_data_stream.read(size=size) return self._fsntfs_file_entry.read(size=size)
391,485
Seeks to an offset within the file-like object. Args: offset (int): offset to seek to. whence (Optional(int)): value that indicates whether offset is an absolute or relative position within the file. Raises: IOError: if the seek failed. OSError: if the seek failed.
def seek(self, offset, whence=os.SEEK_SET): if not self._is_open: raise IOError('Not opened.') if self._fsntfs_data_stream: self._fsntfs_data_stream.seek(offset, whence) else: self._fsntfs_file_entry.seek(offset, whence)
391,486
Initializes a file entry. Args: resolver_context (Context): resolver context. file_system (FileSystem): file system. path_spec (PathSpec): path specification. is_root (Optional[bool]): True if the file entry is the root file entry of the corresponding file system. is_virtual...
def __init__( self, resolver_context, file_system, path_spec, is_root=False, is_virtual=False): gzip_file = resolver.Resolver.OpenFileObject( path_spec, resolver_context=resolver_context) if not gzip_file: raise errors.BackEndError('Missing gzip file.') super(GzipFileEntry, s...
391,489
Initializes a command line interface tabular table view. Args: column_names (Optional[list[str]]): column names. column_sizes (Optional[list[int]]): minimum column sizes, in number of characters. If a column name or row value is larger than the minimum column size the column will be...
def __init__(self, column_names=None, column_sizes=None): super(CLITabularTableView, self).__init__() self._columns = column_names or [] self._column_sizes = column_sizes or [] self._number_of_columns = len(self._columns) self._rows = []
391,494
Writes a row of values aligned with the width to the output writer. Args: output_writer (CLIOutputWriter): output writer. values (list[object]): values. in_bold (Optional[bool]): True if the row should be written in bold.
def _WriteRow(self, output_writer, values, in_bold=False): row_strings = [] for value_index, value_string in enumerate(values): padding_size = self._column_sizes[value_index] - len(value_string) padding_string = ' ' * padding_size row_strings.extend([value_string, padding_string]) r...
391,495
Writes the table to output writer. Args: output_writer (CLIOutputWriter): output writer.
def Write(self, output_writer): # Round up the column sizes to the nearest tab. for column_index, column_size in enumerate(self._column_sizes): column_size, _ = divmod(column_size, self._NUMBER_OF_SPACES_IN_TAB) column_size = (column_size + 1) * self._NUMBER_OF_SPACES_IN_TAB self._column_...
391,496
Initializes a volume scanner mediator. Args: input_reader (Optional[CLIInputReader]): input reader, where None indicates that the stdin input reader should be used. output_writer (Optional[CLIOutputWriter]): output writer, where None indicates that the stdout output writer should be...
def __init__(self, input_reader=None, output_writer=None): preferred_encoding = locale.getpreferredencoding() if not input_reader: input_reader = StdinInputReader(encoding=preferred_encoding) if not output_writer: output_writer = StdoutOutputWriter(encoding=preferred_encoding) super(C...
391,497
Retrieves VSS store identifiers. This method can be used to prompt the user to provide VSS store identifiers. Args: volume_system (VShadowVolumeSystem): volume system. volume_identifiers (list[str]): volume identifiers including prefix. Returns: list[str]: selected volume identifiers in...
def GetVSSStoreIdentifiers(self, volume_system, volume_identifiers): print_header = True while True: if print_header: self._PrintVSSStoreIdentifiersOverview( volume_system, volume_identifiers) print_header = False self._output_writer.Write('\n') lines = self...
391,498
Unlocks an encrypted volume. This method can be used to prompt the user to provide encrypted volume credentials. Args: source_scanner_object (SourceScanner): source scanner. scan_context (SourceScannerContext): source scanner context. locked_scan_node (SourceScanNode): locked scan node. ...
def UnlockEncryptedVolume( self, source_scanner_object, scan_context, locked_scan_node, credentials): # TODO: print volume description. if locked_scan_node.type_indicator == ( definitions.TYPE_INDICATOR_APFS_CONTAINER): header = 'Found an APFS encrypted volume.' elif locked_scan_nod...
391,499
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. Returns: pyvde.volume: BDE volume file-like object. Raises: PathSpecError: if the path specification is incorrect.
def _OpenFileObject(self, path_spec): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) file_object = resolver.Resolver.OpenFileObject( path_spec.par...
391,509
Retrieves the decoder object for a specific encoding method. Args: encoding_method (str): encoding method identifier. Returns: Decoder: decoder or None if the encoding method does not exists.
def GetDecoder(cls, encoding_method): encoding_method = encoding_method.lower() decoder = cls._decoders.get(encoding_method, None) if not decoder: return None return decoder()
391,510
Registers a decoder for a specific encoding method. Args: decoder (type): decoder class. Raises: KeyError: if the corresponding decoder is already set.
def RegisterDecoder(cls, decoder): encoding_method = decoder.ENCODING_METHOD.lower() if encoding_method in cls._decoders: raise KeyError( 'Decoder for encoding method: {0:s} already set.'.format( decoder.ENCODING_METHOD)) cls._decoders[encoding_method] = decoder
391,511
Initializes a file entry. Args: resolver_context (Context): resolver context. file_system (FileSystem): file system. path_spec (PathSpec): path specification. is_root (Optional[bool]): True if the file entry is the root file entry of the corresponding file system. is_virtual...
def __init__( self, resolver_context, file_system, path_spec, is_root=False, is_virtual=False, vslvm_logical_volume=None): if not is_virtual and vslvm_logical_volume is None: vslvm_logical_volume = file_system.GetLVMLogicalVolumeByPathSpec( path_spec) if not is_virtual and vslvm...
391,513
Retrieves the TSK volume system part object from the TSK volume object. Args: tsk_volume (pytsk3.Volume_Info): TSK volume information. path_spec (PathSpec): path specification. Returns: tuple: contains: pytsk3.TSK_VS_PART_INFO: TSK volume system part information or None on error. ...
def GetTSKVsPartByPathSpec(tsk_volume, path_spec): location = getattr(path_spec, 'location', None) part_index = getattr(path_spec, 'part_index', None) start_offset = getattr(path_spec, 'start_offset', None) partition_index = None if part_index is None: if location is not None: if location.starts...
391,517
Retrieves the number of bytes per sector from a TSK volume object. Args: tsk_volume (pytsk3.Volume_Info): TSK volume information. Returns: int: number of bytes per sector or 512 by default.
def TSKVolumeGetBytesPerSector(tsk_volume): # Note that because pytsk3.Volume_Info does not explicitly defines info # we need to check if the attribute exists and has a value other # than None. Default to 512 otherwise. if hasattr(tsk_volume, 'info') and tsk_volume.info is not None: block_size = getattr(...
391,518
Initializes a directory. Args: file_system (SQLiteBlobFileSystem): file system. path_spec (SQLiteBlobPathSpec): path specification.
def __init__(self, file_system, path_spec): super(SQLiteBlobDirectory, self).__init__(file_system, path_spec) self._number_of_entries = None
391,519
Initializes a file entry. Args: resolver_context (Context): resolver context. file_system (FileSystem): file system. path_spec (PathSpec): path specification. is_root (Optional[bool]): True if the file entry is the root file entry of the corresponding file system. is_virtual...
def __init__( self, resolver_context, file_system, path_spec, is_root=False, is_virtual=False): super(SQLiteBlobFileEntry, self).__init__( resolver_context, file_system, path_spec, is_root=is_root, is_virtual=is_virtual) self._number_of_entries = None if is_virtual: s...
391,521
Initializes a file-like object. Args: resolver_context (Context): resolver context. file_object (Optional[FileIO]): file-like object.
def __init__(self, resolver_context, file_object=None): super(VHDIFile, self).__init__(resolver_context, file_object=file_object) self._parent_vhdi_files = [] self._sub_file_objects = []
391,527
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. Returns: pyvhdi.file: a file-like object. Raises: PathSpecError: if the path specification is incorrect.
def _OpenFileObject(self, path_spec): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') file_object = resolver.Resolver.OpenFileObject( path_spec.parent, resolver_context=self._resolver_context) vhdi_file = pyvhdi.file(...
391,529
Opens the parent file. Args: file_system (FileSystem): file system of the VHDI file. path_spec (PathSpec): path specification of the VHDI file. vhdi_file (pyvhdi.file): VHDI file. Raises: PathSpecError: if the path specification is incorrect.
def _OpenParentFile(self, file_system, path_spec, vhdi_file): location = getattr(path_spec, 'location', None) if not location: raise errors.PathSpecError( 'Unsupported path specification without location.') location_path_segments = file_system.SplitPath(location) parent_filename =...
391,530
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: GzipFileEntry: a file entry or None if not available.
def GetFileEntryByPathSpec(self, path_spec): return gzip_file_entry.GzipFileEntry( self._resolver_context, self, path_spec, is_root=True, is_virtual=True)
391,531
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. Returns: FileIO: a file-like object. Raises: PathSpecError: if the path specification is incorrect.
def _OpenFileObject(self, path_spec): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) file_object = resolver.Resolver.OpenFileObject( path_spec.par...
391,535
Deregisters a decrypter for a specific encryption method. Args: decrypter (type): decrypter class. Raises: KeyError: if the corresponding decrypter is not set.
def DeregisterDecrypter(cls, decrypter): encryption_method = decrypter.ENCRYPTION_METHOD.lower() if encryption_method not in cls._decrypters: raise KeyError( 'Decrypter for encryption method: {0:s} not set.'.format( decrypter.ENCRYPTION_METHOD)) del cls._decrypters[encryp...
391,536
Retrieves the decrypter object for a specific encryption method. Args: encryption_method (str): encryption method identifier. kwargs (dict): keyword arguments depending on the decrypter. Returns: Decrypter: decrypter or None if the encryption method does not exists. Raises: Creden...
def GetDecrypter(cls, encryption_method, **kwargs): encryption_method = encryption_method.lower() decrypter = cls._decrypters.get(encryption_method, None) if not decrypter: return None return decrypter(**kwargs)
391,537
Initializes a file system. Args: resolver_context (Context): resolver context. encoding (Optional[str]): file entry name encoding.
def __init__(self, resolver_context, encoding='utf-8'): super(TARFileSystem, self).__init__(resolver_context) self._file_object = None self._tar_file = None self.encoding = encoding
391,544
Opens the file system defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. The default is 'rb' which represents read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if the ...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') file_object = resolver.Resolver.OpenFileObject( path_spec.parent, resolver_context=self._resolver_context) try: # Set the fi...
391,546
Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): path specification. Returns: bool: True if the file entry exists.
def FileEntryExistsByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if (location is None or not location.startswith(self.LOCATION_ROOT)): return False if len(location) == 1: return True try: self._tar_file.getmember(location[1:]) return...
391,547
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: TARFileEntry: file entry or None.
def GetFileEntryByPathSpec(self, path_spec): if not self.FileEntryExistsByPathSpec(path_spec): return None location = getattr(path_spec, 'location', None) if len(location) == 1: return tar_file_entry.TARFileEntry( self._resolver_context, self, path_spec, is_root=True, ...
391,548
Retrieves the TAR info for a path specification. Args: path_spec (PathSpec): a path specification. Returns: tarfile.TARInfo: TAR info or None if it does not exist. Raises: PathSpecError: if the path specification is incorrect.
def GetTARInfoByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if location is None: raise errors.PathSpecError('Path specification missing location.') if not location.startswith(self.LOCATION_ROOT): raise errors.PathSpecError('Invalid location in path specificat...
391,550
Initializes a decrypter. Args: cipher_mode (Optional[str]): cipher mode. initialization_vector (Optional[bytes]): initialization vector. key (Optional[bytes]): key. kwargs (dict): keyword arguments depending on the decrypter. Raises: ValueError: when key is not set, block cipher ...
def __init__( self, cipher_mode=None, initialization_vector=None, key=None, **kwargs): if not key: raise ValueError('Missing key.') cipher_mode = self.ENCRYPTION_MODES.get(cipher_mode, None) if cipher_mode is None: raise ValueError('Unsupported cipher mode: {0!s}'.format(cipher_mode)...
391,551
Decrypts the encrypted data. Args: encrypted_data (bytes): encrypted data. Returns: tuple[bytes,bytes]: decrypted data and remaining encrypted data.
def Decrypt(self, encrypted_data): index_split = -(len(encrypted_data) % Blowfish.block_size) if index_split: remaining_encrypted_data = encrypted_data[index_split:] encrypted_data = encrypted_data[:index_split] else: remaining_encrypted_data = b'' decrypted_data = self._blowfish...
391,552
Initializes the text file. Args: file_object (FileIO): a file-like object to read from. encoding (Optional[str]): text encoding. end_of_line (Optional[str]): end of line indicator.
def __init__(self, file_object, encoding='utf-8', end_of_line='\n'): super(TextFile, self).__init__() self._file_object = file_object self._file_object_size = file_object.get_size() self._encoding = encoding self._end_of_line = end_of_line.encode(self._encoding) self._end_of_line_length = l...
391,553
Initializes a CPIO archive file system. Args: resolver_context (Context): resolver context. encoding (Optional[str]): file entry name encoding.
def __init__(self, resolver_context, encoding='utf-8'): super(CPIOFileSystem, self).__init__(resolver_context) self._cpio_archive_file = None self._file_object = None self.encoding = encoding
391,555
Opens the file system defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. The default is 'rb' which represents read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if the ...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') file_object = resolver.Resolver.OpenFileObject( path_spec.parent, resolver_context=self._resolver_context) cpio_archive_file = cpi...
391,557
Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): a path specification. Returns: bool: True if the file entry exists.
def FileEntryExistsByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if location is None or not location.startswith(self.LOCATION_ROOT): return False if len(location) == 1: return True return self._cpio_archive_file.FileEntryExistsByPath(location[1:])
391,558
Retrieves the CPIO archive file entry for a path specification. Args: path_spec (PathSpec): a path specification. Returns: CPIOArchiveFileEntry: CPIO archive file entry or None if not available. Raises: PathSpecError: if the path specification is incorrect.
def GetCPIOArchiveFileEntryByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if location is None: raise errors.PathSpecError('Path specification missing location.') if not location.startswith(self.LOCATION_ROOT): raise errors.PathSpecError('Invalid location in pa...
391,559
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): a path specification. Returns: CPIOFileEntry: a file entry or None if not available.
def GetFileEntryByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if (location is None or not location.startswith(self.LOCATION_ROOT)): return None if len(location) == 1: return cpio_file_entry.CPIOFileEntry( self._resolver_context, self, path_...
391,560
Strips the prefix from a path. Args: path (str): Windows path to strip the prefix from. Returns: str: path without the prefix or None if the path is not supported.
def _PathStripPrefix(self, path): if path.startswith('\\\\.\\') or path.startswith('\\\\?\\'): if len(path) < 7 or path[5] != ':' or path[6] != self._PATH_SEPARATOR: # Cannot handle a non-volume path. return None path = path[7:] elif path.startswith('\\\\'): # Cannot han...
391,563
Resolves a Windows path in file system specific format. Args: path (str): Windows path to resolve. expand_variables (Optional[bool]): True if path variables should be expanded or not. Returns: PathSpec: path specification in file system specific format.
def ResolvePath(self, path, expand_variables=True): location, path_spec = self._ResolvePath( path, expand_variables=expand_variables) if not location or not path_spec: return None # Note that we don't want to set the keyword arguments when not used because # the path specification b...
391,565
Sets an environment variable in the Windows path helper. Args: name (str): name of the environment variable without enclosing %-characters, e.g. SystemRoot as in %SystemRoot%. value (str): value of the environment variable.
def SetEnvironmentVariable(self, name, value): if isinstance(value, py2to3.STRING_TYPES): value = self._PathStripPrefix(value) if value is not None: self._environment_variables[name.upper()] = value
391,566
Initializes a specification. Args: identifier (str): unique name for the format.
def __init__(self, identifier): super(FormatSpecification, self).__init__() self.identifier = identifier self.signatures = []
391,567
Retrieves the volume index from the path specification. Args: path_spec (PathSpec): path specification. Returns: int: volume index or None if the index cannot be determined.
def APFSContainerPathSpecGetVolumeIndex(path_spec): volume_index = getattr(path_spec, 'volume_index', None) if volume_index is not None: return volume_index location = getattr(path_spec, 'location', None) if location is None or not location.startswith('/apfs'): return None try: volume_index =...
391,568
Unlocks an APFS volume using the path specification. Args: fsapfs_volume (pyapfs.volume): APFS volume. path_spec (PathSpec): path specification. key_chain (KeyChain): key chain. Returns: bool: True if the volume is unlocked, False otherwise.
def APFSUnlockVolume(fsapfs_volume, path_spec, key_chain): is_locked = fsapfs_volume.is_locked() if is_locked: password = key_chain.GetCredential(path_spec, 'password') if password: fsapfs_volume.set_password(password) recovery_password = key_chain.GetCredential(path_spec, 'recovery_password')...
391,569
Initializes the file-like object. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(SQLiteBlobFile, self).__init__(resolver_context) self._blob = None self._current_offset = 0 self._database_object = None self._number_of_rows = None self._size = 0 self._table_name = None
391,570
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSError: if the ...
def _Open(self, path_spec=None, mode='rb'): if not path_spec: raise ValueError('Missing path specification.') if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') table_name = getattr(path_spec, 'table_name', None) if ta...
391,572
Reads a byte string from the file-like object at the current offset. The function will read a byte string of the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: ...
def read(self, size=None): if not self._database_object: raise IOError('Not opened.') if self._current_offset < 0: raise IOError('Invalid offset value out of bounds.') if size == 0 or self._current_offset >= self._size: return b'' if size is None: size = self._size if...
391,574
Seeks to an offset within the file-like object. Args: offset (int): offset to seek to. whence (Optional(int)): value that indicates whether offset is an absolute or relative position within the file. Raises: IOError: if the seek failed. OSError: if the seek failed.
def seek(self, offset, whence=os.SEEK_SET): if not self._database_object: raise IOError('Not opened.') if whence == os.SEEK_CUR: offset += self._current_offset elif whence == os.SEEK_END: offset += self._size elif whence != os.SEEK_SET: raise IOError('Unsupported whence.') ...
391,575
Initializes a path specification. Note that the BDE path specification must have a parent. Args: password (Optional[str]): password. parent (Optional[PathSpec]): parent path specification. recovery_password (Optional[str]): recovery password. startup_key (Optional[str]): name of the st...
def __init__( self, password=None, parent=None, recovery_password=None, startup_key=None, **kwargs): if not parent: raise ValueError('Missing parent value.') super(BDEPathSpec, self).__init__(parent=parent, **kwargs) self.password = password self.recovery_password = recovery_pass...
391,576
Initializes a file-like object. Args: resolver_context (Context): resolver context. file_data (bytes): fake file data.
def __init__(self, resolver_context, file_data): super(FakeFile, self).__init__(resolver_context) self._current_offset = 0 self._file_data = file_data self._size = 0
391,577
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSError: if the ...
def _Open(self, path_spec=None, mode='rb'): if not path_spec: raise ValueError('Missing path specification.') if path_spec.HasParent(): raise errors.PathSpecError('Unsupported path specification with parent.') location = getattr(path_spec, 'location', None) if location is None: ...
391,578
Reads a byte string from the file-like object at the current offset. The function will read a byte string of the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: ...
def read(self, size=None): if not self._is_open: raise IOError('Not opened.') if self._current_offset < 0: raise IOError( 'Invalid current offset: {0:d} value less than zero.'.format( self._current_offset)) if self._file_data is None or self._current_offset >= self...
391,579
Initializes a file entry. Args: resolver_context (Context): resolver context. file_system (FileSystem): file system. path_spec (PathSpec): path specification. is_root (Optional[bool]): True if the file entry is the root file entry of the corresponding file system. is_virtual...
def __init__( self, resolver_context, file_system, path_spec, is_root=False, is_virtual=False): encrypted_stream = resolver.Resolver.OpenFileObject( path_spec, resolver_context=resolver_context) if not encrypted_stream: raise errors.BackEndError( 'Unable to open encrypte...
391,580
Initializes an APFS volume. Args: file_entry (APFSContainerFileEntry): an APFS container file entry.
def __init__(self, file_entry): super(APFSVolume, self).__init__(file_entry.name) self._file_entry = file_entry
391,582
Opens the file-like object defined by path specification. Args: path_spec (PathSpec): path specification. Returns: pyvmdk.handle: a file-like object. Raises: IOError: if the file-like object could not be opened. OSError: if the file-like object could not be opened. PathSpecE...
def _OpenFileObject(self, path_spec): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') parent_path_spec = path_spec.parent parent_location = getattr(parent_path_spec, 'location', None) if not parent_location: raise e...
391,585
Initializes an encoded file system. Args: resolver_context (Context): a resolver context.
def __init__(self, resolver_context): super(EncodedStreamFileSystem, self).__init__(resolver_context) self._encoding_method = None
391,586
Opens the file system defined by path specification. Args: path_spec (PathSpec): a path specification. mode (Optional[str]): file access mode. The default is 'rb' which represents read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if th...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') encoding_method = getattr(path_spec, 'encoding_method', None) if not encoding_method: raise errors.PathSpecError( 'Unsuppor...
391,587
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): a path specification. Returns: EncodedStreamFileEntry: a file entry or None if not available.
def GetFileEntryByPathSpec(self, path_spec): return encoded_stream_file_entry.EncodedStreamFileEntry( self._resolver_context, self, path_spec, is_root=True, is_virtual=True)
391,588
Initializes a path specification. Note that the mount path specification cannot have a parent. Args: identifier (str): identifier of the mount point. Raises: ValueError: when identifier is not set.
def __init__(self, identifier, **kwargs): if not identifier: raise ValueError('Missing identifier value.') super(MountPathSpec, self).__init__(parent=None, **kwargs) self.identifier = identifier
391,591
Initializes a file system. Args: resolver_context (Context): a resolver context. encoding (Optional[str]): encoding of the file entry name.
def __init__(self, resolver_context, encoding='utf-8'): super(ZipFileSystem, self).__init__(resolver_context) self._file_object = None self._zip_file = None self.encoding = encoding
391,594
Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): path specification of the file entry. Returns: bool: True if the file entry exists.
def FileEntryExistsByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if (location is None or not location.startswith(self.LOCATION_ROOT)): return False if len(location) == 1: return True try: self._zip_file.getinfo(location[1:]) return T...
391,597
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification of the file entry. Returns: ZipFileEntry: a file entry or None.
def GetFileEntryByPathSpec(self, path_spec): if not self.FileEntryExistsByPathSpec(path_spec): return None location = getattr(path_spec, 'location', None) if len(location) == 1: return zip_file_entry.ZipFileEntry( self._resolver_context, self, path_spec, is_root=True, ...
391,598
Retrieves the ZIP info for a path specification. Args: path_spec (PathSpec): a path specification. Returns: zipfile.ZipInfo: a ZIP info object or None if not available. Raises: PathSpecError: if the path specification is incorrect.
def GetZipInfoByPathSpec(self, path_spec): location = getattr(path_spec, 'location', None) if location is None: raise errors.PathSpecError('Path specification missing location.') if not location.startswith(self.LOCATION_ROOT): raise errors.PathSpecError('Invalid location in path specificat...
391,600
Initializes a path specification. Args: location (Optional[str]): location. parent (Optional[PathSpec]): parent path specification. Raises: ValueError: when location is not set.
def __init__(self, location=None, parent=None, **kwargs): if not location: raise ValueError('Missing location value.') super(LocationPathSpec, self).__init__(parent=parent, **kwargs) self.location = location
391,601
Initializes a volume. Args: file_entry (VShadowFileEntry): a VSS file entry.
def __init__(self, file_entry): super(VShadowVolume, self).__init__(file_entry.name) self._file_entry = file_entry
391,603
Initializes a path specification. Note that the gzip file path specification must have a parent. Args: parent (Optional[PathSpec]): parent path specification. Raises: ValueError: when parent is not set.
def __init__(self, parent=None, **kwargs): if not parent: raise ValueError('Missing parent value.') super(GzipPathSpec, self).__init__(parent=parent, **kwargs)
391,605
Initializes a file-like object. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(CPIOFile, self).__init__(resolver_context) self._cpio_archive_file = None self._cpio_archive_file_entry = None self._current_offset = 0 self._file_system = None self._size = 0
391,606
Opens the file-like object defined by path specification. Args: path_spec (Optional[PathSpec]): path specification. mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSErro...
def _Open(self, path_spec=None, mode='rb'): if not path_spec: raise ValueError('Missing path specification.') file_system = resolver.Resolver.OpenFileSystem( path_spec, resolver_context=self._resolver_context) file_entry = file_system.GetFileEntryByPathSpec(path_spec) if not file_en...
391,608
Reads a byte string from the file-like object at the current offset. The function will read a byte string of the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: ...
def read(self, size=None): if not self._is_open: raise IOError('Not opened.') if self._current_offset >= self._cpio_archive_file_entry.data_size: return b'' file_offset = ( self._cpio_archive_file_entry.data_offset + self._current_offset) read_size = self._cpio_archive_file_e...
391,609
Seeks to an offset within the file-like object. Args: offset (int): offset to seek to. whence (Optional(int)): value that indicates whether offset is an absolute or relative position within the file. Raises: IOError: if the seek failed. OSError: if the seek failed.
def seek(self, offset, whence=os.SEEK_SET): if not self._is_open: raise IOError('Not opened.') if whence == os.SEEK_CUR: offset += self._current_offset elif whence == os.SEEK_END: offset += self._cpio_archive_file_entry.data_size elif whence != os.SEEK_SET: raise IOError('U...
391,610
Initializes a path specification. Note that the RAW path specification must have a parent. Args: parent (Optional[PathSpec]): parent path specification. Raises: ValueError: when parent is not set.
def __init__(self, parent=None, **kwargs): if not parent: raise ValueError('Missing parent value.') super(RawPathSpec, self).__init__(parent=parent, **kwargs)
391,611
Initializes a path specification. Note that the operating system path specification cannot have a parent. Args: location (Optional[str]): operating specific location string e.g. /opt/dfvfs or C:\\Opt\\dfvfs. Raises: ValueError: when location is not set or parent is set.
def __init__(self, location=None, **kwargs): if not location: raise ValueError('Missing location value.') parent = None if 'parent' in kwargs: parent = kwargs['parent'] del kwargs['parent'] if parent: raise ValueError('Parent value set.') # Within the path specificati...
391,612
Initializes a file system. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(BDEFileSystem, self).__init__(resolver_context) self._bde_volume = None self._file_object = None
391,613
Opens the file system defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. The default is 'rb' read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if the file system could...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) bde_volume = pybde.volume() file_object = resolver.Resolver.Open...
391,615
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: BDEFileEntry: file entry or None.
def GetFileEntryByPathSpec(self, path_spec): return bde_file_entry.BDEFileEntry( self._resolver_context, self, path_spec, is_root=True, is_virtual=True)
391,616
Initializes a decrypter. Args: cipher_mode (Optional[str]): cipher mode. initialization_vector (Optional[bytes]): initialization vector. key (Optional[bytes]): key. kwargs (dict): keyword arguments depending on the decrypter. Raises: ValueError: when key is not set, block cipher ...
def __init__( self, cipher_mode=None, initialization_vector=None, key=None, **kwargs): if not key: raise ValueError('Missing key.') cipher_mode = self.ENCRYPTION_MODES.get(cipher_mode, None) if cipher_mode is None: raise ValueError('Unsupported cipher mode: {0!s}'.format(cipher_mode)...
391,618
Decrypts the encrypted data. Args: encrypted_data (bytes): encrypted data. Returns: tuple[bytes, bytes]: decrypted data and remaining encrypted data.
def Decrypt(self, encrypted_data): index_split = -(len(encrypted_data) % AES.block_size) if index_split: remaining_encrypted_data = encrypted_data[index_split:] encrypted_data = encrypted_data[:index_split] else: remaining_encrypted_data = b'' decrypted_data = self._aes_cipher.de...
391,619
Initializes a path specification. Note that the VHDI file path specification must have a parent. Args: parent (Optional[PathSpec]): parent path specification. Raises: ValueError: when parent is not set.
def __init__(self, parent=None, **kwargs): if not parent: raise ValueError('Missing parent value.') super(VHDIPathSpec, self).__init__(parent=parent, **kwargs)
391,620
Initializes an APFS file system. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(APFSFileSystem, self).__init__(resolver_context) self._fsapfs_volume = None
391,621
Opens the file system defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the APFS volume could not be retrieved or unlocked. OSError: if...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') if path_spec.parent.type_indicator != ( definitions.TYPE_INDICATOR_APFS_CONTAINER): raise errors.PathSpecError( 'Unsupp...
391,622
Determines if a file entry for a path specification exists. Args: path_spec (PathSpec): path specification. Returns: bool: True if the file entry exists. Raises: BackEndError: if the file entry cannot be opened.
def FileEntryExistsByPathSpec(self, path_spec): # Opening a file by identifier is faster than opening a file by location. fsapfs_file_entry = None location = getattr(path_spec, 'location', None) identifier = getattr(path_spec, 'identifier', None) try: if identifier is not None: f...
391,623
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: APFSFileEntry: file entry or None if not available. Raises: BackEndError: if the file entry cannot be opened.
def GetFileEntryByPathSpec(self, path_spec): # Opening a file by identifier is faster than opening a file by location. fsapfs_file_entry = None location = getattr(path_spec, 'location', None) identifier = getattr(path_spec, 'identifier', None) if (location == self.LOCATION_ROOT or iden...
391,624
Retrieves the APFS file entry for a path specification. Args: path_spec (PathSpec): a path specification. Returns: pyfsapfs.file_entry: file entry. Raises: PathSpecError: if the path specification is missing location and identifier.
def GetAPFSFileEntryByPathSpec(self, path_spec): # Opening a file by identifier is faster than opening a file by location. location = getattr(path_spec, 'location', None) identifier = getattr(path_spec, 'identifier', None) if identifier is not None: fsapfs_file_entry = self._fsapfs_volume.ge...
391,625
Initializes a file-like object. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(APFSFile, self).__init__(resolver_context) self._file_system = None self._fsapfs_file_entry = None
391,627
Reads a byte string from the file-like object at the current offset. The function will read a byte string of the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: ...
def read(self, size=None): if not self._is_open: raise IOError('Not opened.') return self._fsapfs_file_entry.read(size=size)
391,629
Deregisters a path specification. Args: path_spec_type (type): path specification type. Raises: KeyError: if path specification is not registered.
def DeregisterPathSpec(cls, path_spec_type): type_indicator = path_spec_type.TYPE_INDICATOR if type_indicator not in cls._path_spec_types: raise KeyError( 'Path specification type: {0:s} not set.'.format(type_indicator)) del cls._path_spec_types[type_indicator] if type_indicator i...
391,636
Retrieves a dictionary containing the path specification properties. Args: path_spec (PathSpec): path specification. Returns: dict[str, str]: path specification properties. Raises: dict: path specification properties.
def GetProperties(cls, path_spec): properties = {} for property_name in cls.PROPERTY_NAMES: # Note that we do not want to set the properties when not used. if hasattr(path_spec, property_name): properties[property_name] = getattr(path_spec, property_name) return properties
391,637
Creates a new path specification for the specific type indicator. Args: type_indicator (str): type indicator. kwargs (dict): keyword arguments depending on the path specification. Returns: PathSpec: path specification. Raises: KeyError: if path specification is not registered.
def NewPathSpec(cls, type_indicator, **kwargs): if type_indicator not in cls._path_spec_types: raise KeyError( 'Path specification type: {0:s} not set.'.format(type_indicator)) # An empty parent will cause parentless path specifications to raise # so we conveniently remove it here. ...
391,638
Registers a path specification type. Args: path_spec_type (type): path specification type. Raises: KeyError: if path specification is already registered.
def RegisterPathSpec(cls, path_spec_type): type_indicator = path_spec_type.TYPE_INDICATOR if type_indicator in cls._path_spec_types: raise KeyError( 'Path specification type: {0:s} already set.'.format( type_indicator)) cls._path_spec_types[type_indicator] = path_spec_typ...
391,639
Reads a string. Args: file_object (FileIO): file-like object. file_offset (int): offset of the data relative from the start of the file-like object. data_type_map (dtfabric.DataTypeMap): data type map of the string. description (str): description of the string. Returns: ...
def _ReadString( self, file_object, file_offset, data_type_map, description): # pylint: disable=protected-access element_data_size = ( data_type_map._element_data_type_definition.GetByteSize()) elements_terminator = ( data_type_map._data_type_definition.elements_terminator) b...
391,640
Initializes a file system. Args: resolver_context (Context): resolver context.
def __init__(self, resolver_context): super(FVDEFileSystem, self).__init__(resolver_context) self._fvde_volume = None self._file_object = None
391,643
Opens the file system defined by path specification. Args: path_spec (PathSpec): path specification. mode (Optional[str]): file access mode. The default is 'rb' read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if the file system could...
def _Open(self, path_spec, mode='rb'): if not path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec) fvde_volume = pyfvde.volume() file_object = resolver.Resolver.Op...
391,645