Skip to content

Commit

Permalink
Allow users to keep Nmap XML logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edu4rdSHL committed Sep 4, 2020
1 parent 93cbc6a commit 945e09b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
7 changes: 7 additions & 0 deletions src/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 deletions src/resolver_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit 945e09b

Please # to comment.