qscan

Crates.ioqscan
lib.rsqscan
version0.6.0
sourcesrc
created_at2022-05-10 22:13:11.78135
updated_at2022-06-13 17:44:23.278732
descriptionQuick async network scan library
homepagehttps://github.com/0xor0ne/qscan
repositoryhttps://github.com/0xor0ne/qscan
max_upload_size
id584208
size109,821
0xor0ne (0xor0ne)

documentation

https://docs.rs/qscan

README

Quick Network Scanner Library

Rust library for scanning network hosts asynchronously.

Currently, the following scan modes are supported:

  • TCP Connect;
  • Ping (ICMP Echo / Echo Reply).

NOTE: in order to properly use the library you may need to increase the maximum allowed open files. E.g.:

ulimit -n 10000

NOTE: for the ping scan mode, you need root or other proper permissions (i.e. CAP_NET_RAW).

See the library on crates.io.

Usage

Dependencies (Cargo.toml):

[dependencies]
qscan = "0.6.0"
tokio = { version = "1", features = ["rt-multi-thread"] }

Alternatively, in order enable json serialization of results structures, activate serialize feature:

[dependencies]
qscan = { version = "0.6.0" , features = ["serialize"] }
tokio = { version = "1", features = ["rt-multi-thread"] }

and then (src/main.rs):

From TCP connect scan example

use qscan::{QSPrintMode, QScanResult, QScanTcpConnectState, QScanType, QScanner};
use tokio::runtime::Runtime;

pub fn main() {
    let mut scanner = QScanner::new("8.8.8.8,127.0.0.1", "53,80,443");
    scanner.set_batch(5000);
    scanner.set_timeout_ms(2000);
    scanner.set_ntries(1);
    scanner.set_scan_type(QScanType::TcpConnect);
    scanner.set_print_mode(QSPrintMode::NonRealTime);

    let res: &Vec<QScanResult> = Runtime::new().unwrap().block_on(scanner.scan_tcp_connect());

    for r in res {
        if let QScanResult::TcpConnect(sa) = r {
            if sa.state == QScanTcpConnectState::Open {
                println!("{}", sa.target);
            }
        }
    }
}

See also the provided ping example and qsc utility.

Commit count: 36

cargo fmt