dissect.target.helpers.sunrpc.client

Module Contents

Classes

AuthScheme

Abstract base class for generic types.

AbstractClient

Helper class that provides a standard way to create an ABC using

LocalPortPolicy

Policy for binding to a local port.

Client

An abstract base class for context managers.

Functions

Attributes

dissect.target.helpers.sunrpc.client.Credentials
dissect.target.helpers.sunrpc.client.Verifier
dissect.target.helpers.sunrpc.client.ConCredentials
dissect.target.helpers.sunrpc.client.ConVerifier
dissect.target.helpers.sunrpc.client.Params
dissect.target.helpers.sunrpc.client.Results
class dissect.target.helpers.sunrpc.client.AuthScheme

Bases: Generic[Credentials, Verifier]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
flavor: int
credentials: Credentials
verifier: Verifier
credentials_serializer: dissect.target.helpers.sunrpc.serializer.AuthSerializer[Credentials]
verifier_serializer: dissect.target.helpers.sunrpc.serializer.AuthSerializer[Verifier]
dissect.target.helpers.sunrpc.client.auth_null() AuthScheme[dissect.target.helpers.sunrpc.sunrpc.AuthNull, dissect.target.helpers.sunrpc.sunrpc.AuthNull]
dissect.target.helpers.sunrpc.client.auth_unix(machine: str | None, uid: int, gid: int, gids: list[int]) AuthScheme[dissect.target.helpers.sunrpc.sunrpc.AuthUnix, dissect.target.helpers.sunrpc.sunrpc.AuthNull]
exception dissect.target.helpers.sunrpc.client.MismatchXidError

Bases: Exception

Common base class for all non-exit exceptions.

exception dissect.target.helpers.sunrpc.client.UnexpectedResponse

Bases: Exception

Common base class for all non-exit exceptions.

exception dissect.target.helpers.sunrpc.client.IncompleteMessage

Bases: Exception

Common base class for all non-exit exceptions.

exception dissect.target.helpers.sunrpc.client.InvalidPortMapping

Bases: Exception

Common base class for all non-exit exceptions.

class dissect.target.helpers.sunrpc.client.AbstractClient

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract call(proc_desc: dissect.target.helpers.nfs.nfs3.ProcedureDescriptor, params: Params, params_serializer: dissect.target.helpers.sunrpc.serializer.Serializer[Params], result_deserializer: dissect.target.helpers.sunrpc.serializer.Deserializer[Results]) Results
abstract close() None
abstract rebind_auth(auth: AuthScheme[ConCredentials, ConVerifier]) None
class dissect.target.helpers.sunrpc.client.LocalPortPolicy

Bases: enum.IntEnum

Policy for binding to a local port.

ANY = 0
PRIVILEGED = -1
class dissect.target.helpers.sunrpc.client.Client(sock: socket.socket, auth: AuthScheme[Credentials, Verifier], fragment_size: int = 8192)

Bases: contextlib.AbstractContextManager, AbstractClient, Generic[Credentials, Verifier]

An abstract base class for context managers.

PMAP_PORT = 111
TCP_KEEPIDLE = 60
TCP_KEEPINTVL = 10
TCP_KEEPCNT = 3
classmethod connect_port_mapper(hostname: str, timeout_in_seconds: float | None = 5.0) Client[dissect.target.helpers.sunrpc.sunrpc.AuthNull, dissect.target.helpers.sunrpc.sunrpc.AuthNull]

Connect to the port mapper service on a remote host.

classmethod connect(hostname: str, port: int, auth: AuthScheme[ConCredentials, ConVerifier], local_port: int | LocalPortPolicy = 0, timeout_in_seconds: float | None = 5.0) Client[ConCredentials, ConVerifier]

Connect to a RPC server.

Parameters:
  • hostname – The remote hostname.

  • port – The remote port.

  • auth – The authentication scheme.

  • local_port – The local port to bind to. If equal to LocalPortPolicy.PRIVILEGED or -1, bind to the first free privileged port. If equal to LocalPortPolicy.ANY or 0, bind to any free port. Otherwise, bind to the specified port.

  • timeout_in_seconds – The timeout for making the connection.

__enter__() typing_extensions.Self

Return self upon entering the runtime context.

__exit__(_: type[BaseException] | None, __: BaseException | None, ___: types.TracebackType | None) bool

Raise any exception triggered within the runtime context.

close() None
rebind_auth(auth: AuthScheme[ConCredentials, ConVerifier]) Client[ConCredentials, ConVerifier]

Return a new client with the same socket, but different authentication credentials.

query_port_mapping(program: int, version: int) int

Query port number of specified program and version.

call(proc_desc: dissect.target.helpers.nfs.nfs3.ProcedureDescriptor, params: Params, params_serializer: dissect.target.helpers.sunrpc.serializer.Serializer[Params], result_deserializer: dissect.target.helpers.sunrpc.serializer.Deserializer[Results]) Results

Synchronously call an RPC procedure and return the result.

__del__()