use anyhow::Result;
use clap::Parser;
#[derive(Parser)]
pub(crate) struct LsaArgs {
#[command(flatten)]
pub auth: crate::shared_args::SmbAuth,
#[arg(long)]
pub nt_hash: Option<adhammer_core::SecretString>,
#[arg(long)]
pub name: String,
}
pub(crate) async fn lsa(a: LsaArgs) -> Result<()> {
use dcerpc::lsat::LsatClient;
use smb2_client::SmbClient;
let mut smb = SmbClient::connect(&a.auth.host).await?;
crate::smb_login(
&mut smb,
&a.auth.host,
&a.auth.domain,
&a.auth.user,
&a.auth.password,
&a.nt_hash,
)
.await?;
smb.tree_connect(&format!("\\\\{}\\IPC$", a.auth.host))
.await?;
let pipe = smb.open_pipe("lsarpc").await?;
let mut client = LsatClient::bind(&mut smb, pipe).await?;
let policy = client.open_policy().await?;
match client.lookup_name(&policy, &a.name).await? {
Some(sid) => println!("{} => {sid}", a.name),
None => println!("{} => (not mapped)", a.name),
}
Ok(())
}