ntrace
A fast and secure network port scanner and protocol analyzer written in Rust.
Features
- Advanced Port Scanning: Asynchronous TCP/UDP port scanning with configurable concurrency and rate limiting
- Service Detection: Identifies services running on open ports using multiple methods:
- Banner grabbing
- Active probing
- Well known port database
- Protocol Analysis: Detects and analyzes protocols (HTTP, TLS, SSH, etc.)
- Multiple Output Formats: JSON and CSV output for integration with other tools
- Hostname Resolution: Supports both IP addresses and hostnames as targets
- Flexible Port Selection: Scan specific ports, ranges, or use predefined groups (common, well known, all)
Installation
From Cargo
From Source
The binary will be available at target/release/ntrace.
Usage
Basic Usage
# Scan default ports (1-1000) on a target
# Scan specific ports
# Scan a port range
# Scan common ports
Advanced Options
# Verbose output (show closed ports)
# Set custom timeout
# Set batch size for parallel scanning
# Use UDP protocol instead of TCP
# Skip host discovery (ping)
# Save results to a file (JSON or CSV)
# Aggressive scan (more intrusive probes)
Port Selection Options
common: Scans commonly used portswell-known: Scans well known ports (1-1023)all: Scans all ports (1-65535)registered: Scans registered ports (1024-49151)dynamic: Scans dynamic ports (49152-65535)
Scan Examples
Basic TCP Scan
Scan the most common ports on a web server:
Output:
=============================================================
_ _ _____
| \ | |_ _| __ __ _ ___ ___
| \| | | || '__/ _` |/ __/ _ \
| |\ | | || | | (_| | (_| __/
|_| \_| |_||_| \__,_|\___\___|
Network Port Scanner & Protocol Analyzer v0.1.0
=============================================================
Starting scan of 20 ports on wikipedia.org...
[00:00:02] Scan completed in 2.34s
Results for wikipedia.org (resolved to 93.184.216.34):
PORT STATE SERVICE PROTOCOL LATENCY
80 open http TCP 124.3ms
443 open https TLS/SSL 125.1ms
Summary: 2 open ports, 18 closed ports out of 20 scanned
Comprehensive Web Server Analysis
Scan all web-related ports with verbose output:
Network Service Discovery
Discover all services on a local network device:
Fast Network Sweep
Quickly check if common services are running:
UDP Service Detection
Scan for common UDP services:
Note about UDP scanning: Unlike TCP, UDP is connectionless and doesn't have a handshake mechanism. This makes it difficult to determine if a port is truly open or closed. In UDP scanning:
open: The port sent back a UDP response (definite open)open|filtered: No response was received, which could mean either the port is open but the service didn't respond, or a firewall is filtering the portclosed: An ICMP "port unreachable" message was received
Output:
=============================================================
_ _ _____
| \ | |_ _| __ __ _ ___ ___
| \| | | || '__/ _` |/ __/ _ \
| |\ | | || | | (_| | (_| __/
|_| \_| |_||_| \__,_|\___\___|
Network Port Scanner & Protocol Analyzer v0.1.0
=============================================================
Starting scan of 4 ports on 192.168.1.1...
[00:00:03] Scan completed in 3.12s
Results for 192.168.1.1:
PORT STATE SERVICE PROTOCOL LATENCY
53 open domain DNS 45.7ms
123 open ntp NTP 67.2ms
67 open|filtered dhcp UDP -
161 open|filtered snmp UDP -
Summary: 2 open ports, 2 open|filtered ports out of 4 scanned
Exporting Scan Results
Scan and save results in JSON format for further analysis:
Library Usage
ntrace can also be used as a library in your Rust projects:
use ;
use IpAddr;
use FromStr;
use Duration;
async
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.