netscan Crates.io License

Cross-platform network scan library
with the aim of being lightweight and fast.

Features

Usage

Add netscan to your dependencies
toml:Cargo.toml [dependencies] netscan = "0.13.0"

Example

Port Scan Example ```rust use netscan::blocking::PortScanner; use netscan::setting::{ScanType, Destination}; use std::time::Duration; use std::net::{IpAddr, Ipv4Addr};

fn main() { let mut portscanner = match PortScanner::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 4))) { Ok(scanner) => (scanner), Err(e) => panic!("Error creating scanner: {}", e), }; // Add scan target let dstip: IpAddr = IpAddr::V4(Ipv4Addr::new(192, 168, 1, 8)); //let dst: Destination = Destination::new(dstip, vec![22, 80, 443]); let dst: Destination = Destination::newwithportrange(dstip, 1, 1000); portscanner.adddestination(dst); // Set options portscanner.setscantype(ScanType::TcpSynScan); portscanner.settimeout(Duration::frommillis(10000)); portscanner.setwaittime(Duration::frommillis(100)); //portscanner.setsendrate(Duration::frommillis(1)); // Run scan let result = portscanner.scan(); // Print results println!("Status: {:?}", result.scanstatus); println!("Results:"); for (ip, ports) in result.resultmap { println!("{}", ip); for port in ports { println!("{:?}", port); } } println!("Scan Time: {:?}", result.scan_time); } ```

Feature flags

The following feature flags can be used to enable/disable specific features.

--feature async

Enable async scanning.(Default feature)

--feature service

Enable service detection. (Experimental)

--feature os

Enable TCP/IP Stack Fingerprinting. (Experimental)

--feature full

Enable all of the above.

For more details see Examples

Supported platform

Note for Windows users

To build libpnet on Windows, follow the instructions below.

Windows

Source

Additional Notes

This library requires the ability to create raw sockets. Execute with administrator privileges.