Skip to main content

ServiceDetection

Enum ServiceDetection 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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.

Source

pub const fn name(self) -> &'static str

The name this level is written under, wherever it arrives as text.

Source

pub const fn level(self) -> u8

The number this level is written as, for a front end that offers it as a dial.

Source

pub const fn from_level(level: u8) -> Option<Self>

The level with this number, or None past the highest there is.

Source

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());
Source

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());
Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ServiceDetection

Source§

impl Debug for ServiceDetection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServiceDetection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for ServiceDetection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ServiceDetection

Source§

impl FromStr for ServiceDetection

Source§

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

The associated error which can be returned from parsing.
Source§

impl Hash for ServiceDetection

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ServiceDetection

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for ServiceDetection

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ServiceDetection

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ServiceDetection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more