Expand description
Asphyxia - A fast and efficient network scanner
This library provides high-performance network scanning capabilities for both port scanning and address scanning operations. It’s designed to be efficient, reliable, and easy to use.
§Features
- Port Scanning: Scan individual ports or ranges of ports on target hosts
- Address Scanning: Check host availability and scan IP ranges
- Subnet Scanning: Scan entire subnets for available hosts
- Utility Functions: Helper functions for parsing ports, IPs, and subnets
§Module Organization
scanner::port: Port scanning functionalityscanner::address: Address and subnet scanning functionalityutils: Utility functions for parsing and validationcli: Command-line interface implementation
§Examples
§Basic Port Scanning
use asphyxia::scan_port;
// Scan a single port (default timeout)
if let Some(hit) = scan_port("example.com".to_string(), 80, None) {
println!("Port {} is open ({} ms)", hit.port, hit.latency.as_millis());
}
// Scan multiple ports
let ports = vec![80, 443, 8080];
for port in ports {
if let Some(hit) = scan_port("example.com".to_string(), port, None) {
println!("Port {} is open", hit.port);
}
}§Address and Subnet Scanning
use asphyxia::{scan_address, scan_subnet, scan_ip_range};
use std::net::IpAddr;
use std::time::Duration;
// Check if a host is available (IPv4 or IPv6)
let ip: IpAddr = "192.168.1.1".parse().unwrap();
let timeout = Duration::from_secs(1);
if let Some(_) = scan_address(ip, Some(timeout)) {
println!("Host is available");
}
// Scan a subnet
let subnet = "192.168.1.0/24".parse().unwrap();
let available_hosts = scan_subnet(subnet, None);
println!("Found {} available hosts", available_hosts.len());
// Scan an IP range
let start: IpAddr = "192.168.1.1".parse().unwrap();
let end: IpAddr = "192.168.1.10".parse().unwrap();
let hosts = scan_ip_range(start, end, None);
println!("Found {} hosts in range", hosts.len());§Using Utility Functions
use asphyxia::{parse_ports, parse_ip, parse_subnet};
// Parse port ranges
let ports = parse_ports("80,443,8000,8080").unwrap();
println!("Ports to scan: {:?}", ports);
// Parse IP address (IPv4 or IPv6)
let ip = parse_ip("2001:db8::1").unwrap();
println!("IP address: {}", ip);
// Parse subnet
let subnet = parse_subnet("192.168.1.0/24").unwrap();
println!("Subnet: {}", subnet);§Error Handling
Most functions return Option<T> or Result<T, E> to handle potential errors
gracefully. Always check the return values to ensure proper error handling.
§Performance Considerations
The library is designed for performance and uses asynchronous operations where appropriate. For large-scale scanning operations, consider using the subnet scanning functions which are optimized for scanning multiple hosts.
Re-exports§
pub use config::Config;pub use output::OutputFormat;pub use output::ScanRecord;pub use output::emit;pub use output::render;pub use resume::ScanState;pub use resume::StateFinding;pub use scanner::address::HostHit;pub use scanner::address::range_addresses;pub use scanner::address::scan_address;pub use scanner::address::scan_address_with_retries;pub use scanner::address::scan_hosts;pub use scanner::address::scan_ip_range;pub use scanner::address::scan_ip_range_with_retries;pub use scanner::address::scan_subnet;pub use scanner::address::scan_subnet_with_retries;pub use scanner::address::subnet_addresses;pub use scanner::exclude::ExcludeSet;pub use scanner::nmap::nmap_args;pub use scanner::nmap::run_nmap;pub use scanner::nmap::split_extra_args;pub use scanner::port::PortHit;pub use scanner::port::UdpHit;pub use scanner::port::is_resolvable;pub use scanner::port::resolve_host;pub use scanner::port::scan_port;pub use scanner::port::scan_port_with_retries;pub use scanner::port::scan_udp_port;pub use scanner::service::detect as detect_service;pub use scanner::service::match_service;pub use scanner::service::service_by_port;pub use scanner::syn::ProbeMode;pub use scanner::syn::ProbeOutcome;pub use scanner::syn::SynOutcome;pub use scanner::syn::build_ipv4_probe;pub use scanner::syn::build_ipv4_syn;pub use scanner::syn::build_tcp_probe;pub use scanner::syn::classify_flags;pub use scanner::syn::classify_reply;pub use scanner::syn::parse_ipv4_tcp;pub use utils::init_scan_pool;pub use utils::parse_ip;pub use utils::parse_ports;pub use utils::parse_subnet;pub use utils::progress_bar;pub use utils::read_targets;pub use utils::read_targets_from_file;pub use utils::read_targets_from_stdin;
Modules§
- cli
- config
- Configuration profiles loaded from
~/.asphyxia.toml. - iface
- Binding scan sockets to a specific network interface (
-e/--interface). - output
- Machine-readable output for scan results.
- rate
- Global rate limiting for scan probes.
- resume
- Resumable scan state for long-running port scans.
- scanner
- Network scanning functionality
- timing
- Timing profiles (
-T0..-T5), a familiar shorthand (à la nmap) for a whole speed/stealth posture instead of tuning--timeout,--concurrency,--retries, and--rateby hand. - utils