pub struct ServiceDetector {
pub dst_ip: IpAddr,
pub dst_name: String,
pub open_ports: Vec<u16>,
pub connect_timeout: Duration,
pub read_timeout: Duration,
pub accept_invalid_certs: bool,
}Available on crate feature
service only.Expand description
Struct for service detection
§Example
fn main() -> Result<(), String> {
#[cfg(feature = "service")]
{
use e_libscanner::service::{self, PortDatabase, ServiceDetector};
use e_libscanner::Opts;
use std::thread;
// more command information use: -h
let mut scanner = Opts::new(Some(&[
"e-libscanner",
"--ips",
"192.168.80.10",
"--ports",
"8000",
"8080",
"20-100",
"--rate",
"1",
"--model",
"service",
"--scan",
"tcpsyn",
"--no-gui",
]))?
.init()?
.downcast::<service::Scanner>()
.unwrap();
let rx = scanner.get_progress_receiver();
let time = std::time::Instant::now();
// Run scan
let handle = thread::spawn(move || scanner.scan(None));
// Print progress
while let Ok(socket_addr) = rx.lock().unwrap().recv() {
println!("Check: {}", socket_addr);
}
let result = handle.join().unwrap();
for (ip, _ports) in result.ip_with_port.clone() {
let mut service_detector = ServiceDetector::new();
service_detector.set_dst_ip(ip);
service_detector.set_open_ports(result.get_open_ports(ip));
println!("{}", service_detector.scan(Some(PortDatabase::default())));
}
println!("time -> {}/s", time.elapsed().as_secs_f64());
}
Ok(())
}Fields§
§dst_ip: IpAddrDestination IP address
dst_name: StringDestination Host Name
open_ports: Vec<u16>Target ports for service detection
connect_timeout: DurationTCP connect (open) timeout
read_timeout: DurationTCP read timeout
accept_invalid_certs: boolSSL/TLS certificate validation when detecting HTTPS services.
Default value is false, which means validation is enabled.
Implementations§
Source§impl ServiceDetector
impl ServiceDetector
Sourcepub fn new() -> ServiceDetector
pub fn new() -> ServiceDetector
Create new ServiceDetector
Sourcepub fn set_dst_ip(&mut self, dst_ip: IpAddr)
pub fn set_dst_ip(&mut self, dst_ip: IpAddr)
Set Destination IP address
Sourcepub fn set_dst_name(&mut self, host_name: IpAddr)
pub fn set_dst_name(&mut self, host_name: IpAddr)
Set Destination Host Name
Sourcepub fn set_open_ports(&mut self, open_ports: Vec<u16>)
pub fn set_open_ports(&mut self, open_ports: Vec<u16>)
Set target ports
Sourcepub fn add_open_port(&mut self, open_port: u16)
pub fn add_open_port(&mut self, open_port: u16)
Add target port
Sourcepub fn set_connect_timeout(&mut self, connect_timeout: Duration)
pub fn set_connect_timeout(&mut self, connect_timeout: Duration)
Set connect (open) timeout
Sourcepub fn set_read_timeout(&mut self, read_timeout: Duration)
pub fn set_read_timeout(&mut self, read_timeout: Duration)
Set TCP read timeout
Sourcepub fn set_accept_invalid_certs(&mut self, accept_invalid_certs: bool)
pub fn set_accept_invalid_certs(&mut self, accept_invalid_certs: bool)
Set SSL/TLS certificate validation enable/disable.
Trait Implementations§
Source§impl Clone for ServiceDetector
impl Clone for ServiceDetector
Source§fn clone(&self) -> ServiceDetector
fn clone(&self) -> ServiceDetector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ServiceDetector
impl RefUnwindSafe for ServiceDetector
impl Send for ServiceDetector
impl Sync for ServiceDetector
impl Unpin for ServiceDetector
impl UnwindSafe for ServiceDetector
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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