Skip to content

Commit 9ce001f

Browse files
authored
Merge pull request #620 from israelrg/ipv6nmapfix
BugFix: Allow IPV6 addresses to be parsed into NMAP
2 parents f81312d + 4f964b7 commit 9ce001f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/scripts/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use text_placeholder::Template;
9191
static DEFAULT: &str = r#"tags = ["core_approved", "RustScan", "default"]
9292
developer = [ "RustScan", "https://github.com/RustScan" ]
9393
ports_separator = ","
94-
call_format = "nmap -vvv -p {{port}} {{ip}}"
94+
call_format = "nmap -vvv -p {{port}} -{{ipversion}} {{ip}}"
9595
"#;
9696

9797
#[cfg(not(tarpaulin_include))]
@@ -184,12 +184,14 @@ struct ExecPartsScript {
184184
script: String,
185185
ip: String,
186186
port: String,
187+
ipversion: String
187188
}
188189

189190
#[derive(Serialize)]
190191
struct ExecParts {
191192
ip: String,
192193
port: String,
194+
ipversion: String
193195
}
194196

195197
impl Script {
@@ -244,17 +246,24 @@ impl Script {
244246
script: self.path.unwrap().to_str().unwrap().to_string(),
245247
ip: self.ip.to_string(),
246248
port: ports_str,
249+
ipversion: match &self.ip {
250+
IpAddr::V4(_) => String::from("4"),
251+
IpAddr::V6(_) => String::from("6")
252+
}
247253
};
248254
to_run = default_template.fill_with_struct(&exec_parts_script)?;
249255
} else {
250256
let exec_parts: ExecParts = ExecParts {
251257
ip: self.ip.to_string(),
252258
port: ports_str,
259+
ipversion: match &self.ip {
260+
IpAddr::V4(_) => String::from("4"),
261+
IpAddr::V6(_) => String::from("6")
262+
}
253263
};
254264
to_run = default_template.fill_with_struct(&exec_parts)?;
255265
}
256266
debug!("\nScript format to run {}", to_run);
257-
258267
execute_script(&to_run)
259268
}
260269
}

0 commit comments

Comments
 (0)