Skip to main content

SmbClient

Struct SmbClient 

Source
pub struct SmbClient { /* private fields */ }

Implementations§

Source§

impl SmbClient

Source

pub async fn connect(host: &str) -> Result<Self>

Source

pub async fn probe_signing(&mut self) -> Result<(u16, bool)>

Unauthenticated NEGOTIATE probe: returns (dialect revision, signing_required). Signing NOT required marks a host as an NTLM-relay target. Cheap — no session setup.

Source

pub async fn login( &mut self, host: &str, domain: &str, user: &str, password: &str, ) -> Result<()>

Negotiate + NTLM session setup with a plaintext password.

Source

pub async fn login_kerberos( &mut self, gss_blob: &[u8], session_key: &[u8; 16], ) -> Result<()>

Pass-the-ticket: negotiate + Kerberos session setup with a pre-built GSS/SPNEGO AP-REQ blob and the 16-byte GSS session key (the AP-REQ authenticator subkey). Single-shot — no NTLM challenge round-trip. Subsequent messages are signed with the Kerberos session key.

Source

pub async fn login_null(&mut self, host: &str) -> Result<()>

Null / anonymous session: negotiate + NTLM session setup with empty domain / user / password. On a DC that still permits anonymous IPC$ (RestrictAnonymous=0) this yields a session usable for SAMR / LSAT RID-cycling and share enumeration; on a hardened DC (2019+ default) the server returns STATUS_ACCESS_DENIED / STATUS_LOGON_FAILURE and the caller reports the box as hardened.

Uses an empty-credential NTLMv2 exchange (the classic "" / "" / "" null bind). No signing key results from an anonymous logon, so the session is unsigned — callers must not attempt signed operations on it.

Source

pub async fn login_hash( &mut self, host: &str, domain: &str, user: &str, nt: &[u8; 16], ) -> Result<()>

Pass-the-hash: negotiate + NTLM session setup with a raw NT hash.

Source

pub async fn login_cred( &mut self, host: &str, domain: &str, user: &str, cred: Cred<'_>, ) -> Result<()>

Negotiate + NTLM session setup with either a password or an NT hash.

Source

pub async fn tree_connect(&mut self, unc: &str) -> Result<()>

Connect to a share, e.g. \\dc01\IPC$.

Source

pub async fn open_pipe(&mut self, name: &str) -> Result<[u8; 16]>

Open a named pipe on the connected tree and return its FileId.

Source

pub async fn read_pipe( &mut self, file_id: &[u8; 16], max: u32, ) -> Result<Vec<u8>>

Read up to max bytes from a pipe (SMB2 READ). Returns empty at end-of-pipe. Used to drain RPC response fragments that don’t fit one FSCTL_PIPE_TRANSCEIVE.

Source

pub async fn write_pipe( &mut self, file_id: &[u8; 16], data: &[u8], ) -> Result<()>

Write to a pipe/file with no read back — used for a fire-and-forget RPC AUTH3.

Source

pub async fn transact( &mut self, file_id: &[u8; 16], data: &[u8], ) -> Result<Vec<u8>>

One RPC round trip over the pipe (FSCTL_PIPE_TRANSCEIVE): send data, return output.

Source

pub async fn read_file_delete(&mut self, path: &str) -> Result<Vec<u8>>

Read a whole file off the currently-connected disk share and delete it on close. path is relative to the share root (e.g. Windows\Temp\out.txt). Retries the open while the file does not yet exist — an async writer (e.g. our exec child) may still be starting. Returns the file contents (possibly empty). Tree-connect the share first.

Source

pub async fn list_directory(&mut self, path: &str) -> Result<Vec<DirEntry>>

Enumerate a directory on the currently-connected disk share (SMB2 QUERY_DIRECTORY, FileDirectoryInformation). path is relative to the share root ("" = the root itself). Read-only: opens the directory handle, drains entries until STATUS_NO_MORE_FILES, and closes. ./.. are filtered out. Tree-connect the share first.

Source

pub async fn read_file(&mut self, path: &str) -> Result<Vec<u8>>

Read a whole file off the currently-connected disk share, read-only, and close WITHOUT deleting it (unlike SmbClient::read_file_delete, which is for our own exec output). path is relative to the share root. Fails if the file is absent. Tree-connect the share first.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V