Cross-platform network scan library
with the aim of being lightweight and fast.
Add netscan
to your dependencies
toml:Cargo.toml
[dependencies]
netscan = "0.7.0"
Port Scan Example ```rust extern crate netscan; 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), }; 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); portscanner.setscantype(ScanType::TcpSynScan); portscanner.settimeout(Duration::frommillis(10000)); portscanner.setwaittime(Duration::frommillis(100)); portscanner.runscan(); let result = portscanner.getscanresult(); println!("Status: {:?}", result.scanstatus); println!("Open Ports:"); for port in result.ports { println!("{:?}", port); } println!("Scan Time: {:?}", result.scantime); } ```
For more details see Examples
This library requires the ability to create raw sockets. Execute with administrator privileges.