Allow users to keep Nmap XML logs.

This commit is contained in:
Eduard Tolosa 2020-09-03 20:22:42 -05:00
parent 93cbc6a58b
commit 945e09bb23
4 changed files with 12 additions and 6 deletions

View file

@ -59,6 +59,7 @@ pub fn get_args() -> Args {
custom_resolvers: matches.is_present("custom-resolvers"),
custom_ports_range: matches.is_present("initial-port") || matches.is_present("last-port"),
fast_scan: matches.is_present("fast-scan"),
keep_nmap_logs: matches.is_present("keep-nmap-logs"),
files: return_matches_vec(&matches, "files"),
min_rate: value_t!(matches, "min-rate", usize).unwrap_or_else(|_| 30000),
resolvers: if matches.is_present("custom-resolvers") {

View file

@ -82,3 +82,10 @@ args:
long: logs-dir
takes_value: true
multiple: false
- keep-nmap-logs:
help: Keep Nmap XML files created in the logs/ folder for every scanned IP. This data will be usefull for other tasks.
short: k
long: keep-nmap-logs
takes_value: false
multiple: false

View file

@ -190,12 +190,9 @@ fn async_resolver_engine(args: &Args, targets: HashSet<String>) -> HashMap<Strin
.unwrap_or_default()
.port
.retain(|f| f.state.state == "open");
match std::fs::remove_file(&filename) {
Ok(_) => (),
Err(e) => {
error!("Error removing filename {}. Description: {}", &filename, e)
}
};
if !args.keep_nmap_logs && std::fs::remove_file(&filename).is_err() {
error!("Error removing filename {}.", &filename)
}
(ip.clone(), nmap_data)
}
Err(e) => {

View file

@ -19,6 +19,7 @@ pub struct Args {
pub quiet_flag: bool,
pub custom_resolvers: bool,
pub custom_ports_range: bool,
pub keep_nmap_logs: bool,
pub fast_scan: bool,
pub files: Vec<String>,
pub resolvers: Vec<String>,