Add: Implement smb and wmi functions#2197
Conversation
Dependency ReviewThe following issues were found:
|
| // Note that the first session ID we will | ||
| // hand out is an arbitrary high number, this is only to help | ||
| // debugging. |
There was a problem hiding this comment.
I think this comment should go on the MIN_HANDLE_ID
| ctx.target().ip_addr() | ||
| }; | ||
|
|
||
| let host = if let Some(_krb5) = kdc.clone() { |
There was a problem hiding this comment.
clone() feels unnecessary here, and the actual match is ignored, so why not
if kdc.is_some() { ... } which avoids the clone
(if let Some(ref krb5) = kdc { ... } would be the alternative if we need the krb5)
| match lookup_addr(&host) { | ||
| Ok(host) => host, | ||
| Err(e) => { | ||
| return Err(SmbError::InvalidHost(e.to_string()).into()); | ||
| } | ||
| } |
There was a problem hiding this comment.
lookup_addr(&host).map_err(|e| SmbError::InvalidHost(e.to_string()).into())?
|
|
||
| let username = username.replacen("\\", "/", 1); | ||
| let realm = realm.unwrap_or_default(); | ||
| let target = if let Some(_realm) = username.find("/") { |
There was a problem hiding this comment.
same as above, this is username.find("/").is_some(). Putting underscores in front of variable names is virtually never the rusty thing to do - mutex guards being a notable exception
| if let Some(krb5) = kdc.clone() { | ||
| let first_kdc = if let Some(i) = krb5.find(",") { | ||
| krb5[..i].to_string() | ||
| } else { | ||
| krb5 | ||
| }; |
There was a problem hiding this comment.
total nitpick but just for curiosities sake: doing
if let Some(ref krb5) = kdc {
let first_kdc = if let Some(i) = krb5.find(",") {
&krb5[..i]
} else {
&krb5
};
output.arg("-k").arg("-dc-ip").arg(first_kdc);
}
output.arg(target).arg(cmd);would be a way to avoid the clone.
| realm: Option<String>, | ||
| kdc: Option<String>, | ||
| cmd: String, | ||
| ) -> Result<Option<String>, FnError> { |
There was a problem hiding this comment.
Just for fun: The nasl_function macro also allows returning SmbError as the error type of this function (any error type that has a Into<FnError> works) and then add
From<io::Error> and From<AddrParseError> impls to get rid of all of the map_err calls in this function (the ? operator auto-converts via From)
| mod knowledge_base; | ||
| mod krb5; | ||
| pub mod misc; | ||
| mod naslsmb; |
There was a problem hiding this comment.
Personal nitpick: This is already in the nasl/builtin/mod.rs, so the nasl is already implied. Why not simply smb? We have a smb.rs in the cryptographic subfolder, but I think it's clear enough that this is something else.
| cidr = "0.3.2" | ||
| smb = "0.11.2" | ||
| smb-msg = "0.11.2" | ||
| use = "0.0.1-pre.0" |
There was a problem hiding this comment.
unused. Also, what is this?
| rustls-pki-types = { version = "1.14.0", features = ["std"] } | ||
| cidr = "0.3.2" | ||
| smb = "0.11.2" | ||
| smb-msg = "0.11.2" |
| smb = "0.11.2" | ||
| smb-msg = "0.11.2" | ||
| use = "0.0.1-pre.0" | ||
| smb-dtyp = "0.11.2" |
|
Blocked by afiffon/smb-rs#166 |
What:
Add:
Jira: SC-1432
Why:
How:
Ensure you have access to the windows target and there file exists. Run the following nasl script with the right credentials.
target/debug/scannerctl execute script smb_rs.nasl -t TARGET_IP --kb="SMB/login=DOMAIN\USER" --kb="SMB/password=PASS"Checklist: