Skip to content

Commit

Permalink
Add support for raw and url output formats.
Browse files Browse the repository at this point in the history
Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
  • Loading branch information
Edu4rdSHL committed May 11, 2021
1 parent f20f6d6 commit 8378a29
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
10 changes: 10 additions & 0 deletions src/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 44 additions & 2 deletions src/resolver_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub resolvers: Vec<String>,
pub targets: HashSet<String>,
Expand Down

0 comments on commit 8378a29

Please # to comment.