dissect.target.filesystems.smb

Module Contents

Classes

SmbFilesystem

Filesystem implementation for SMB.

SmbDirEntry

Directory entry base class. Closely models os.DirEntry.

SmbFilesystemEntry

Base class for filesystem entries.

SmbStream

Stream implementation for reading SMB files.

Attributes

dissect.target.filesystems.smb.HAS_IMPACKET = True
dissect.target.filesystems.smb.log
class dissect.target.filesystems.smb.SmbFilesystem(conn: impacket.smbconnection.SMBConnection, share_name: str, *args, **kwargs)

Bases: dissect.target.filesystem.Filesystem

Filesystem implementation for SMB.

__type__ = 'smb'

A short string identifying the type of filesystem.

conn
share_name
static detect(fh: BinaryIO) bool

No, your file is not an SMB connection.

get(path: str) dissect.target.filesystem.FilesystemEntry

Returns a SmbFilesystemEntry object corresponding to the given path.

class dissect.target.filesystems.smb.SmbDirEntry(fs: Filesystem, path: str, name: str, entry: Any)

Bases: dissect.target.filesystem.DirEntry

Directory entry base class. Closely models os.DirEntry.

Filesystem implementations are encouraged to subclass this class to provide efficient implementations of the various methods.

Parameters:
  • fs – The filesystem the entry belongs to.

  • path – The path of the parent directory.

  • name – The name of the entry.

  • entry – The raw entry backing this directory entry.

fs: SmbFilesystem

The filesystem the entry belongs to.

entry: impacket.smb.SharedFile

The raw entry backing this directory entry.

get() SmbFilesystemEntry

Retrieve the FilesystemEntry this directory entry points to.

Subclasses should override this method to provide an efficient implementation.

is_dir(*, follow_symlinks: bool = True) bool

Return whether this entry is a directory or a symbolic link pointing to a directory.

Subclasses should override this method to provide an efficient implementation.

is_file(*, follow_symlinks: bool = True) bool

Return whether this entry is a file or a symbolic link pointing to a file.

Subclasses should override this method to provide an efficient implementation.

Return whether this entry is a symbolic link.

Subclasses should override this method to provide an efficient implementation.

stat(*, follow_symlinks: bool = True) dissect.target.helpers.fsutil.stat_result
class dissect.target.filesystems.smb.SmbFilesystemEntry(fs: Filesystem, path: str, entry: Any)

Bases: dissect.target.filesystem.FilesystemEntry

Base class for filesystem entries.

fs: SmbFilesystem
entry: impacket.smb.SharedFile
get(path: str) dissect.target.filesystem.FilesystemEntry

Retrieve a FilesystemEntry relative to this entry.

Parameters:

path – The path relative to this filesystem entry.

Returns:

A relative FilesystemEntry.

scandir() collections.abc.Iterator[SmbDirEntry]

Iterate over the contents of a directory, yields FilesystemEntry.

Returns:

An iterator of FilesystemEntry.

open() SmbStream

Open this filesystem entry.

Returns:

A file-like object. Resolves symlinks when possible

is_dir(follow_symlinks: bool = True) bool

Determine if this entry is a directory.

Parameters:

follow_symlinks – Whether to resolve the entry if it is a symbolic link.

Returns:

True if the entry is a directory or a symbolic link to a directory, return False otherwise. If follow_symlinks is False, return True only if the entry is a directory (without following symlinks).

is_file(follow_symlinks: bool = True) bool

Determine if this entry is a file.

Parameters:

follow_symlinks – Whether to resolve the entry if it is a symbolic link.

Returns:

True if the entry is a file or a symbolic link to a file, return False otherwise. If follow_symlinks is False, return True only if the entry is a file (without following symlinks).

Determine whether this entry is a symlink.

Returns:

True if the entry is a symbolic link, False otherwise.

Read the link where this entry points to, return the resulting path as string.

If it is a symlink and returns the entry that corresponds to that path. This means it follows the path a link points to, it tries to do it recursively.

Returns:

The path the link points to.

stat(follow_symlinks: bool = True) dissect.target.helpers.fsutil.stat_result

Determine the stat information of this entry.

If the entry is a symlink and follow_symlinks is True, it gets resolved, attempting to stat the path where it points to.

Parameters:

follow_symlinks – Whether to resolve the symbolic link if this entry is a symbolic link.

Returns:

The stat information of this entry.

lstat() dissect.target.helpers.fsutil.stat_result

Determine the stat information of this entry, without resolving the symlinks.

When it detects a symlink, it will stat the information of the symlink, not the path it points to.

Returns:

The stat information of this entry.

class dissect.target.filesystems.smb.SmbStream(conn: impacket.smbconnection.SMBConnection, share_name: str, path: str, size: int)

Bases: dissect.util.stream.AlignedStream

Stream implementation for reading SMB files.

conn
share_name
path
tree_id
file_id
close() None

Close the stream. Does nothing by default.