#[non_exhaustive]pub enum ServiceDetection {
Off,
Banner,
Probe,
Thorough,
}Expand description
How far a scan may go to identify what is listening behind an open port.
The port scan establishes that a port is open; naming what is on it is a second pass that needs a real connection to every open port. A scan mapping what exists may not want that cost; a scan auditing what is deployed does.
Ordered by what each level puts on the wire.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Off
Level 0. Do not connect. A port keeps whatever its number implies and nothing more.
The fastest and quietest: after a raw scan no connection is completed, so
nothing appears in the target’s logs. It yields no versions or products: a port
is reported open http because it is port 80, whatever is actually there.
Banner
Level 1. Connect and listen. Send nothing.
For services that greet on connect, such as SSH, SMTP, FTP and IRC, this learns what a probe would, without sending a byte. For everything else it establishes only that the port accepts connections.
Use it against equipment that must not be sent anything unexpected. Industrial controllers, medical devices and old embedded stacks have been knocked over by well-formed requests they did not anticipate.
Probe
Level 2, and the default. Connect, listen, and ask.
Sends each port the probes its service registered and, where nothing registers the port, one generic request. That identifies the long tail: an open port on an unregistered number is most often an HTTP server, and one request names it.
A port that answers none of that, in the clear or through TLS, is then asked
the likeliest of the questions other services registered, the bottom of the
scale probe_intensity reaches. Such a port is most
often a database moved off its number, which speaks only when spoken to in its
own protocol. Each question costs a connection and a read. Across a path slower
than a third of a second only the likeliest is asked.
The default because it is the most informative level and, against an unrecognised port, the fastest: waiting for a greeting that never comes and then trying TLS costs two seconds per port, where asking gets an answer in a round trip.
Thorough
Level 3. Everything above, and then every question the corpus has.
A port that stayed silent through everything else gets every probe authored for other services, in rarity order. That reaches a service which speaks only when spoken to, is off its registered port, and is rarer than the default’s guesses.
Costs a connection and a round trip per probe, paid only where everything else drew a blank, which on an ordinary host is a port or two.
Implementations§
Source§impl ServiceDetection
impl ServiceDetection
Sourcepub const ALL: &'static [Self]
pub const ALL: &'static [Self]
Every level, ordered from least effort to most. The index of a level in
this array is its level number.
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The name this level is written under, wherever it arrives as text.
Sourcepub const fn level(self) -> u8
pub const fn level(self) -> u8
The number this level is written as, for a front end that offers it as a dial.
Sourcepub const fn from_level(level: u8) -> Option<Self>
pub const fn from_level(level: u8) -> Option<Self>
The level with this number, or None past the highest there is.
Sourcepub const fn connects(self) -> bool
pub const fn connects(self) -> bool
Whether this level opens a connection at all.
Below this boundary the scan leaves no trace in application logs; at or above it every open port records a connection.
use zond_engine::config::ServiceDetection;
assert!(!ServiceDetection::Off.connects());
assert!(ServiceDetection::default().connects());Sourcepub const fn sends(self) -> bool
pub const fn sends(self) -> bool
Whether this level sends anything once connected.
use zond_engine::config::ServiceDetection;
assert!(!ServiceDetection::Banner.sends());
assert!(ServiceDetection::Probe.sends());Sourcepub const fn probe_intensity(self) -> u8
pub const fn probe_intensity(self) -> u8
How far up the corpus’s rarity scale this level reaches, for a probe nothing registered against the port being asked.
The scale runs 1 to 9 and is the one the imported corpora are authored
on; see Probe::rarity. Zero
reaches nothing, which is what every level below Probe wants.
The default reaches 1, the questions a port silent to everything else most often answers, and the thorough level the whole scale. The default stops at 1 because only the bottom of the scale is authored so far; it can rise as the corpus fills in.
use zond_engine::config::ServiceDetection;
assert_eq!(ServiceDetection::Banner.probe_intensity(), 0);
assert_eq!(ServiceDetection::Thorough.probe_intensity(), 9);Trait Implementations§
Source§impl Clone for ServiceDetection
impl Clone for ServiceDetection
impl Copy for ServiceDetection
Source§impl Debug for ServiceDetection
impl Debug for ServiceDetection
Source§impl Default for ServiceDetection
impl Default for ServiceDetection
Source§impl Display for ServiceDetection
impl Display for ServiceDetection
impl Eq for ServiceDetection
Source§impl FromStr for ServiceDetection
impl FromStr for ServiceDetection
Source§fn from_str(input: &str) -> Result<Self, Self::Err>
fn from_str(input: &str) -> Result<Self, Self::Err>
Parses a level by name or by number, ignoring case and surrounding whitespace.
use zond_engine::config::ServiceDetection;
assert_eq!("banner".parse(), Ok(ServiceDetection::Banner));
assert_eq!("0".parse(), Ok(ServiceDetection::Off));
assert_eq!("3".parse(), Ok(ServiceDetection::Thorough));
assert!("exhaustive".parse::<ServiceDetection>().is_err());Source§type Err = UnknownServiceDetection
type Err = UnknownServiceDetection
Source§impl Hash for ServiceDetection
impl Hash for ServiceDetection
Source§impl Ord for ServiceDetection
impl Ord for ServiceDetection
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ServiceDetection
impl PartialEq for ServiceDetection
Source§impl PartialOrd for ServiceDetection
impl PartialOrd for ServiceDetection
impl StructuralPartialEq for ServiceDetection
Auto Trait Implementations§
impl Freeze for ServiceDetection
impl RefUnwindSafe for ServiceDetection
impl Send for ServiceDetection
impl Sync for ServiceDetection
impl Unpin for ServiceDetection
impl UnsafeUnpin for ServiceDetection
impl UnwindSafe for ServiceDetection
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more