Add raw output support.

Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
This commit is contained in:
Edu4rdSHL 2021-05-10 11:58:50 -05:00
parent e2525b3642
commit f20f6d6ce0
No known key found for this signature in database
GPG key ID: 3A574A4009F553E5
4 changed files with 45 additions and 28 deletions

View file

@ -58,7 +58,8 @@ 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"),
no_keep_nmap_logs: matches.is_present("no-keep-nmap-logs"),
raw_output: matches.is_present("raw-output"),
files: return_matches_vec(&matches, "files"),
min_rate: value_t!(matches, "min-rate", String).unwrap_or_else(|_| String::new()),
resolvers: if matches.is_present("custom-resolvers") {

View file

@ -77,9 +77,16 @@ args:
takes_value: true
multiple: false
- keep-nmap-logs:
- no-keep-nmap-logs:
help: Keep Nmap XML files created in the logs/ folder for every scanned IP. This data will be useful for other tasks.
short: k
long: keep-nmap-logs
long: no-keep-nmap-logs
takes_value: false
multiple: false
- raw-output:
help: Use raw output instead of a table.
short: r
long: raw-output
takes_value: false
multiple: false

View file

@ -68,6 +68,11 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
]);
for (target, resolv_data) in &data {
if !resolv_data.ip.is_empty() {
if args.raw_output {
for port_data in &resolv_data.ports_data {
println!("{},{},{}", target, resolv_data.ip, port_data.portid)
}
} else {
let mut services_table = Table::new();
for port_data in &resolv_data.ports_data {
services_table
@ -110,6 +115,7 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
]);
}
}
}
if args.with_output
&& !args.targets.is_empty()
@ -121,7 +127,7 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
args.file_name
)
}
if !args.quiet_flag {
if !args.quiet_flag && !args.raw_output {
table.printstd();
}
@ -132,7 +138,9 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
);
info!("Logfile saved in {}\n\n", args.file_name);
}
if !args.quiet_flag {
println!();
}
Ok(())
}
@ -174,7 +182,7 @@ fn parallel_resolver_engine(args: &Args, targets: HashSet<String>) -> HashMap<St
.unwrap_or_default()
.port
.retain(|f| f.state.state == "open");
if !args.keep_nmap_logs && std::fs::remove_file(&filename).is_err() {
if args.no_keep_nmap_logs && std::fs::remove_file(&filename).is_err() {
error!("Error removing filename {}.", &filename)
}
(ip.clone(), nmap_data)

View file

@ -18,7 +18,8 @@ pub struct Args {
pub quiet_flag: bool,
pub custom_resolvers: bool,
pub custom_ports_range: bool,
pub keep_nmap_logs: bool,
pub no_keep_nmap_logs: bool,
pub raw_output: bool,
pub fast_scan: bool,
pub files: Vec<String>,
pub resolvers: Vec<String>,