nnmap is a high-performance network scanning tool implemented in Go, designed to replicate nmap's core functionality. nnmap provides port scanning, service detection, operating system detection, and more, while maintaining a similar command-line interface and output format to nmap.
- Port Scanning: Supports TCP SYN, TCP Connect, UDP, FIN, Null, Xmas, ACK and other scanning methods
- Service Detection: Signature-based service version detection for TCP and UDP protocols
- Operating System Detection: OS fingerprinting through TCP/IP stack analysis
- Host Discovery: Multiple probe types including ICMP, TCP, UDP, SCTP
- Traceroute: Trace the network path to target hosts
- Static Build Support: Pure Go compilation without CGO dependencies, suitable for containerized deployment
- Embedded Data Files: Optionally embed data files into binary for single-file distribution
- Flexible Building: Control feature modules through build tags for different use cases
- Concurrent Scanning: Multi-port, multi-host concurrent scanning with full resource utilization
- Smart Timeout: Adaptive timeout mechanism based on network conditions
- Timing Templates: Six timing templates (T0-T5) balancing speed and accuracy
# Clone repository
git clone https://github.com/vsermae/nnmap.git
cd nnmap
# Build (with embedded data files, recommended)
go build -ldflags="-s -w" -o nnmap ./cmd/nnmapSuitable for Docker Alpine, CI/CD, and similar environments:
CGO_ENABLED=0 go build -tags norawsocket -ldflags="-s -w" -o nnmap ./cmd/nnmap| Build Option | Command | Features |
|---|---|---|
| Standard Mode | go build -o nnmap ./cmd/nnmap |
SYN/UDP scanning, OS detection, requires libpcap |
| Standard (No Embed) | go build -tags noembed_data -o nnmap ./cmd/nnmap |
Requires external data directory |
| Static Mode | CGO_ENABLED=0 go build -tags norawsocket -o nnmap ./cmd/nnmap |
Pure Go, Connect scan only, suitable for containers |
| Static (No Embed) | CGO_ENABLED=0 go build -tags norawsocket,noembed_data -o nnmap ./cmd/nnmap |
Minimal size, requires external data |
# TCP Connect scan (no root required)
./nnmap -sT 192.168.1.1
# TCP SYN scan (root required)
sudo ./nnmap -sS 192.168.1.1
# UDP scan
sudo ./nnmap -sU 192.168.1.1
# Specify port range
./nnmap -sT -p 1-1000 192.168.1.1
# Service version detection
./nnmap -sT -sV 192.168.1.1
# Operating system detection
sudo ./nnmap -O 192.168.1.1
# Aggressive scan
sudo ./nnmap -A 192.168.1.1# Ping scan (no port scan)
./nnmap -sn 192.168.1.0/24
# TCP SYN ping
./nnmap -sn -PS80,443 192.168.1.0/24
# ICMP Echo ping
sudo ./nnmap -sn -PE 192.168.1.0/24
# Traceroute
sudo ./nnmap --traceroute 192.168.1.1# Use timing template (T0-T5, higher is faster)
./nnmap -T4 192.168.1.1
# Set parallelism
./nnmap --min-parallelism 10 --max-parallelism 100 192.168.1.1
# Limit packet rate
./nnmap --max-rate 100 192.168.1.1# Show only open ports
./nnmap --open 192.168.1.1
# Output to file
./nnmap -oN result.txt 192.168.1.1
./nnmap -oX result.xml 192.168.1.1
# Verbose output
./nnmap -v 192.168.1.1
./nnmap -vv 192.168.1.1 # More verbose| Feature | Standard Mode | Static Mode | Notes |
|---|---|---|---|
| TCP SYN Scan (-sS) | β | β | Requires rawsocket support |
| TCP Connect Scan (-sT) | β | β | No special privileges needed |
| UDP Scan (-sU) | β | β | Requires rawsocket support |
| TCP FIN/Null/Xmas Scan | β | β | Requires rawsocket support |
| Service Version Detection (-sV) | β | β | Supports TCP and UDP |
| OS Detection (-O) | β | β | Requires rawsocket support |
| Host Discovery (-sn) | β | β | ICMP requires root |
| Traceroute (--traceroute) | β | β | Requires rawsocket support |
| Requires CGO | β | β | Static mode is pure Go |
| Depends on libpcap | β | β | Standard mode requires |
| Alpine Compatible | β | β | Static mode for containers |
- β Security auditing and penetration testing
- β Full scanning capabilities required
- β Root privileges and libpcap available
- β Network device and service exploration
- β Containerized environments (Docker, Kubernetes)
- β CI/CD pipeline integration
- β Service discovery without root privileges
- β Alpine Linux environments
- β Quick port availability checks
-iL <inputfilename> Read targets from file
<target specification> IP addresses, ranges, or CIDR notation
-sS TCP SYN scan (stealth scan)
-sT TCP Connect scan
-sU UDP scan
-sV Service version detection
-sA TCP ACK scan
-sF TCP FIN scan
-sN TCP Null scan
-sX TCP Xmas scan
-sn Ping scan - disable port scan
-sL List scan - list targets only
-Pn Treat all hosts as online - skip host discovery
-PS TCP SYN Ping
-PA TCP ACK Ping
-PU UDP Ping
-PE ICMP Echo Ping
-PP ICMP Timestamp Ping
-PM ICMP Netmask Ping
-PO IP Protocol Ping
-p <port ranges> Specify port ranges
Examples: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080
-O Enable OS detection
-A Aggressive mode: enable OS detection, version detection, script scanning, and traceroute
-T<0-5> Set timing template (higher is faster)
--min-parallelism <num> Minimum parallelism
--max-parallelism <num> Maximum parallelism
--min-rate <rate> Minimum packet rate
--max-rate <rate> Maximum packet rate
--scan-delay <ms> Scan delay (milliseconds)
-v Increase verbosity level
-oN <file> Output normal format to file
-oX <file> Output XML format to file
--open Only show open ports
-6 Enable IPv6 scanning
-n Never do DNS resolution
-R Always resolve DNS
--dns-servers <serv1[,serv2],...> Specify custom DNS servers
--traceroute Perform traceroute
nnmap/
βββ cmd/nnmap/ # Main entry point
β βββ main.go # Main logic
β βββ help_*.go # Help information (conditional build)
β βββ *_*.go # Feature modules (conditional build)
βββ internal/ # Internal packages
β βββ data/ # Data management
β βββ hostdiscovery/ # Host discovery
β βββ osdetect/ # OS detection
β βββ packet/ # Packet processing
β βββ portlist/ # Port list management
β βββ scanengine/ # Scan engine
β β βββ connect/ # Connect scan
β β βββ synscan/ # SYN scan
β β βββ udpscan/ # UDP scan
β βββ service/ # Service detection
β βββ target/ # Target parsing
β βββ timing/ # Timing control
βββ embeddata/ # Embedded data interface
βββ data/ # Data files directory
β βββ nmap-services
β βββ nmap-protocols
β βββ nmap-mac-prefixes
β βββ nmap-os-db
β βββ nmap-service-probes
βββ go.mod # Go module definition
- Concurrent Architecture: Efficient concurrent scanning using goroutines and channels
- Smart Scheduling: Adaptive timeout and retransmission mechanisms for efficiency
- Modular Design: Flexible feature control through build tags
- Compatibility: Output format consistent with nmap for easy tool integration
- SYN Scan: Send SYN packets, determine port status from responses
- Connect Scan: Complete three-way handshake, no special privileges needed
- UDP Scan: Send UDP probes, judge based on response or timeout
- Service Detection: Pattern matching based on nmap-service-probes
- OS Detection: Operating system matching through TCP/IP fingerprint database
Contributions are welcome! Please feel free to submit issues or pull requests.
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
- Ensure
go test ./...passes - Follow Go code conventions
- Add necessary unit tests
- Update relevant documentation
This project is licensed under the GNU General Public License v3.0 - see LICENSE file for details
Important Note: This project uses data files from the nmap project (such as nmap-services, nmap-service-probes, nmap-os-db, etc.), which are licensed under GPLv2. To ensure license compatibility, this project adopts the GPLv3 license.
- Thanks to nmap for inspiration, data files, and technical references
- Thanks to gopacket for network packet processing capabilities
- Thanks to all contributors
The data files used in this project are from the nmap project and are copyrighted by Insecure.Com LLC. These data files include but are not limited to:
- nmap-services
- nmap-service-probes
- nmap-os-db
- nmap-protocols
- nmap-mac-prefixes
These data files are licensed under the GNU General Public License Version 2. For more information about nmap's license, please visit: https://nmap.org/