Opts

Struct Opts 

Source
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: String

use it ip match network interface of hardware;

§timeout: u64

The timeout in milliseconds before a port is assumed to be closed; default is 3_600_000ms

§wait_time: u64

Waiting time after packet sending task is completed; default is 3000ms

§rate: u64

Packet sending interval(0 for unlimited); default is 0

§scan: ScanOrderType

send type; [ Icmp, TcpConnect, Udp, Tcp, TcpSyn]; default: None;

§model: ScanModelType

scan type; [ Sync, Async, Os, Service, Dns, Traceroute ]; default: sync

§scripts: ScriptsRequired

scripts

§no_gui: bool

no gui window

§verbose: u8

Verbose 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

Source

pub fn new<I>(args: Option<I>) -> Result<Self, String>
where Self: Sized, I: IntoIterator, I::Item: Into<OsString> + Clone,

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

impl Opts

Source

pub fn init(&self) -> Result<Box<dyn Any>, String>

init opts data

Trait Implementations§

Source§

impl Debug for Opts

Source§

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

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

impl StructOpt for Opts

Source§

fn clap<'a, 'b>() -> App<'a, 'b>

Returns clap::App corresponding to the struct.
Source§

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() -> Self
where 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,

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
where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,

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

fn from_iter_safe<I>(iter: I) -> Result<Self, Error>
where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,

Gets the struct from any iterator such as a Vec of your making. Read more

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V