TCP SYN (Stealth) Scan (-sS) (2024)

  • Nmap Network Scanning
  • Chapter5.Port Scanning Techniques and Algorithms
  • TCP SYN (Stealth) Scan (-sS)

SYN scan is the default and most popular scan option for goodreason. It can be performed quickly, scanning thousands of ports persecond on a fast network not hampered by intrusive firewalls. SYN scanis relatively unobtrusive and stealthy, since it never completes TCPconnections. It also works against any compliant TCP stack ratherthan depending on idiosyncrasies of specific platforms as Nmap'sFIN/NULL/Xmas, Maimon and idle scans do. It also allows clear,reliable differentiation between open,closed, and filteredstates.

SYN scan may be requested by passing the -sSoption to Nmap. It requiresraw-packet privileges,and is the defaultTCP scan when they are available. So when running Nmap as root orAdministrator, -sS is usually omitted. This defaultSYN scan behavior is shown in Example5.1, which finds a port in each of the three major states.

Example5.1.A SYN scan showing three port states

krad# nmap -p22,113,139 scanme.nmap.orgStarting Nmap ( https://nmap.org )Nmap scan report for scanme.nmap.org (64.13.134.52)PORT STATE SERVICE22/tcp open ssh113/tcp closed auth139/tcp filtered netbios-ssnNmap done: 1 IP address (1 host up) scanned in 1.35 seconds

While SYN scan is pretty easy to use without any low-levelTCP knowledge,understanding the technique helps when interpreting unusual results.Fortunately for us, the fearsomeblack-hatcrackerEreet Hagiwarahas taken a break from terrorizingJapanese Windows users to illustrate the Example5.1SYN scan for us at the packet level. First, the behavior against openport 22 is shown in Figure5.2.

Figure5.2.SYN scan of open port 22

TCP SYN (Stealth) Scan (-sS) (1)

As this example shows, Nmap starts by sending a TCP packet withthe SYN flag set (see Figure2, “TCP header” if you haveforgotten what packet headers look like) to port 22. This is thefirst step in the TCPthree-way handshakethat any legitimateconnection attempt takes. Since the target port is open, Scanme takesthe second step by sending a response with the SYN and ACK flags back.In a normal connection, Ereet's machine (named krad) would completethe three-way handshake by sending an ACK packet acknowledging theSYN/ACK. Nmap does not need to do this, since the SYN/ACK responsealready told it that the port is open. If Nmap completed theconnection, it would then have to worry about closing it. Thisusually involves another handshake, using FIN packets ratherthan SYN. So an ACK is a bad idea, yet something still has to bedone. If the SYN/ACK is ignored completely, Scanme will assume it wasdropped and keep re-sending it. The proper response, since we don'twant to make a full connection, is a RST packet as shown in thediagram. This tells Scanme to forget about (reset) the attemptedconnection. Nmap could send this RST packet easily enough, but itactually doesn't need to. The OS running on krad also receivesthe SYN/ACK, which it doesn't expect because Nmap crafted the SYNprobe itself. So the OS responds to the unexpected SYN/ACK with aRST packet. All RST packets described in this chapter also have the ACK bitset because they are always sent in response to (and acknowledge) areceived packet. So that bit is not shown explicitly for RST packets.Because the three-way handshake is never completed, SYN scan issometimes calledhalf-open scanning.

Figure5.3 shows how Nmapdetermines that port 113 is closed. This is even simpler than theopen case. The first step is always the same—Nmap sends the SYNprobe to Scanme. But instead of receiving a SYN/ACK back, a RST isreturned. That settles it—the port is closed. No morecommunication regarding this port is necessary.

Figure5.3.SYN scan of closed port 113

TCP SYN (Stealth) Scan (-sS) (2)

Finally, Ereet shows us how a filtered port appears to Nmap inFigure5.4. The initialSYN is sent first, as usual, but Nmap sees no reply. The responsecould simply be slow. From previous responses (or timing defaults),Nmap knows how long to wait and eventually gives up on receiving one.A non-responsive port is usually filtered (blocked by a firewalldevice, or perhaps the host is down), but this one test is notconclusive. Perhaps the port is open but the probe or response weresimply dropped. Networks can be flaky. So Nmap tries again by resending the SYN probe. After yet another timeout period, Nmapgives up and marks the port filtered. In thiscase, only one retransmission was attempted. As described in the section called “Scan Code and Algorithms”, Nmap keeps careful packet lossstatistics and will attempt more retransmissions when scanning lessreliable networks.

Figure5.4.SYN scan of filtered port 139

TCP SYN (Stealth) Scan (-sS) (3)

Nmap will also consider a port filtered if it receives certain ICMP error messages back. Table5.2 shows how Nmap assigns port states based on responses to a SYN probe.

Table5.2.How Nmap interprets responses to a SYN probe

Probe ResponseAssigned State
TCP SYN/ACK responseopen
TCP RST responseclosed
No response received (even after retransmissions)filtered
ICMP unreachable error (type 3, code 1, 2, 3, 9, 10, or 13)filtered

While the pretty illustrations in this section are useful whenyou have them, Nmap reports exactly what it is doing at the packetlevel when you specify the --packet-trace option inaddition to any other desired command-line flags. This is a great way fornewbies to understand Nmap's behavior when Ereet is not around tohelp. Even advanced users find it handy when Nmap producesresults they don't expect. You may want to increase the debug levelwith -d (or even -d5) as well. Thenscan the minimum number of ports and hosts necessary for your purposeor you could end up with literally millions of output lines. Example5.2 repeats Ereet'sthree-port SYN scan with packet tracing enabled (output edited forbrevity). Read the command-line, then test yourself by figuring outwhat packets will be sent before reading on. Then once you read the traceup to The SYN Stealth Scan took 1.25s, you should knowfrom the RCVD lines what the port state table will look like beforecontinuing on to read it.

Example5.2.Using --packet-trace to understand a SYN scan

krad# nmap -d --packet-trace -p22,113,139 scanme.nmap.orgStarting Nmap ( https://nmap.org )SENT (0.0130s) ICMP krad > scanme echo request (type=8/code=0) ttl=52 id=1829SENT (0.0160s) TCP krad:63541 > scanme:80 A iplen=40 seq=91911070 ack=99850910RCVD (0.0280s) ICMP scanme > krad echo reply (type=0/code=0) iplen=28We got a ping packet back from scanme: id = 48821 seq = 714 checksum = 16000massping done: num_hosts: 1 num_responses: 1Initiating SYN Stealth Scan against scanme.nmap.org (scanme) [3 ports] at 00:53SENT (0.1340s) TCP krad:63517 > scanme:113 S iplen=40 seq=10438635SENT (0.1370s) TCP krad:63517 > scanme:22 S iplen=40 seq=10438635SENT (0.1400s) TCP krad:63517 > scanme:139 S iplen=40 seq=10438635RCVD (0.1460s) TCP scanme:113 > krad:63517 RA iplen=40 seq=0 ack=10438636RCVD (0.1510s) TCP scanme:22 > krad:63517 SA iplen=44 seq=75897108 ack=10438636SENT (1.2550s) TCP krad:63518 > scanme:139 S iplen=40 seq=10373098 win=3072The SYN Stealth Scan took 1.25s to scan 3 total ports.Nmap scan report for scanme.nmap.org (64.13.134.52)PORT STATE SERVICE22/tcp open ssh113/tcp closed auth139/tcp filtered netbios-ssnNmap done: 1 IP address (1 host up) scanned in 1.40 seconds

SYN scan has long been called thestealth scanbecause it issubtler than TCP connect scan (discussed next), which was the mostcommon scan type before Nmap was released. Despite that moniker,don't count on a default SYN scan slipping undetected throughsensitive networks. Widely deployedintrusion detection systems and even personal firewallsare quite capable of detecting default SYN scans. More effectivetechniques for stealthy scanning are demonstrated in Chapter10, Detecting and Subverting Firewalls and Intrusion Detection Systems.

TCP SYN (Stealth) Scan (-sS) (2024)

FAQs

What is a TCP SYN scan response? ›

TCP SYN scan

It works by sending a SYN packet in an attempt to open a connection. A SYN/ACK response indicates an open TCP port, whereas an RST response indicates a closed port. If no response is received or if an Internet Control Message Protocol (ICMP) unreachable error is received, it indicates a filtered state.

What is TCP SYN stealth port scan Nmap? ›

A TCP SYN scan is a stealth scan used to determine if ports on a target system are open, closed or filtered. Nmap sends a SYN packet to the target and waits for a response. If the target responds with a SYN/ACK packet, the port is considered open and ready to establish a connection.

What does sS do 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.

What is TCP SYN ping scan in Nmap? ›

A TCP SYN scan runs by default when running Nmap as root or Administrator. It is the most popular scan option according to Nmap.org. Quick and efficient, this scan can indicate open, filtered, and closed port states.

How does a stealth scan work? ›

A stealth scan works by manipulating the network traffic to hide the presence of the scan from security tools. The attacker uses different techniques like fragmenting packets, using low-level protocol commands, and sending packets at slow intervals to ensure that the scan remains undetected.

What is TCP SYN used for? ›

TCP uses a three-way handshake to establish a reliable connection. The connection is full duplex, and both sides synchronize (SYN) and acknowledge (ACK) each other.

What is the difference between a TCP SYN scan and a TCP Connect scan? ›

Half-open or "SYN" scans are other names for stealth scanning. With closed and filtered ports, SYN scan operates similarly to TCP Connect scan in that it receives a RST message for closed ports and no answer for filtered ports. The way they handle open ports is the only distinction.

What is a stealth port? ›

Internet Port Status Definitions

A "Stealth" port is one that completely ignores and simply "drops" any incoming packets without telling the sender whether the port is "Open" or "Closed" for business.

What does a TCP scan do? ›

One of the more common and popular port scanning techniques is the TCP half-open port scan, sometimes referred to as an SYN scan. It's a fast and sneaky scan that tries to find potential open ports on the target computer. SYN packets request a response from a computer, and an ACK packet is a response.

What are the flags for TCP scan? ›

In TCP connection, flags are used to indicate a particular state of connection or to provide some additional useful information like troubleshooting purposes or to handle a control of a particular connection. Most commonly used flags are “SYN”, “ACK” and “FIN”. Each flag corresponds to 1 bit information.

What is the sS command used for? ›

The ss command is a tool used to dump socket statistics and displays information in similar fashion (although simpler and faster) to netstat. The ss command can also display even more TCP and state information than most other tools.

How does Nmap decoy scan work? ›

Decoying IP address

Nmap will send multiple packets with different IP addresses, along with your attacker's IP address. Again, the output is the same as previous outputs but on the target view is very different. Check the Logs on your Windows Server Firewall and analyze the last scan performed.

What is default Nmap SYN scan? ›

By default, Nmap performs a SYN Scan, though it substitutes a connect scan if the user does not have proper privileges to send raw packets (requires root access on Unix). Of the scans listed in this section, unprivileged users can only execute connect and FTP bounce scans.

When scanning Why would you use SYN scan over a TCP connect scan? ›

When SYN scan is available, it is usually a better choice. Nmap has less control over the high level connect call than with raw packets, making it less efficient. The system call completes connections to open target ports rather than performing the half-open reset that SYN scan does.

What is port scanner syn? ›

SYN scanning

SYN scan is another form of TCP scanning. Rather than using the operating system's network functions, the port scanner generates raw IP packets itself, and monitors for responses. This scan type is also known as "half-open scanning", because it never actually opens a full TCP connection.

What is TCP SYN reply? ›

The handshake involves three steps: A client sends a SYN (synchronize) message to a server, indicating a desire to establish a connection. The server acknowledges this request by sending a SYN-ACK message back to the client. The client responds with an ACK (acknowledgment), and the connection is officially established.

What is the purpose of TCP ACK scan? ›

The TCP ACK scanning technique uses packets with the flag ACK on to try to determine if a port is filtered. This technique comes handy when checking if the firewall protecting a host is stateful or stateless.

What does a TCP connect scan do? ›

A TCP connect scan establishes a complete connection to the target host by completing a TCP three-way handshake.

What are the responses to a port scan? ›

Port scan results reveal the status of the network or server and can be described in one of three categories: open, closed, or filtered. Open ports: Open ports indicate that the target server or network is actively accepting connections or datagrams and has responded with a packet that indicates it is listening.

Top Articles
Bitcoin and cryptocurrencies – what digital money really means for our future
Compare Estate Planning Documents - Living Trust vs. Will vs. Living Will
Edina Omni Portal
Craigslist St. Paul
What Are Romance Scams and How to Avoid Them
Tj Nails Victoria Tx
Acts 16 Nkjv
Ecers-3 Cheat Sheet Free
About Goodwill – Goodwill NY/NJ
Best Cav Commanders Rok
Ncaaf Reference
Red Heeler Dog Breed Info, Pictures, Facts, Puppy Price & FAQs
Thotsbook Com
Shuiby aslam - ForeverMissed.com Online Memorials
Scholarships | New Mexico State University
Discover Westchester's Top Towns — And What Makes Them So Unique
Shannon Dacombe
Aldi Sign In Careers
Erica Banks Net Worth | Boyfriend
Costco Great Oaks Gas Price
Arre St Wv Srj
Caledonia - a simple love song to Scotland
Melissababy
Air Traffic Control Coolmathgames
67-72 Chevy Truck Parts Craigslist
John Chiv Words Worth
All Obituaries | Gateway-Forest Lawn Funeral Home | Lake City FL funeral home and cremation Lake City FL funeral home and cremation
8005607994
Hdmovie2 Sbs
Scott Surratt Salary
My Reading Manga Gay
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
O'reilly's Wrens Georgia
2024 Coachella Predictions
Craigslist Hamilton Al
Missouri State Highway Patrol Will Utilize Acadis to Improve Curriculum and Testing Management
Rogers Centre is getting a $300M reno. Here's what the Blue Jays ballpark will look like | CBC News
Rochester Ny Missed Connections
Paperless Employee/Kiewit Pay Statements
Japanese Big Natural Boobs
Dr Mayy Deadrick Paradise Valley
Here's Everything You Need to Know About Baby Ariel
John Wick: Kapitel 4 (2023)
Craigslist Chautauqua Ny
Black Adam Showtimes Near Kerasotes Showplace 14
Divisadero Florist
Black Adam Showtimes Near Cinemark Texarkana 14
The Significance Of The Haitian Revolution Was That It Weegy
Predator revo radial owners
Room For Easels And Canvas Crossword Clue
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 5934

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.