Stealth Scans With Nmap (2024)

This tutorial describes different techniques to execute stealth scans with Nmap.

Stealth scan techniques are implemented to bypass firewalls or discover hosts alive while remaining undetected.

Nmap offers a variety of flags and options to execute different stealth scan types, most of which are explained in this article. They are easy to implement and constitute a nice learning process on IP packets.

After reading this content, the reader will enjoy a better understanding of network packets and communications while acquiring deep practical knowledge on stealth scans with Nmap.

All instructions in this tutorial contain screenshots, making it easy for all readers to understand how they are executed and their outputs or results.

Brief Introduction to Stealth Scans

Usually, firewalls detect establishing or established connections.

TCP sends packets trying to establish a connection with the target (Gathering information in the process). This activity may be blocked and logged by the firewall to be reported to the administrator.

Suppose the user has root privileges by default. In that case, Nmap runs stealth scan techniques consisting of SYN (Synchronization) packets and RST packets interrupting the connection after the first reply from the destination.

Users can prevent firewalls from detecting the scan by interrupting the brief interaction at a time and canceling the connection process before sending an ACK reply.

As you can see in the figure below, a regular TCP scan consists of an initial SYN (Synchronization) packet from Nmap (PC1) requesting the target (PC2) to synchronize a connection. If the targeted port is open, the target replies SYN+ACK (Acknowledgment and Synchronization) packets confirming the SYN reception and the synchronization to Nmap, and Nmap sends ACK (Acknowledgment) packets as a reply to the target’s SYN.

Stealth Scans With Nmap (1)

The following figure shows a stealth scan with SYN packets. As you can see, the final acknowledgment (ACK) packet sent by PC1 (Nmap) is replaced with an RST packet, interrupting the connection to bypass firewalls (Intrusion Detection Systems and custom firewalls will detect stealth scans).

Stealth Scans With Nmap (2)

Nmap TCP SYN (Stealth) Scan Techniques

To execute an SYN or stealth scan like the one depicted in the previous second figure, the user must implement the –sS (SYN) flag. This option will reset the connection before its established.

Note: The SYN scan requires root privileges; use the sudo command.

In the following example, a stealth scan is executed against the network 192.168.0.0/24:

Stealth Scans With Nmap (3)

TCP SYN Ping Scan

The -PS flag allows you to launch SYN ping to discover alive hosts in a stealthy way.

nmap -sn -PS80 192.168.0.1/24

Stealth Scans With Nmap (4)

The -sP flag will also run a no ping scan without a port scan.

nmap -sP 192.168.0.0/24

Stealth Scans With Nmap (5)

Nmap NULL scan

Despite sending an RST packet preventing the connection from being logged, an SYN scan can be detected by firewalls and Intrusion Detection Systems (IDS). There are additional techniques to carry out more stealthy scans with Nmap.

Nmap works by analyzing the packet’s responses from the target, contrasting them with protocol rules, and interpreting them. Nmap allows forging packets to generate the proper responses revealing their nature, for example, to know if a port is closed or filtered by a firewall.

The following example shows a NULL scan that does not include SYN, ACK, or RST packets.

When executing a NULL scan, Nmap can interpret three results: Open|Filtered, Closed, or Filtered, where:

  • Open|Filtered: Nmap can’t determine if the port is open or filtered by a firewall.
  • Closed: The port is closed
  • Filtered: The port is filtered.

In the next practical example, the user uses the -sN flag to run a NULL scan:

sudo nmap -v -sN -p 80 linuxhint.com

Stealth Scans With Nmap (6)

As shown in the following example, you can add the option -sV to discover if the port portrayed as Open|Filtered is actually open, but adding this flag may result in easier scan detection by the target, as explained in Nmap’s book.

sudo nmap -sN -sV -p 80 linuxhint.com

Stealth Scans With Nmap (7)

  • nmap = Calls the program
  • -v = Instructs Nmap to scan with verbosity
  • -sN = Instructs Nmap to run a NULL scan
  • -sV = Version detection
  • -p = Prefix to determine the port to scan.

In some cases, firewalls block SYN packets. In such a case, the user can send a packet with flags SYN/ACK to bypass firewalls that don’t block SYN/ACK packets.

Some packets are not blocked in SYN with ACK packets and also allow the combination of SYN with other headers, the SYN/FIN header is one of them.

The following scan type will send SYN and FIN headers. This scan type has a low chance of remaining undetected.

sudo nmap -sS --scanflags SYNFIN linuxhint.com -v

Stealth Scans With Nmap (8)

Nmap Xmas Scan

Xmas scan was considered a stealth scan technique analyzing responses to Xmas packets to learn the type of remote system.

Each operating system or network device replies to Xmas packets in a different way revealing information, such as the operating system and port states.

Xmas is an old scan technique; today, many firewalls and Intrusion Detection Systems can detect Xmas. It is not recommended to rely on them as a stealth technique.

sudo nmap -sX -T2 linuxhint.com -v

Stealth Scans With Nmap (9)

Comparison between TCP SYN stealth scan and TCP “Connect Scan”:

Normal TCP Communication

  • -“Hey, can you hear me? Can we meet?” (SYN packet requesting synchronization)
  • -“Hi!, I see you!, we can meet” (Where “I see you” is an ACK packet, and “we can meet” is a SYN packet)
  • -“Great!” (RSTet pack)

SYN Stealth communication

  • -“Hey, can you hear me? Can we meet?” (SYN packet requesting synchronization)
  • -“Hi!, I see you!, we can meet” (Where “I see you” is an ACK packet, “we can meet” is a SYN packet)
  • -“Sorry, I sent a request to you by mistake, forget about it” (RSTet pack)

The second example above shows a SYN connection, which does not establish a connection in contrast to a TCP connection or Connect Scan. Therefore there is no log on the second device about a connection, nor is your IP address logged.

Other Nmap Flags (No Stealth)

In addition to the stealth scan techniques, we decided to describe some different flags.

It is important to clarify that the following flags below are not stealthy.

The -O flag can detect the target operating system, as shown in the following screenshot:

sudo nmap -O donweb.co

Stealth Scans With Nmap (10)

As you can see in the previous screenshot, the target probably has Linux with kernel 2.6.x; according to the report, detection conditions were difficult.

The following example tries to learn the software version (-sV) listening behind ports. As you can see, Varnish was detected.

nmap -sV wikipedia.org

Stealth Scans With Nmap (11)

The -oN flag creates a file with the results of the scan.

In the following example, the user implements the -oN flag to create the file “results.txt” with the scan output.

Stealth Scans With Nmap (12)

That’s all about stealth scan methods. You can test them with an Intrusion Detection System like Snort to see their effectiveness before different detection rules.

Conclusion

As you can see, Nmap offers different stealth scan techniques. They all are easy to implement, and the technique is easy to understand if the user knows networking basics. Readers with minimal experience can reproduce the given practical examples without major difficulty. It is highly recommended to apply the example additionally to the reading.

All the given instructions are valid for all Linux distributions.

Thank you for reading this tutorial explaining how to run stealth scans with Nmap. Keep following Linux Hint for more networking and security professional content.

Stealth Scans With Nmap (2024)

FAQs

What is the benefit of a stealth scan in Nmap? ›

SYN scan is the default and most popular scan option for good reason. It can be performed quickly, scanning thousands of ports per second on a fast network not hampered by intrusive firewalls. SYN scan is relatively unobtrusive and stealthy, since it never completes TCP connections.

Is it illegal to scan with Nmap? ›

Network probing or port scanning tools are only permitted when used in conjunction with a residential home network, or if explicitly authorized by the destination host and/or network. Unauthorized port scanning, for any reason, is strictly prohibited.

Which Nmap scan would be the least detectable? ›

If the goal is to run an Nmap scan as quietly as possible and minimize the chance of detection, using the "-P0" option would be a better choice than the "-T0" option. So, the correct answer to the question is "-P0".

Are Nmap scans detectable? ›

Log monitoring tools such as Logwatch and Swatch can certainly help, but the reality is that system logs are only marginally effective at detecting Nmap activity. Special purpose port scan detectors are a more effective approach to detecting Nmap activity. Two common examples are PortSentry and Scanlogd.

What is the best stealth scan in Nmap? ›

Idle scan is the ultimate stealth scan. Nmap offers decoy scanning ( -D ) to help users shield their identity, but that (unlike idle scan) still requires an attacker to send some packets to the target from his real IP address in order to get scan results back.

Why do we use stealth scan? ›

Stealth scans

Stealth scan types are those where packet flags cause the target system to respond without having a fully established connection. Stealth scanning is used by hackers to circumvent the intrusion detection system (IDS), making it a significant threat.

Do real hackers use Nmap? ›

However, hackers can also use Nmap to access uncontrolled ports on a system. They can run Nmap on a targeted approach, identify vulnerabilities, and exploit them.

Do people still use Nmap? ›

Nmap is usually thought of as a cybersecurity tool, though its usefulness as a troubleshooting utility should not be underrated. Security pros and administrators use Nmap for many different types of tasks.

Is Nmap still relevant? ›

With its wide range of applications, Nmap has become an essential tool for troubleshooting, auditing, and general network scanning, proving its reliability in the networking and security space.

What is the difference between a stealth scan and a connect scan? ›

Although both TCP Connect and Stealth scanning are effective methods for monitoring system ports and port states, Stealth scanning has the advantage of avoiding logging because it uses a half-open TCP connection to the target and thus detects the target's ports faster, while Web Application Firewalls detects fewer of ...

What is the most powerful Nmap scan? ›

Let's get to know a few useful command-line based best Nmap scans that can be performed.
  1. Basic Nmap Scan against IP or host. ...
  2. Nmap Ping Scan. ...
  3. Scan specific ports or scan entire port ranges on a local or remote server. ...
  4. Scan multiple IP addresses. ...
  5. Scan IP ranges. ...
  6. Scan the most popular ports.
Apr 11, 2024

Is there anything better than Nmap? ›

Masscan can be compared with other tools like Nmap. Due to its focus on high performance, this tool can be used when many systems have to be scanned at once. It can scan all internet hosts on IPv4 within 5 minutes. This impressive statistic makes the tool loved by those that do security research.

What is Nmap decoy scan? ›

The Nmap command nmap -D RND:10 is the decoy option, that lets you scan using multiple decoy IP addresses. Firewalls and IDS detect normal scanning attempts on the target network. However, you can use the IP address decoy technique to avoid detection.

Is an Nmap scan intrusive? ›

Performs a script scan using the default set of scripts. It is equivalent to --script=default . Some of the scripts in this default category are considered intrusive and should not be run against a target network without permission.

Is port scanning detectable? ›

This scan is accurate but easily detectable because a full connection is always logged by firewalls. SYN scan: Also called a half-open scan, this sends a SYN flag to the target and waits for a SYN-ACK response.

Why would a stealth scan attract more attention than a connect scan? ›

If an attacker is running a connect scan they are probably less sophisticated/skilled, and therefore less of a threat. If someone is running a stealth scan they are much more likely to know what they are doing, and be harder to detect. TCP connect scan establishes full connection with target as compare to SYN.

What are the advantages of Nmap scan? ›

Users find Nmap to be a helpful tool with an easy interface for scanning networks, making it the best free networking scanner available. It offers easy commands and scripts for performing scans, allowing users to check services running on a network and detect vulnerabilities.

What is TCP stealth scan? ›

In computer networking, TCP Stealth is a proposed modification of the Transmission Control Protocol (TCP) to hide open ports of some TCP services from the public, in order to impede port scans. It is somewhat similar to the port knocking technique.

Top Articles
Exchange traded funds
How to Delete a Character from a String in Python: A Step-by-Step Guide | Hostman
Kostner Wingback Bed
Christian McCaffrey loses fumble to open Super Bowl LVIII
Gore Videos Uncensored
Snowflake Activity Congruent Triangles Answers
Best Pawn Shops Near Me
Beau John Maloney Houston Tx
Walmart End Table Lamps
Craigslist Free Stuff Santa Cruz
Troy Bilt Mower Carburetor Diagram
Osborn-Checkliste: Ideen finden mit System
Ruben van Bommel: diepgang en doelgerichtheid als wapens, maar (nog) te weinig rendement
ZURU - XSHOT - Insanity Mad Mega Barrel - Speelgoedblaster - Met 72 pijltjes | bol
Aaa Saugus Ma Appointment
Ubg98.Github.io Unblocked
Fort Mccoy Fire Map
Ivegore Machete Mutolation
Craigslist Northfield Vt
C&T Wok Menu - Morrisville, NC Restaurant
Cookie Clicker Advanced Method Unblocked
Scripchat Gratis
Sessional Dates U Of T
Phantom Fireworks Of Delaware Watergap Photos
At 25 Years, Understanding The Longevity Of Craigslist
Cognitive Science Cornell
EVO Entertainment | Cinema. Bowling. Games.
Carroway Funeral Home Obituaries Lufkin
2487872771
DIY Building Plans for a Picnic Table
Ancestors The Humankind Odyssey Wikia
Chattanooga Booking Report
Craigslist Red Wing Mn
Ippa 番号
Metra Schedule Ravinia To Chicago
Otter Bustr
7543460065
Housing Intranet Unt
Luvsquad-Links
Hovia reveals top 4 feel-good wallpaper trends for 2024
Saline Inmate Roster
Iupui Course Search
Unblocked Games 6X Snow Rider
Random Warzone 2 Loadout Generator
Acuity Eye Group - La Quinta Photos
Doelpuntenteller Robert Mühren eindigt op 38: "Afsluiten in stijl toch?"
Craigslist Anc Ak
Diesel Technician/Mechanic III - Entry Level - transportation - job employment - craigslist
Ics 400 Test Answers 2022
Affidea ExpressCare - Affidea Ireland
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5501

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.