Skip to main content

LsadClient

Struct LsadClient 

Source
pub struct LsadClient<'a> { /* private fields */ }
Expand description

Ergonomic LSAD client. Binds the LSA interface over an already-open \lsarpc pipe, opens the policy handle lazily on the first call.

Implementations§

Source§

impl<'a> LsadClient<'a>

Source

pub async fn bind(client: &'a mut SmbClient, file_id: [u8; 16]) -> Result<Self>

Bind the LSA interface over a fresh \lsarpc pipe.

Examples found in repository?
examples/enum_trusts.rs (line 43)
20async fn main() -> Result<(), Box<dyn Error>> {
21    let args: Vec<String> = std::env::args().collect();
22    if args.len() < 5 {
23        eprintln!(
24            "usage: {} <host> <domain> <user> <password>",
25            args.first().map(String::as_str).unwrap_or("enum_trusts")
26        );
27        std::process::exit(2);
28    }
29    let host = &args[1];
30    let domain = &args[2];
31    let user = &args[3];
32    let password = &args[4];
33
34    eprintln!("[+] connecting to \\\\{host}\\IPC$ as {domain}\\{user}");
35    let mut smb = SmbClient::connect(host).await?;
36    smb.login(host, domain, user, password).await?;
37    smb.tree_connect(&format!("\\\\{host}\\IPC$")).await?;
38
39    eprintln!("[+] opening \\PIPE\\lsarpc");
40    let pipe = smb.open_pipe("lsarpc").await?;
41
42    eprintln!("[+] binding MS-LSAD interface + LsarOpenPolicy2");
43    let mut client = LsadClient::bind(&mut smb, pipe).await?;
44
45    eprintln!("[+] calling LsarEnumerateTrustedDomains (opnum 13)");
46    let trusts = client.enumerate_trusts("").await?;
47
48    println!("=== {} trust(s) enumerated ===", trusts.len());
49    for t in &trusts {
50        println!("  {}  {}", t.sid, t.name);
51    }
52
53    Ok(())
54}
Source

pub async fn enumerate_trusts( &mut self, system_name: &str, ) -> Result<Vec<TrustedDomainInfo>>

Enumerate every trust in one page (loops the paging cursor internally until the server returns next_context == 0). Real-world domains have < 256 trusts; a single page is almost always sufficient.

Examples found in repository?
examples/enum_trusts.rs (line 46)
20async fn main() -> Result<(), Box<dyn Error>> {
21    let args: Vec<String> = std::env::args().collect();
22    if args.len() < 5 {
23        eprintln!(
24            "usage: {} <host> <domain> <user> <password>",
25            args.first().map(String::as_str).unwrap_or("enum_trusts")
26        );
27        std::process::exit(2);
28    }
29    let host = &args[1];
30    let domain = &args[2];
31    let user = &args[3];
32    let password = &args[4];
33
34    eprintln!("[+] connecting to \\\\{host}\\IPC$ as {domain}\\{user}");
35    let mut smb = SmbClient::connect(host).await?;
36    smb.login(host, domain, user, password).await?;
37    smb.tree_connect(&format!("\\\\{host}\\IPC$")).await?;
38
39    eprintln!("[+] opening \\PIPE\\lsarpc");
40    let pipe = smb.open_pipe("lsarpc").await?;
41
42    eprintln!("[+] binding MS-LSAD interface + LsarOpenPolicy2");
43    let mut client = LsadClient::bind(&mut smb, pipe).await?;
44
45    eprintln!("[+] calling LsarEnumerateTrustedDomains (opnum 13)");
46    let trusts = client.enumerate_trusts("").await?;
47
48    println!("=== {} trust(s) enumerated ===", trusts.len());
49    for t in &trusts {
50        println!("  {}  {}", t.sid, t.name);
51    }
52
53    Ok(())
54}

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for LsadClient<'a>

§

impl<'a> Freeze for LsadClient<'a>

§

impl<'a> RefUnwindSafe for LsadClient<'a>

§

impl<'a> Send for LsadClient<'a>

§

impl<'a> Sync for LsadClient<'a>

§

impl<'a> Unpin for LsadClient<'a>

§

impl<'a> UnsafeUnpin for LsadClient<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more