Post

10 Essential Nmap Flags

Top 10 essential flags for when using the network mapper Nmap.

What is Nmap?

Nmap, short for Network Mapper, is a powerful open-source tool designed for network discovery and security auditing. It’s an essential resource for network administrators, helping them identify devices on their networks, discover open ports, and detect potential vulnerabilities. Cybersecurity professionals and penetration testers frequently rely on Nmap to assess network security and bolster defenses.

Installing Nmap

If you’re using Kali Linux, you’re in luck—Nmap comes pre-installed and ready to go. For other Linux distributions, you can easily install it with the following command:

1
apt-get install nmap

If you’re on macOS, you can install Nmap using Homebrew:

1
brew install nmap

For Windows users, detailed installation instructions can be found here.

Useful Nmap Flags

1. OS Detection

Nmap can detect the operating system of a target machine using the -O option. This command identifies the OS based on TCP/IP stack fingerprinting behavior, analyzing how the target responds to various network probes.

1
nmap -O <target_ip>

2. Scan a Port Range

To scan a specific range of ports, use the -p option. For example, to scan ports 20 to 80:

1
nmap -p 20-80 <target_ip>

3. Speed Control

Nmap allows you to control the speed of your scans using the -T option. Here’s a quick breakdown of the timing templates:

  • T0 (Paranoid): Very slow; ideal for stealth and avoiding detection.
  • T1 (Sneaky): Slightly faster than T0; minimizes detection risk while scanning.
  • T2 (Polite): Slows scans to conserve bandwidth and reduce load on targets.
  • T3 (Normal): Default speed; balances speed and stealth for general use.
  • T4 (Aggressive): Fast scans for stable networks; good for quick assessments.
  • T5 (Insane): Extremely fast; suitable for high-speed networks but risks detection.

4. Output to File

To save your scan results to a file, you can use the -oN option followed by the desired filename:

1
nmap -oN output.txt <target_ip>

5. Scan Multiple Targets

You can scan multiple targets by specifying their IPs separated by spaces or by using CIDR notation:

1
2
nmap <target_ip1> <target_ip2>
nmap 192.168.1.0/24  # Scan an entire subnet

6. Stealthy Scans

To perform a stealthy scan, you can use SYN scans with the -sS option. This method is less likely to be detected by firewalls:

1
nmap -sS <target_ip>

7. Scan using a decoy IP address

To obscure your scan’s origin, you can use the decoy option with the -D flag. This sends your packets through a decoy IP:

1
nmap -D RND:10 <target_ip>

8. Nmap vulnerability scan

Nmap comes with scripts that can help identify vulnerabilities. Use the --script option to run vulnerability scans:

1
nmap --script=vuln <target_ip>

9. Scan using TCP or UDP protocols

To specify the protocol for your scan, use the -sT option for TCP scans or -sU for UDP scans:

1
2
nmap -sT <target_ip>  # TCP scan
nmap -sU <target_ip>  # UDP scan

Read more about the differences between TCP and UDP here.

10. Service Version Detection

Another impressive capability of Nmap is its ability to detect service versions running on open ports. You can use the -sV option to gather this information:

1
nmap -sV <target_ip>

Conclusion

Nmap is an invaluable tool for network assessment and security auditing. With its wide array of options, you can uncover vulnerabilities and enhance your network defenses effectively. Whether you’re managing a corporate network, conducting penetration tests, or participating in Capture The Flag (CTF) challenges, mastering Nmap is crucial.

This post is licensed under CC BY 4.0 by the author.