e_libscanner/frame/
mod.rs

1#[doc(hidden)]
2pub mod result;
3use pnet_datalink::MacAddr;
4use std::collections::HashSet;
5use std::net::IpAddr;
6use std::time::Duration;
7
8/// Scan Type
9#[derive(Clone, Debug)]
10pub enum ScanType {
11    /// Default fast port scan type.
12    ///
13    /// Send TCP packet with SYN flag to the target ports and check response.
14    TcpSynScan,
15    /// Attempt TCP connection and check port status.
16    ///
17    /// Slow but can be run without administrator privileges.
18    TcpConnectScan,
19    /// Default host scan type.
20    ///
21    /// Send ICMP echo request and check response.
22    IcmpPingScan,
23    /// Perform host scan for a specific service.
24    ///
25    /// Send TCP packets with SYN flag to a specific port and check response.
26    TcpPingScan,
27    /// Send udp packets;
28    UdpPingScan,
29}
30
31/// Struct of destination information
32///
33/// Destination IP address and ports
34#[derive(Clone, Debug)]
35pub struct Destination {
36    /// Destination IP address
37    pub dst_ip: IpAddr,
38    /// Destination ports
39    pub dst_ports: Vec<u16>,
40}
41
42impl Destination {
43    /// Create new Destination from IP address and ports
44    pub fn new(ip_addr: IpAddr, ports: Vec<u16>) -> Destination {
45        Destination {
46            dst_ip: ip_addr,
47            dst_ports: ports,
48        }
49    }
50    /// Create new Destination with IP address and port range
51    pub fn new_with_port_range(ip_addr: IpAddr, start_port: u16, end_port: u16) -> Destination {
52        let mut ports: Vec<u16> = vec![];
53        for i in start_port..end_port + 1 {
54            ports.push(i);
55        }
56        Destination {
57            dst_ip: ip_addr,
58            dst_ports: ports,
59        }
60    }
61    /// Set destination IP address
62    pub fn set_dst_ip(&mut self, ip_addr: IpAddr) {
63        self.dst_ip = ip_addr;
64    }
65    /// Get destination IP address
66    pub fn get_dst_ip(&self) -> IpAddr {
67        self.dst_ip.clone()
68    }
69    /// Set destination ports
70    pub fn set_dst_port(&mut self, ports: Vec<u16>) {
71        self.dst_ports = ports;
72    }
73    /// Get destination ports
74    pub fn get_dst_port(&self) -> Vec<u16> {
75        self.dst_ports.clone()
76    }
77}
78
79#[derive(Clone, Debug)]
80pub(crate) struct ScanSetting {
81    pub(crate) if_index: u32,
82    #[allow(dead_code)]
83    pub(crate) src_mac: MacAddr,
84    #[allow(dead_code)]
85    pub(crate) dst_mac: MacAddr,
86    pub(crate) src_ip: IpAddr,
87    pub(crate) src_port: u16,
88    pub(crate) destinations: Vec<Destination>,
89    pub(crate) ip_set: HashSet<IpAddr>,
90    pub(crate) timeout: Duration,
91    pub(crate) wait_time: Duration,
92    #[allow(dead_code)]
93    pub(crate) send_rate: Duration,
94    pub(crate) scan_type: ScanType,
95    #[allow(dead_code)]
96    pub(crate) hosts_concurrency: usize,
97    #[allow(dead_code)]
98    pub(crate) ports_concurrency: usize,
99}