(chore): bump dependencies and adapt code to new ones

This commit is contained in:
Eduard Tolosa 2025-08-02 15:11:48 -05:00
parent a6c166e470
commit c6a06db04b
5 changed files with 1316 additions and 647 deletions

1677
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package]
name = "unimap"
version = "0.6.0"
version = "0.7.0"
authors = ["Eduard Tolosa <edu4rdshl@protonmail.com>"]
edition = "2018"
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
[dependencies]
trust-dns-resolver = "0.20.4"
hickory-resolver = "0.25.2"
rayon = "1.10.0"
log = { version = "0.4.27", features = ["std"] }
colored = { version = "2.2.0", optional = true }
rand = "0.8.5"
colored = { version = "3.0.0", optional = true }
rand = "0.9.2"
lazy_static = "1.5.0"
tokio = { version = "1.47.0", features = ["rt"] }
futures = "0.3"
serde = { version = "1.0.219", features = ["derive"] }
serde_derive = "1.0.219"
prettytable-rs = "0.8.0"
serde-xml-rs = "0.5.1"
chrono = "0.4.40"
clap = { version = "2.34.0", features = ["yaml"] }
config = { version = "0.11.0", features = [
"yaml",
"json",
"toml",
"hjson",
"ini",
] }
prettytable-rs = "0.10.0"
serde-xml-rs = "0.8.1"
chrono = "0.4.41"
clap = { version = "4.5.42", features = ["derive"] }
config = { version = "0.15.13", features = ["yaml", "json", "toml", "ini"] }
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]
openssl = { version = "0.10.72", features = ["vendored"] }
openssl = { version = "0.10.73", features = ["vendored"] }
[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]
openssl = { version = "0.10.72", features = ["vendored"] }
openssl = { version = "0.10.73", features = ["vendored"] }
[target.'cfg(windows)'.dependencies]
atty = "0.2.14"
@ -55,5 +47,4 @@ winapi = { version = "0.3.9", features = ["handleapi", "winbase"] }
lto = true
codegen-units = 1
panic = 'abort'
incremental = false
opt-level = "s"
strip = true

View file

@ -1,43 +1,43 @@
use {
crate::{files, structs::Args},
std::{collections::HashSet, net::SocketAddr},
trust_dns_resolver::{
config::{NameServerConfig, NameServerConfigGroup, Protocol, ResolverConfig, ResolverOpts},
Resolver,
crate::{args::ProcessedArgs, files},
hickory_resolver::{
config::{NameServerConfig, NameServerConfigGroup, ResolverConfig, ResolverOpts},
name_server::TokioConnectionProvider,
proto::xfer::Protocol,
TokioResolver,
},
std::{collections::HashSet, net::SocketAddr},
};
pub fn get_records(resolver: &Resolver, domain: &str) -> String {
if let Ok(ips) = resolver.ipv4_lookup(domain) {
pub fn get_records(resolver: &TokioResolver, domain: &str) -> String {
futures::executor::block_on(resolver.ipv4_lookup(domain)).map_or_else(
|_| String::new(),
|ips| {
ips.iter()
.map(std::string::ToString::to_string)
.next()
.expect("Failed to get IPV4.")
} else {
String::new()
}
},
)
}
pub fn get_resolver(nameserver_ips: HashSet<SocketAddr>, opts: ResolverOpts) -> Resolver {
let mut name_servers = NameServerConfigGroup::with_capacity(nameserver_ips.len() * 2);
name_servers.extend(nameserver_ips.into_iter().flat_map(|socket_addr| {
std::iter::once(NameServerConfig {
socket_addr,
protocol: Protocol::Udp,
tls_dns_name: None,
trust_nx_responses: false,
})
.chain(std::iter::once(NameServerConfig {
socket_addr,
protocol: Protocol::Tcp,
tls_dns_name: None,
trust_nx_responses: false,
}))
}));
Resolver::new(ResolverConfig::from_parts(None, vec![], name_servers), opts).unwrap()
pub fn get_resolver(nameserver_ips: HashSet<SocketAddr>, opts: ResolverOpts) -> TokioResolver {
let mut name_servers = NameServerConfigGroup::with_capacity(nameserver_ips.len());
name_servers.extend(
nameserver_ips
.into_iter()
.map(|socket_addr| NameServerConfig::new(socket_addr, Protocol::Udp)),
);
TokioResolver::builder_with_config(
ResolverConfig::from_parts(None, vec![], name_servers),
TokioConnectionProvider::default(),
)
.with_options(opts)
.build()
}
pub fn return_socket_address(args: &Args) -> HashSet<SocketAddr> {
pub fn return_socket_address(args: &ProcessedArgs) -> HashSet<SocketAddr> {
let mut resolver_ips = HashSet::new();
if args.custom_resolvers {
for r in &files::return_file_targets(args, args.resolvers.clone()) {

View file

@ -1,11 +1,12 @@
use {
crate::{
args,
args::ProcessedArgs,
errors::Result,
files, logic, networking,
nmap::{self, Nmaprun},
structs::{Args, ResolvData},
structs::ResolvData,
},
hickory_resolver::config::{LookupIpStrategy, ResolverOpts},
log::{error, info},
prettytable,
prettytable::Table,
@ -15,18 +16,12 @@ use {
net::Ipv4Addr,
time::Duration,
},
trust_dns_resolver::{
config::{LookupIpStrategy, ResolverOpts},
Resolver,
},
};
lazy_static! {
pub static ref RESOLVERS: Vec<Ipv4Addr> = {
let args = args::get_args();
fn create_resolvers(args: &ProcessedArgs) -> Vec<Ipv4Addr> {
let mut resolver_ips = Vec::new();
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()) {
match r.parse::<Ipv4Addr>() {
Ok(ip) => resolver_ips.push(ip),
Err(e) => {
@ -36,7 +31,7 @@ lazy_static! {
}
}
} else {
for r in args.resolvers {
for r in &args.resolvers {
match r.parse::<Ipv4Addr>() {
Ok(ip) => resolver_ips.push(ip),
Err(e) => {
@ -47,10 +42,9 @@ lazy_static! {
}
}
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) {
error!("The logs directory {} does not exist.\n", args.logs_dir);
std::process::exit(1)
@ -63,16 +57,14 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
);
}
let opts = ResolverOpts {
timeout: Duration::from_secs(1),
ip_strategy: LookupIpStrategy::Ipv4Only,
num_concurrent_reqs: 1,
..Default::default()
};
let mut opts = ResolverOpts::default();
opts.timeout = Duration::from_secs(1);
opts.ip_strategy = LookupIpStrategy::Ipv4Only;
opts.num_concurrent_reqs = 1;
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();
table.set_titles(row![
@ -202,20 +194,22 @@ pub fn parallel_resolver_all(args: &mut Args) -> Result<()> {
}
fn parallel_resolver_engine(
args: &Args,
targets: HashSet<String>,
resolver: Resolver,
args: &ProcessedArgs,
targets: &HashSet<String>,
resolver: &hickory_resolver::TokioResolver,
) -> HashMap<String, ResolvData> {
let resolv_data: HashMap<String, ResolvData> = targets
.par_iter()
.map(|target| {
let fqdn_target = format!("{target}.");
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)
})
.collect();
let resolvers = create_resolvers(args);
let mut nmap_ips: HashSet<String> = resolv_data
.values()
.map(|resolv_data| resolv_data.ip.clone())
@ -243,6 +237,7 @@ fn parallel_resolver_engine(
&args.min_rate,
&args.ports,
args.fast_scan,
&resolvers,
) {
Ok(nmap_data) => {
nmap_data

104
unimap.1
View file

@ -1,81 +1,73 @@
.\" 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
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
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.
.SS "USAGE:"
.IP
unimap [FLAGS] [OPTIONS]
.SS "FLAGS:"
.SH OPTIONS
.TP
\fB\-\-fast\-scan\fR
Use fast scanning for ports (no version detection).
\fB\-t\fR, \fB\-\-target\fR <TARGET>
Target host
.TP
\fB\-h\fR, \fB\-\-help\fR
Prints help information
.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.
\fB\-f\fR, \fB\-\-files\fR <FILES>
Use a list of targets written in a file as input
.TP
\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
\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
\fB\-r\fR, \fB\-\-raw\-output\fR
Use raw output instead of a table.
.TP
\fB\-\-stdin\fR
Read from stdin instead of files or aguments.
Use raw output instead of a table
.TP
\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
\fB\-V\fR, \fB\-\-version\fR
Prints version information
.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.
Print version
.SH "SEE ALSO"
The full documentation for
.B Unimap
.B unimap
is maintained as a Texinfo manual. If the
.B info
and
.B Unimap
.B unimap
programs are properly installed at your site, the command
.IP
.B info Unimap
.B info unimap
.PP
should give you access to the complete manual.