mirror of
https://github.com/edu4rdshl/unimap.git
synced 2026-07-17 23:24:49 +00:00
(chore): bump dependencies and adapt code to new ones
This commit is contained in:
parent
a6c166e470
commit
c6a06db04b
5 changed files with 1316 additions and 647 deletions
1677
Cargo.lock
generated
1677
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
39
Cargo.toml
39
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "unimap"
|
name = "unimap"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
authors = ["Eduard Tolosa <edu4rdshl@protonmail.com>"]
|
authors = ["Eduard Tolosa <edu4rdshl@protonmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Scan only once by IP address and reduce scan times with Nmap for large amounts of data."
|
description = "Scan only once by IP address and reduce scan times with Nmap for large amounts of data."
|
||||||
|
|
@ -12,39 +12,31 @@ readme = "README.md"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
trust-dns-resolver = "0.20.4"
|
hickory-resolver = "0.25.2"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
log = { version = "0.4.27", features = ["std"] }
|
log = { version = "0.4.27", features = ["std"] }
|
||||||
colored = { version = "2.2.0", optional = true }
|
colored = { version = "3.0.0", optional = true }
|
||||||
rand = "0.8.5"
|
rand = "0.9.2"
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
|
tokio = { version = "1.47.0", features = ["rt"] }
|
||||||
|
futures = "0.3"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_derive = "1.0.219"
|
serde_derive = "1.0.219"
|
||||||
prettytable-rs = "0.8.0"
|
prettytable-rs = "0.10.0"
|
||||||
serde-xml-rs = "0.5.1"
|
serde-xml-rs = "0.8.1"
|
||||||
chrono = "0.4.40"
|
chrono = "0.4.41"
|
||||||
clap = { version = "2.34.0", features = ["yaml"] }
|
clap = { version = "4.5.42", features = ["derive"] }
|
||||||
config = { version = "0.11.0", features = [
|
config = { version = "0.15.13", features = ["yaml", "json", "toml", "ini"] }
|
||||||
"yaml",
|
|
||||||
"json",
|
|
||||||
"toml",
|
|
||||||
"hjson",
|
|
||||||
"ini",
|
|
||||||
] }
|
|
||||||
failure = "0.1.8"
|
failure = "0.1.8"
|
||||||
|
|
||||||
# https://github.com/bluejekyll/trust-dns/pull/1632
|
|
||||||
[patch.crates-io]
|
|
||||||
trust-dns-resolver = { git = "https://github.com/Findomain/trust-dns", package = "trust-dns-resolver", branch = "custombranch" }
|
|
||||||
|
|
||||||
[target.arm-unknown-linux-gnueabihf.dependencies]
|
[target.arm-unknown-linux-gnueabihf.dependencies]
|
||||||
openssl = { version = "0.10.72", features = ["vendored"] }
|
openssl = { version = "0.10.73", features = ["vendored"] }
|
||||||
|
|
||||||
[target.aarch64-unknown-linux-gnu.dependencies]
|
[target.aarch64-unknown-linux-gnu.dependencies]
|
||||||
openssl = { version = "0.10.72", features = ["vendored"] }
|
openssl = { version = "0.10.73", features = ["vendored"] }
|
||||||
|
|
||||||
[target.armv7-unknown-linux-gnueabihf.dependencies]
|
[target.armv7-unknown-linux-gnueabihf.dependencies]
|
||||||
openssl = { version = "0.10.72", features = ["vendored"] }
|
openssl = { version = "0.10.73", features = ["vendored"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
atty = "0.2.14"
|
atty = "0.2.14"
|
||||||
|
|
@ -55,5 +47,4 @@ winapi = { version = "0.3.9", features = ["handleapi", "winbase"] }
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = 'abort'
|
panic = 'abort'
|
||||||
incremental = false
|
strip = true
|
||||||
opt-level = "s"
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,43 @@
|
||||||
use {
|
use {
|
||||||
crate::{files, structs::Args},
|
crate::{args::ProcessedArgs, files},
|
||||||
std::{collections::HashSet, net::SocketAddr},
|
hickory_resolver::{
|
||||||
trust_dns_resolver::{
|
config::{NameServerConfig, NameServerConfigGroup, ResolverConfig, ResolverOpts},
|
||||||
config::{NameServerConfig, NameServerConfigGroup, Protocol, ResolverConfig, ResolverOpts},
|
name_server::TokioConnectionProvider,
|
||||||
Resolver,
|
proto::xfer::Protocol,
|
||||||
|
TokioResolver,
|
||||||
},
|
},
|
||||||
|
std::{collections::HashSet, net::SocketAddr},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn get_records(resolver: &Resolver, domain: &str) -> String {
|
pub fn get_records(resolver: &TokioResolver, domain: &str) -> String {
|
||||||
if let Ok(ips) = resolver.ipv4_lookup(domain) {
|
futures::executor::block_on(resolver.ipv4_lookup(domain)).map_or_else(
|
||||||
ips.iter()
|
|_| String::new(),
|
||||||
.map(std::string::ToString::to_string)
|
|ips| {
|
||||||
.next()
|
ips.iter()
|
||||||
.expect("Failed to get IPV4.")
|
.map(std::string::ToString::to_string)
|
||||||
} else {
|
.next()
|
||||||
String::new()
|
.expect("Failed to get IPV4.")
|
||||||
}
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_resolver(nameserver_ips: HashSet<SocketAddr>, opts: ResolverOpts) -> Resolver {
|
pub fn get_resolver(nameserver_ips: HashSet<SocketAddr>, opts: ResolverOpts) -> TokioResolver {
|
||||||
let mut name_servers = NameServerConfigGroup::with_capacity(nameserver_ips.len() * 2);
|
let mut name_servers = NameServerConfigGroup::with_capacity(nameserver_ips.len());
|
||||||
name_servers.extend(nameserver_ips.into_iter().flat_map(|socket_addr| {
|
name_servers.extend(
|
||||||
std::iter::once(NameServerConfig {
|
nameserver_ips
|
||||||
socket_addr,
|
.into_iter()
|
||||||
protocol: Protocol::Udp,
|
.map(|socket_addr| NameServerConfig::new(socket_addr, Protocol::Udp)),
|
||||||
tls_dns_name: None,
|
);
|
||||||
trust_nx_responses: false,
|
|
||||||
})
|
TokioResolver::builder_with_config(
|
||||||
.chain(std::iter::once(NameServerConfig {
|
ResolverConfig::from_parts(None, vec![], name_servers),
|
||||||
socket_addr,
|
TokioConnectionProvider::default(),
|
||||||
protocol: Protocol::Tcp,
|
)
|
||||||
tls_dns_name: None,
|
.with_options(opts)
|
||||||
trust_nx_responses: false,
|
.build()
|
||||||
}))
|
|
||||||
}));
|
|
||||||
Resolver::new(ResolverConfig::from_parts(None, vec![], name_servers), opts).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn return_socket_address(args: &Args) -> HashSet<SocketAddr> {
|
pub fn return_socket_address(args: &ProcessedArgs) -> HashSet<SocketAddr> {
|
||||||
let mut resolver_ips = HashSet::new();
|
let mut resolver_ips = HashSet::new();
|
||||||
if args.custom_resolvers {
|
if args.custom_resolvers {
|
||||||
for r in &files::return_file_targets(args, args.resolvers.clone()) {
|
for r in &files::return_file_targets(args, args.resolvers.clone()) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
args,
|
args::ProcessedArgs,
|
||||||
errors::Result,
|
errors::Result,
|
||||||
files, logic, networking,
|
files, logic, networking,
|
||||||
nmap::{self, Nmaprun},
|
nmap::{self, Nmaprun},
|
||||||
structs::{Args, ResolvData},
|
structs::ResolvData,
|
||||||
},
|
},
|
||||||
|
hickory_resolver::config::{LookupIpStrategy, ResolverOpts},
|
||||||
log::{error, info},
|
log::{error, info},
|
||||||
prettytable,
|
prettytable,
|
||||||
prettytable::Table,
|
prettytable::Table,
|
||||||
|
|
@ -15,42 +16,35 @@ use {
|
||||||
net::Ipv4Addr,
|
net::Ipv4Addr,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
},
|
},
|
||||||
trust_dns_resolver::{
|
|
||||||
config::{LookupIpStrategy, ResolverOpts},
|
|
||||||
Resolver,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
fn create_resolvers(args: &ProcessedArgs) -> Vec<Ipv4Addr> {
|
||||||
pub static ref RESOLVERS: Vec<Ipv4Addr> = {
|
let mut resolver_ips = Vec::new();
|
||||||
let args = args::get_args();
|
if args.custom_resolvers {
|
||||||
let mut resolver_ips = Vec::new();
|
for r in &files::return_file_targets(args, args.resolvers.clone()) {
|
||||||
if args.custom_resolvers {
|
match r.parse::<Ipv4Addr>() {
|
||||||
for r in &files::return_file_targets(&args, args.resolvers.clone()) {
|
Ok(ip) => resolver_ips.push(ip),
|
||||||
match r.parse::<Ipv4Addr>() {
|
Err(e) => {
|
||||||
Ok(ip) => resolver_ips.push(ip),
|
error!("Error parsing the {r} IP from resolvers file to IP address. Please check and try again. Error: {e}\n");
|
||||||
Err(e) => {
|
std::process::exit(1)
|
||||||
error!("Error parsing the {r} IP from resolvers file to IP address. Please check and try again. Error: {e}\n");
|
|
||||||
std::process::exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for r in args.resolvers {
|
|
||||||
match r.parse::<Ipv4Addr>() {
|
|
||||||
Ok(ip) => resolver_ips.push(ip),
|
|
||||||
Err(e) => {
|
|
||||||
error!("Error parsing the {r} IP from resolvers file to IP address. Please check and try again. Error: {e}\n");
|
|
||||||
std::process::exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolver_ips
|
} else {
|
||||||
};
|
for r in &args.resolvers {
|
||||||
|
match r.parse::<Ipv4Addr>() {
|
||||||
|
Ok(ip) => resolver_ips.push(ip),
|
||||||
|
Err(e) => {
|
||||||
|
error!("Error parsing the {r} IP from resolvers file to IP address. Please check and try again. Error: {e}\n");
|
||||||
|
std::process::exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolver_ips
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
|
pub fn parallel_resolver_all(args: &mut ProcessedArgs) -> Result<()> {
|
||||||
if !files::check_full_path(&args.logs_dir) {
|
if !files::check_full_path(&args.logs_dir) {
|
||||||
error!("The logs directory {} does not exist.\n", args.logs_dir);
|
error!("The logs directory {} does not exist.\n", args.logs_dir);
|
||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
|
|
@ -63,16 +57,14 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let opts = ResolverOpts {
|
let mut opts = ResolverOpts::default();
|
||||||
timeout: Duration::from_secs(1),
|
opts.timeout = Duration::from_secs(1);
|
||||||
ip_strategy: LookupIpStrategy::Ipv4Only,
|
opts.ip_strategy = LookupIpStrategy::Ipv4Only;
|
||||||
num_concurrent_reqs: 1,
|
opts.num_concurrent_reqs = 1;
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let resolver = networking::get_resolver(networking::return_socket_address(args), opts);
|
let resolver = networking::get_resolver(networking::return_socket_address(args), opts);
|
||||||
|
|
||||||
let data = parallel_resolver_engine(args, args.targets.clone(), resolver);
|
let data = parallel_resolver_engine(args, &args.targets, &resolver);
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.set_titles(row![
|
table.set_titles(row![
|
||||||
|
|
@ -202,20 +194,22 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parallel_resolver_engine(
|
fn parallel_resolver_engine(
|
||||||
args: &Args,
|
args: &ProcessedArgs,
|
||||||
targets: HashSet<String>,
|
targets: &HashSet<String>,
|
||||||
resolver: Resolver,
|
resolver: &hickory_resolver::TokioResolver,
|
||||||
) -> HashMap<String, ResolvData> {
|
) -> HashMap<String, ResolvData> {
|
||||||
let resolv_data: HashMap<String, ResolvData> = targets
|
let resolv_data: HashMap<String, ResolvData> = targets
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|target| {
|
.map(|target| {
|
||||||
let fqdn_target = format!("{target}.");
|
let fqdn_target = format!("{target}.");
|
||||||
let mut resolv_data = ResolvData::default();
|
let mut resolv_data = ResolvData::default();
|
||||||
resolv_data.ip = networking::get_records(&resolver, &fqdn_target);
|
resolv_data.ip = networking::get_records(resolver, &fqdn_target);
|
||||||
(target.to_owned(), resolv_data)
|
(target.to_owned(), resolv_data)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let resolvers = create_resolvers(args);
|
||||||
|
|
||||||
let mut nmap_ips: HashSet<String> = resolv_data
|
let mut nmap_ips: HashSet<String> = resolv_data
|
||||||
.values()
|
.values()
|
||||||
.map(|resolv_data| resolv_data.ip.clone())
|
.map(|resolv_data| resolv_data.ip.clone())
|
||||||
|
|
@ -243,6 +237,7 @@ fn parallel_resolver_engine(
|
||||||
&args.min_rate,
|
&args.min_rate,
|
||||||
&args.ports,
|
&args.ports,
|
||||||
args.fast_scan,
|
args.fast_scan,
|
||||||
|
&resolvers,
|
||||||
) {
|
) {
|
||||||
Ok(nmap_data) => {
|
Ok(nmap_data) => {
|
||||||
nmap_data
|
nmap_data
|
||||||
|
|
|
||||||
104
unimap.1
104
unimap.1
|
|
@ -1,81 +1,73 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
|
||||||
.TH UNIMAP "1" "August 2025" "Unimap 0.6.0" "User Commands"
|
.TH UNIMAP "1" "August 2025" "unimap 0.7.0" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Unimap \- manual page for Unimap 0.6.0
|
unimap \- manual page for unimap 0.7.0
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B unimap
|
||||||
|
[\fI\,OPTIONS\/\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Unimap 0.6.0
|
|
||||||
Eduard Tolosa <edu4rdshl@protonmail.com>
|
|
||||||
Scan only once by IP address and reduce scan times with Nmap for large amounts of data.
|
Scan only once by IP address and reduce scan times with Nmap for large amounts of data.
|
||||||
.SS "USAGE:"
|
.SH OPTIONS
|
||||||
.IP
|
|
||||||
unimap [FLAGS] [OPTIONS]
|
|
||||||
.SS "FLAGS:"
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-fast\-scan\fR
|
\fB\-t\fR, \fB\-\-target\fR <TARGET>
|
||||||
Use fast scanning for ports (no version detection).
|
Target host
|
||||||
.TP
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-f\fR, \fB\-\-files\fR <FILES>
|
||||||
Prints help information
|
Use a list of targets written in a file as input
|
||||||
.TP
|
|
||||||
\fB\-k\fR, \fB\-\-no\-keep\-nmap\-logs\fR
|
|
||||||
Keep Nmap XML files created in the logs/ folder for every scanned IP. This data will be
|
|
||||||
useful for other tasks.
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR, \fB\-\-output\fR
|
\fB\-o\fR, \fB\-\-output\fR
|
||||||
Write to an output file. The name of the output file will be unimap\-log\-date.
|
Write to an output file. The name of the output file will be unimap\-log\-date
|
||||||
|
.TP
|
||||||
|
\fB\-u\fR, \fB\-\-unique\-output\fR <UNIQUE_OUTPUT>
|
||||||
|
Write the output in CSV format to the specified filename
|
||||||
.TP
|
.TP
|
||||||
\fB\-q\fR, \fB\-\-quiet\fR
|
\fB\-q\fR, \fB\-\-quiet\fR
|
||||||
Remove informative messages.
|
Remove informative messages
|
||||||
|
.TP
|
||||||
|
\fB\-\-threads\fR <THREADS>
|
||||||
|
Number of threads to use to perform the resolution
|
||||||
|
.TP
|
||||||
|
\fB\-\-resolvers\fR <CUSTOM_RESOLVERS>
|
||||||
|
Path to a file (or files) containing a list of DNS IP address. If no specified then a list of built\-in DNS servers is used
|
||||||
|
.TP
|
||||||
|
\fB\-\-ports\fR <PORTS>
|
||||||
|
Ports to scan. You can specify a range of ports, a list, or both. Put them inside double quotes, for example: "22, 80, 443, 1000\-5000"
|
||||||
|
.TP
|
||||||
|
\fB\-\-min\-rate\fR <MIN_RATE>
|
||||||
|
Nmap \fB\-\-min\-rate\fR value for ports scan
|
||||||
|
.TP
|
||||||
|
\fB\-\-fast\-scan\fR
|
||||||
|
Use fast scanning for ports (no version detection)
|
||||||
|
.TP
|
||||||
|
\fB\-\-logs\-dir\fR <LOGS_DIR>
|
||||||
|
Path to save the CSV data of the process and/or Nmap XML files. Default to logs/ [default: unimap_logs]
|
||||||
|
.TP
|
||||||
|
\fB\-k\fR, \fB\-\-no\-keep\-nmap\-logs\fR
|
||||||
|
Keep Nmap XML files created in the logs/ folder for every scanned IP. This data will be useful for other tasks
|
||||||
.TP
|
.TP
|
||||||
\fB\-r\fR, \fB\-\-raw\-output\fR
|
\fB\-r\fR, \fB\-\-raw\-output\fR
|
||||||
Use raw output instead of a table.
|
Use raw output instead of a table
|
||||||
.TP
|
|
||||||
\fB\-\-stdin\fR
|
|
||||||
Read from stdin instead of files or aguments.
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-url\-output\fR
|
\fB\-\-url\-output\fR
|
||||||
Use HOST:IP output format.
|
Use HOST:IP output format
|
||||||
|
.TP
|
||||||
|
\fB\-\-stdin\fR
|
||||||
|
Read from stdin instead of files or arguments
|
||||||
|
.TP
|
||||||
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
|
Print help
|
||||||
.TP
|
.TP
|
||||||
\fB\-V\fR, \fB\-\-version\fR
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
Prints version information
|
Print version
|
||||||
.SS "OPTIONS:"
|
|
||||||
.TP
|
|
||||||
\fB\-\-resolvers\fR <custom\-resolvers>...
|
|
||||||
Path to a file (or files) containing a list of DNS IP address. If no
|
|
||||||
specified then 1.6k of built\-in valid DNS servers from public\-dns.info are
|
|
||||||
used.
|
|
||||||
.TP
|
|
||||||
\fB\-f\fR, \fB\-\-file\fR <files>...
|
|
||||||
Use a list of targets writen in a file as input.
|
|
||||||
.TP
|
|
||||||
\fB\-\-logs\-dir\fR <logs\-dir>
|
|
||||||
Path to save the CSV data of the process and/or Nmap XML files. Default to
|
|
||||||
logs/.
|
|
||||||
.TP
|
|
||||||
\fB\-\-min\-rate\fR <min\-rate>
|
|
||||||
Nmap \fB\-\-min\-rate\fR value for ports scan.
|
|
||||||
.TP
|
|
||||||
\fB\-\-ports\fR <ports>
|
|
||||||
Ports to scan. You can specify a range of ports, a list, or both. Put them
|
|
||||||
inside double quotes, for example: "22, 80, 443, 1000\-5000"
|
|
||||||
.TP
|
|
||||||
\fB\-t\fR, \fB\-\-target\fR <target>
|
|
||||||
Target host.
|
|
||||||
.TP
|
|
||||||
\fB\-\-threads\fR <threads>
|
|
||||||
Number of threads to use to perform the resolution.
|
|
||||||
.TP
|
|
||||||
\fB\-u\fR, \fB\-\-unique\-output\fR <unique\-output>
|
|
||||||
Write the output in CSV format to the specified filename.
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
The full documentation for
|
The full documentation for
|
||||||
.B Unimap
|
.B unimap
|
||||||
is maintained as a Texinfo manual. If the
|
is maintained as a Texinfo manual. If the
|
||||||
.B info
|
.B info
|
||||||
and
|
and
|
||||||
.B Unimap
|
.B unimap
|
||||||
programs are properly installed at your site, the command
|
programs are properly installed at your site, the command
|
||||||
.IP
|
.IP
|
||||||
.B info Unimap
|
.B info unimap
|
||||||
.PP
|
.PP
|
||||||
should give you access to the complete manual.
|
should give you access to the complete manual.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue