1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::net::IpAddr;
use std::time::Duration;
use std::collections::HashSet;
use pnet_datalink::MacAddr;
pub(crate) const DEFAULT_SRC_PORT: u16 = 53443;
pub(crate) const DEFAULT_HOSTS_CONCURRENCY: usize = 50;
pub(crate) const DEFAULT_PORTS_CONCURRENCY: usize = 100;
#[derive(Clone, Debug)]
pub enum ScanType {
TcpSynScan,
TcpConnectScan,
IcmpPingScan,
TcpPingScan,
UdpPingScan,
}
#[derive(Clone, Debug)]
pub struct Destination {
pub dst_ip: IpAddr,
pub dst_ports: Vec<u16>,
}
impl Destination {
pub fn new(ip_addr: IpAddr, ports: Vec<u16>) -> Destination {
Destination {
dst_ip: ip_addr,
dst_ports: ports,
}
}
pub fn new_with_port_range(ip_addr: IpAddr, start_port: u16, end_port: u16) -> Destination {
let mut ports: Vec<u16> = vec![];
for i in start_port..end_port + 1 {
ports.push(i);
}
Destination {
dst_ip: ip_addr,
dst_ports: ports,
}
}
pub fn set_dst_ip(&mut self, ip_addr: IpAddr) {
self.dst_ip = ip_addr;
}
pub fn get_dst_ip(&self) -> IpAddr {
self.dst_ip.clone()
}
pub fn set_dst_port(&mut self, ports: Vec<u16>) {
self.dst_ports = ports;
}
pub fn get_dst_port(&self) -> Vec<u16> {
self.dst_ports.clone()
}
}
#[derive(Clone, Debug)]
pub(crate) struct ScanSetting {
pub if_index: u32,
#[allow(dead_code)]
pub src_mac: MacAddr,
#[allow(dead_code)]
pub dst_mac: MacAddr,
pub src_ip: IpAddr,
pub src_port: u16,
pub destinations: Vec<Destination>,
pub ip_set: HashSet<IpAddr>,
pub timeout: Duration,
pub wait_time: Duration,
pub send_rate: Duration,
pub scan_type: ScanType,
#[allow(dead_code)]
pub hosts_concurrency: usize,
#[allow(dead_code)]
pub ports_concurrency: usize,
}