From a28925ebca89d5bf145237b1aed81c6cf616ceb2 Mon Sep 17 00:00:00 2001 From: Mohamed Elbadry Date: Fri, 10 Sep 2021 08:49:55 +0200 Subject: [PATCH] Update dangling detection --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 38 +++++++++++++++++++++++++------------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa5976e..06b1dbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -765,7 +765,7 @@ dependencies = [ [[package]] name = "sslenum" -version = "1.0.0" +version = "1.0.1" dependencies = [ "addr", "clap", diff --git a/Cargo.toml b/Cargo.toml index d2341ce..b0ef10c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sslenum" -version = "1.0.0" +version = "1.0.1" authors = ["melbadry9 "] edition = "2018" description = "SSL certificate Extractor" diff --git a/src/main.rs b/src/main.rs index 10976a5..9a183c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,25 +24,37 @@ struct DomainData { impl DomainData { fn check_dangling(self: &mut Self) { let domain = List.parse_dns_name(self.hostname.as_str()).unwrap(); - let host = List.parse_dns_name(self.cn[0].as_str()); - match host { - Ok(host) => { - let host_root = host.root(); - match host_root { - Some(host_root) => { - if !(domain.root().unwrap() == host_root) { + let mut dns_names: Vec = Vec::new(); + + dns_names.extend(self.cn.clone()); + dns_names.extend(self.alt_names.clone()); + + for cand in dns_names { + let host = List.parse_dns_name(cand.as_str()); + match host { + Ok(host) => { + let host_root = host.root(); + match host_root { + Some(host_root) => { + if !(domain.root().unwrap() == host_root) { + self.dangling = true; + } else { + self.dangling = false; + break; + } + } + None => { self.dangling = true; } } - None => { - self.dangling = true; - } + } + Err(_) => { + self.dangling = false; } } - Err(_) => { - self.dangling = false; - } + } + } }