mirror of
https://github.com/edu4rdshl/unimap.git
synced 2026-07-17 23:24:49 +00:00
Add support from reading from stdin.
Signed-off-by: Edu4rdSHL <edu4rdshl@protonmail.com>
This commit is contained in:
parent
177e29abe4
commit
ba1f7da885
6 changed files with 32 additions and 5 deletions
|
|
@ -58,6 +58,7 @@ pub fn get_args() -> Args {
|
||||||
no_keep_nmap_logs: matches.is_present("no-keep-nmap-logs"),
|
no_keep_nmap_logs: matches.is_present("no-keep-nmap-logs"),
|
||||||
raw_output: matches.is_present("raw-output"),
|
raw_output: matches.is_present("raw-output"),
|
||||||
url_output: matches.is_present("url-output"),
|
url_output: matches.is_present("url-output"),
|
||||||
|
from_stdin: matches.is_present("stdin"),
|
||||||
files: return_matches_vec(&matches, "files"),
|
files: return_matches_vec(&matches, "files"),
|
||||||
min_rate: value_t!(matches, "min-rate", String).unwrap_or_else(|_| String::new()),
|
min_rate: value_t!(matches, "min-rate", String).unwrap_or_else(|_| String::new()),
|
||||||
resolvers: if matches.is_present("custom-resolvers") {
|
resolvers: if matches.is_present("custom-resolvers") {
|
||||||
|
|
|
||||||
11
src/cli.yml
11
src/cli.yml
|
|
@ -13,6 +13,7 @@ args:
|
||||||
multiple: false
|
multiple: false
|
||||||
conflicts_with:
|
conflicts_with:
|
||||||
- files
|
- files
|
||||||
|
- stdin
|
||||||
|
|
||||||
- files:
|
- files:
|
||||||
short: f
|
short: f
|
||||||
|
|
@ -22,6 +23,7 @@ args:
|
||||||
multiple: true
|
multiple: true
|
||||||
conflicts_with:
|
conflicts_with:
|
||||||
- target
|
- target
|
||||||
|
- stdin
|
||||||
|
|
||||||
- output:
|
- output:
|
||||||
short: o
|
short: o
|
||||||
|
|
@ -100,3 +102,12 @@ args:
|
||||||
multiple: false
|
multiple: false
|
||||||
conflicts_with:
|
conflicts_with:
|
||||||
- raw-output
|
- raw-output
|
||||||
|
|
||||||
|
- stdin:
|
||||||
|
help: Read from stdin instead of files or aguments.
|
||||||
|
long: stdin
|
||||||
|
takes_value: false
|
||||||
|
multiple: false
|
||||||
|
conflicts_with:
|
||||||
|
- files
|
||||||
|
- target
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ pub mod args;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod files;
|
pub mod files;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
|
pub mod misc;
|
||||||
pub mod resolver_engine;
|
pub mod resolver_engine;
|
||||||
|
|
||||||
mod defaults;
|
mod defaults;
|
||||||
mod logic;
|
mod logic;
|
||||||
mod misc;
|
|
||||||
mod networking;
|
mod networking;
|
||||||
mod nmap;
|
mod nmap;
|
||||||
mod structs;
|
mod structs;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
log::{error, Level},
|
log::{error, Level},
|
||||||
std::{collections::HashSet, iter::FromIterator},
|
std::{collections::HashSet, iter::FromIterator},
|
||||||
unimap::{args, errors::*, files::return_file_targets, logger, resolver_engine},
|
unimap::{args, errors::*, files::return_file_targets, logger, misc, resolver_engine},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn run() -> Result<()> {
|
fn run() -> Result<()> {
|
||||||
|
|
@ -14,8 +14,10 @@ fn run() -> Result<()> {
|
||||||
if !arguments.files.is_empty() {
|
if !arguments.files.is_empty() {
|
||||||
arguments.targets =
|
arguments.targets =
|
||||||
HashSet::from_iter(return_file_targets(&arguments, arguments.files.clone()))
|
HashSet::from_iter(return_file_targets(&arguments, arguments.files.clone()))
|
||||||
} else {
|
} else if !arguments.target.is_empty() {
|
||||||
arguments.targets.insert(arguments.target.clone());
|
arguments.targets.insert(arguments.target.clone());
|
||||||
|
} else {
|
||||||
|
arguments.targets = misc::read_stdin()
|
||||||
}
|
}
|
||||||
|
|
||||||
if arguments.targets.len() < 50 {
|
if arguments.targets.len() < 50 {
|
||||||
|
|
@ -27,7 +29,7 @@ fn run() -> Result<()> {
|
||||||
.build_global()
|
.build_global()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if !arguments.target.is_empty() || !arguments.files.is_empty() {
|
if !arguments.targets.is_empty() {
|
||||||
resolver_engine::parallel_resolver_all(&mut arguments)
|
resolver_engine::parallel_resolver_all(&mut arguments)
|
||||||
} else {
|
} else {
|
||||||
error!("Error: Target is empty or invalid!\n");
|
error!("Error: Target is empty or invalid!\n");
|
||||||
|
|
|
||||||
14
src/misc.rs
14
src/misc.rs
|
|
@ -1,4 +1,7 @@
|
||||||
use std::collections::HashSet;
|
use std::{
|
||||||
|
collections::HashSet,
|
||||||
|
io::{self, Read},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn sanitize_target_string(target: String) -> String {
|
pub fn sanitize_target_string(target: String) -> String {
|
||||||
target
|
target
|
||||||
|
|
@ -32,3 +35,12 @@ pub fn return_matches_hashset(matches: &clap::ArgMatches, value: &str) -> HashSe
|
||||||
HashSet::new()
|
HashSet::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read_stdin() -> HashSet<String> {
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let mut stdin = io::stdin();
|
||||||
|
stdin
|
||||||
|
.read_to_string(&mut buffer)
|
||||||
|
.expect("Error getting input list.");
|
||||||
|
buffer.lines().map(str::to_owned).collect()
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ pub struct Args {
|
||||||
pub raw_output: bool,
|
pub raw_output: bool,
|
||||||
pub fast_scan: bool,
|
pub fast_scan: bool,
|
||||||
pub url_output: bool,
|
pub url_output: bool,
|
||||||
|
pub from_stdin: bool,
|
||||||
pub files: Vec<String>,
|
pub files: Vec<String>,
|
||||||
pub resolvers: Vec<String>,
|
pub resolvers: Vec<String>,
|
||||||
pub targets: HashSet<String>,
|
pub targets: HashSet<String>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue