ntrace
A fast network port scanner, protocol analyzer, and traceroute utility 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.)
- Advanced Traceroute: Trace the network path to a target using various protocols (ICMP, TCP, UDP) with:
- Parallel tracing for up to 5x faster results
- Path MTU discovery
- Path asymmetry detection
- Detailed latency statistics (min/max/avg/std-dev)
- Packet loss calculation
- Adaptive timing for better reliability
- 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.
Using the Built Binary
After building the binary, you can use it directly:
# Port scanning
# Traceroute will automatically handle permissions for ICMP
# The tool will automatically request sudo access to set CAP_NET_RAW capability if needed
# Or you can manually set the capability:
# UDP port scanning
You can also move the binary to a directory in your PATH for easier access:
# On Linux/macOS
# On Windows (PowerShell with Administrator privileges)
Platform Specific Examples
Linux
# Full port scan with service detection
# Fast traceroute with table output and parallel processing
Windows
# Scan a local network device
# TCP traceroute with parallel processing
macOS
# Scan multiple ports with JSON output
# ICMP traceroute with maximum 20 hops
Advanced Command Examples
Here are some more advanced examples that combine multiple features:
# Comprehensive network analysis: port scan followed by traceroute to open ports
# Security audit: scan all well-known ports with aggressive service detection
# Network troubleshooting: compare fast TCP and standard ICMP traceroute results
# Performance testing: scan with different batch sizes and compare
# Advanced traceroute with parallel processing for faster results
# Comprehensive network path analysis
Usage
Basic Usage
# Scan default ports (1-1000) on a target
# Scan specific ports
# Scan a port range
# Scan common ports
Traceroute Usage
# Basic ICMP traceroute (requires sudo/root privileges)
# TCP traceroute (can work without sudo for basic functionality)
# UDP traceroute
# Specify maximum hops
# Specify port for TCP/UDP traceroute
# Output trace results as table
# Save trace results to a file
# Fast mode with parallel tracing (up to 5x faster)
# Combine options for optimal performance
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)
# Ultra fast scanning mode
Advanced Traceroute Features
ntrace offers several advanced traceroute capabilities that make it more powerful than traditional traceroute tools:
# Parallel traceroute for faster results (up to 5x faster)
# Combine parallel processing with TCP for reliable results
# Detailed statistics with table output
# Control the number of parallel requests
# Customize timing parameters for better reliability
These advanced features provide:
- Parallel Processing: Trace multiple hops simultaneously for faster results
- Detailed Statistics: Min/max/avg latency, standard deviation, packet loss
- Adaptive Timing: Automatically adjust timing based on network conditions
- Flexible Protocol Support: Choose between TCP, UDP, and ICMP based on your needs
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
Traceroute Example
Trace the network path to Google using ICMP:
Or use the faster parallel traceroute with TCP:
Output:
╔══════════════════════════════════════════════════════════╗
║ ║
║ _ _ _____ ║
║ | \ | |_ _| __ __ _ ___ ___ ║
║ | \| | | || '__/ _` |/ __/ _ \ ║
║ | |\ | | || | | (_| | (_| __/ ║
║ |_| \_| |_||_| \__,_|\___\___| ║
║ ║
║ Traceroute & Network Path Analyzer v0.1.3 ║
║ ║
╚══════════════════════════════════════════════════════════╝
Starting traceroute to google.com using Icmp...
╔════════════════════════════════════════════════════════════════════╗
║ TRACEROUTE RESULTS ║
╠════════════════════════════════════════════════════════════════════╣
║ Target: google.com ║
║ Protocol: Icmp ║
║ Duration: 15.77 seconds ║
║ Hops: 16 ║
║ Destination Reached: Yes ║
╠════════════════════════════════════════════════════════════════════╣
║ HOP IP HOSTNAME LATENCY ║
╠════════════════════════════════════════════════════════════════════╣
║ 1 172.21.96.1 - 0.44ms ║
║ 2 192.168.29.1 - 3.19ms ║
║ 3 10.50.144.1 - 5.26ms ║
║ 4 172.31.5.101 - 4.87ms ║
║ 5 192.168.86.238 - 3.96ms ║
║ 6 172.26.104.52 - 3.99ms ║
║ 7 172.26.104.146 - 8.50ms ║
║ 8 192.168.85.56 - 5.13ms ║
║ 9 * - * ║
║ 10 * - * ║
║ 11 * - * ║
║ 12 * - * ║
║ 13 173.194.121.8 - 34.54ms ║
║ 14 192.178.110.227 - 33.98ms ║
║ 15 72.14.233.59 - 33.37ms ║
║ 16 → 142.250.183.110 ← - 35.66ms ║
╚════════════════════════════════════════════════════════════════════╝
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:
Ultra Fast Scanning
For maximum speed (up to 10x faster than regular scanning), use fast mode:
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.