diff --git a/src/args.rs b/src/args.rs index b50eb49..6b81942 100644 --- a/src/args.rs +++ b/src/args.rs @@ -60,6 +60,7 @@ pub fn get_args() -> Args { fast_scan: matches.is_present("fast-scan"), no_keep_nmap_logs: matches.is_present("no-keep-nmap-logs"), raw_output: matches.is_present("raw-output"), + url_output: matches.is_present("url-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") { diff --git a/src/cli.yml b/src/cli.yml index 56a2a7b..fc02883 100644 --- a/src/cli.yml +++ b/src/cli.yml @@ -90,3 +90,13 @@ args: long: raw-output takes_value: false multiple: false + conflicts_with: + - url-output + + - url-output: + help: Use HOST:IP output format. + long: url-output + takes_value: false + multiple: false + conflicts_with: + - raw-output diff --git a/src/resolver_engine.rs b/src/resolver_engine.rs index 51276c3..bc933bd 100644 --- a/src/resolver_engine.rs +++ b/src/resolver_engine.rs @@ -66,11 +66,53 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> { "OPEN PORTS", "SERVICES" ]); + if args.raw_output && !args.quiet_flag { + println!("HOST,IP,PORT,SERVICE,VERSION,PRODUCT,OS,EXTRAINFO") + } else if args.url_output && !args.quiet_flag { + println!("HOST:IP") + } 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) + println!( + "{},{},{},{},{},{},{},{}", + target, + resolv_data.ip, + port_data.portid, + port_data.service.clone().unwrap_or_default().name, + port_data + .clone() + .service + .unwrap_or_default() + .version + .unwrap_or_else(|| "NULL".to_string()), + port_data + .clone() + .service + .clone() + .unwrap_or_default() + .product + .unwrap_or_else(|| "NULL".to_string()), + port_data + .service + .clone() + .unwrap_or_default() + .ostype + .clone() + .unwrap_or_else(|| "NULL".to_string()), + port_data + .service + .clone() + .unwrap_or_default() + .extrainfo + .clone() + .unwrap_or_else(|| "NULL".to_string()) + ) + } + } else if args.url_output { + for port_data in &resolv_data.ports_data { + println!("{}:{}", target, port_data.portid) } } else { let mut services_table = Table::new(); @@ -127,7 +169,7 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> { args.file_name ) } - if !args.quiet_flag && !args.raw_output { + if !args.quiet_flag && !args.raw_output && !args.url_output { table.printstd(); } diff --git a/src/structs.rs b/src/structs.rs index dbdb6e8..edc937c 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -21,6 +21,7 @@ pub struct Args { pub no_keep_nmap_logs: bool, pub raw_output: bool, pub fast_scan: bool, + pub url_output: bool, pub files: Vec, pub resolvers: Vec, pub targets: HashSet,