pub struct Opts {
pub ips: Vec<String>,
pub ports: Vec<String>,
pub src_ip: String,
pub timeout: u64,
pub wait_time: u64,
pub rate: u64,
pub scan: ScanOrderType,
pub model: ScanModelType,
pub scripts: ScriptsRequired,
pub no_gui: bool,
pub verbose: u8,
pub command: Vec<String>,
}Expand description
Opts
§Examples
use e_libscanner::Opts;
fn main() -> Result<(), String> {
// more command information use: -h
let opts = Opts::new(Some(&[
"e-libscanner",
"--ips",
"192.168.9.8",
"192.168.1.0/23",
"192.168.10-11.0-254",
"--ports",
"80",
"22",
// "--src-ip",
// "127.0.0.1",
"--timeout",
"3000",
"--wait-time",
"1000",
"--rate",
"0",
"--model",
"os",
"--scan",
"tcp",
"--scripts",
"default",
"--no-gui",
"-vvv",
"--",
"-AS",
]))?
.init()?;
println!("{:?}", opts);
Ok(())
}Fields§
§ips: Vec<String>host list; example: “192.168.1.1”, “192.168.1.0/24”, “192.168.8-9.80-100”, “baidu.com”
ports: Vec<String>port list; Example: 80,443,8080,100-1000.
src_ip: Stringuse it ip match network interface of hardware;
timeout: u64The timeout in milliseconds before a port is assumed to be closed; default is 3_600_000ms
wait_time: u64Waiting time after packet sending task is completed; default is 3000ms
rate: u64Packet sending interval(0 for unlimited); default is 0
scan: ScanOrderTypesend type; [ Icmp, TcpConnect, Udp, Tcp, TcpSyn]; default: None;
model: ScanModelTypescan type; [ Sync, Async, Os, Service, Dns, Traceroute ]; default: sync
scripts: ScriptsRequiredscripts
no_gui: boolno gui window
verbose: u8Verbose mode (-v, -vv, -vvv, etc.)
command: Vec<String>Extend command; example: e-libscanner –ips baidu.com 192.168.1.0/24 –model sync –scan icmp –no-gui – -AS commads: – -AS: ARP Spoofing,
Implementations§
Source§impl Opts
impl Opts
Sourcepub fn new<I>(args: Option<I>) -> Result<Self, String>
pub fn new<I>(args: Option<I>) -> Result<Self, String>
§Example
let mut scanner = Opts::new(Some(&[
"e-libscanner",
"--ips",
"192.168.80.0/21",
"192.168.20-21.15-20",
"baidu.com",
"--model",
"sync",
"--scan",
"Icmp",
"--no-gui",
"--",
"-AS",
]))
.init()?
.downcast::<sync_scan::Scanner>()
.unwrap();
let rx = scanner.get_progress_receiver();
// 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();
// Print results
println!("Status: {:?}", result.scan_status);
println!("UP Hosts:");
let len = result.ips.len();
for host in result.ips {
println!("{:?}", host);
}
println!("Scan Time: {:?} count[ {} ]", result.scan_time, len);Trait Implementations§
Source§impl StructOpt for Opts
impl StructOpt for Opts
Source§fn from_clap(matches: &ArgMatches<'_>) -> Self
fn from_clap(matches: &ArgMatches<'_>) -> Self
Builds the struct from
clap::ArgMatches. It’s guaranteed to succeed
if matches originates from an App generated by StructOpt::clap called on
the same type, otherwise it must panic.Source§fn from_args() -> Selfwhere
Self: Sized,
fn from_args() -> Selfwhere
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os).
Calls clap::Error::exit on failure, printing the error message and aborting the program.Source§fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os).
Unlike StructOpt::from_args, returns clap::Error on failure instead of aborting the program,
so calling .exit is up to you.Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Gets the struct from any iterator such as a
Vec of your making.
Print the error message and quit the program in case of failure. Read moreAuto Trait Implementations§
impl Freeze for Opts
impl RefUnwindSafe for Opts
impl Send for Opts
impl Sync for Opts
impl Unpin for Opts
impl UnwindSafe for Opts
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> 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