pub struct SmbClient { /* private fields */ }Implementations§
Source§impl SmbClient
impl SmbClient
pub async fn connect(host: &str) -> Result<Self>
Sourcepub async fn probe_signing(&mut self) -> Result<(u16, bool)>
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.
Sourcepub async fn login(
&mut self,
host: &str,
domain: &str,
user: &str,
password: &str,
) -> Result<()>
pub async fn login( &mut self, host: &str, domain: &str, user: &str, password: &str, ) -> Result<()>
Negotiate + NTLM session setup with a plaintext password.
Sourcepub async fn login_kerberos(
&mut self,
gss_blob: &[u8],
session_key: &[u8; 16],
) -> Result<()>
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.
Sourcepub async fn login_null(&mut self, host: &str) -> Result<()>
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.
Sourcepub async fn login_hash(
&mut self,
host: &str,
domain: &str,
user: &str,
nt: &[u8; 16],
) -> Result<()>
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.
Sourcepub async fn login_cred(
&mut self,
host: &str,
domain: &str,
user: &str,
cred: Cred<'_>,
) -> Result<()>
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.
Sourcepub async fn tree_connect(&mut self, unc: &str) -> Result<()>
pub async fn tree_connect(&mut self, unc: &str) -> Result<()>
Connect to a share, e.g. \\dc01\IPC$.
Sourcepub async fn open_pipe(&mut self, name: &str) -> Result<[u8; 16]>
pub async fn open_pipe(&mut self, name: &str) -> Result<[u8; 16]>
Open a named pipe on the connected tree and return its FileId.
Sourcepub async fn read_pipe(
&mut self,
file_id: &[u8; 16],
max: u32,
) -> Result<Vec<u8>>
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.
Sourcepub async fn write_pipe(
&mut self,
file_id: &[u8; 16],
data: &[u8],
) -> Result<()>
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.
Sourcepub async fn transact(
&mut self,
file_id: &[u8; 16],
data: &[u8],
) -> Result<Vec<u8>>
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.
Sourcepub async fn read_file_delete(&mut self, path: &str) -> Result<Vec<u8>>
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.
Sourcepub async fn list_directory(&mut self, path: &str) -> Result<Vec<DirEntry>>
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.
Sourcepub async fn read_file(&mut self, path: &str) -> Result<Vec<u8>>
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.