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.2.0"

Example

Port Scan Example ```rust extern crate netscan; use netscan::PortScanner; use netscan::PortScanType; use netscan::ScanStatus; use std::time::Duration;

fn main() { let mut portscanner = match PortScanner::new(None) { Ok(scanner) => (scanner), Err(e) => panic!("Error creating scanner: {}", e), }; portscanner.settargetipaddr("192.168.1.8"); portscanner.setrange(1, 1024); //portscanner.addtargetport(22); //portscanner.addtargetport(80); //portscanner.addtargetport(443); portscanner.setscantype(PortScanType::SynScan); portscanner.settimeout(Duration::frommillis(10000)); //portscanner.setwaittime(Duration::frommillis(10)); portscanner.runscan(); let result = portscanner.getresult(); print!("Status: "); match result.scanstatus { ScanStatus::Done => {println!("Normal end")}, ScanStatus::Timeout => {println!("Timed out")}, _ => {println!("Error")}, } println!("Open Ports:"); for port in result.openports { println!("{}", port); } println!("Scan Time: {:?}", result.scantime); match portscanner.getscantype() { PortScanType::ConnectScan => {}, _=> { if portscanner.getwaittime() > Duration::frommillis(0) { println!("(Including {:?} of wait time)", portscanner.getwaittime()); } }, } } ```

For more details see Examples

Supported platform

Additional Notes

This library requires the ability to create raw sockets. Execute with administrator privileges.
(The default SYN SCAN is recommended, but CONNECT SCAN without administrator privileges is also possible.)