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>
impl<'a> LsadClient<'a>
Sourcepub async fn bind(client: &'a mut SmbClient, file_id: [u8; 16]) -> Result<Self>
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}Sourcepub async fn enumerate_trusts(
&mut self,
system_name: &str,
) -> Result<Vec<TrustedDomainInfo>>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more