SMT 2-5 Port Scan

NSHC Training
28 Jul 202414:26

Summary

TLDRThis video script offers an insightful look into port scanning techniques, a critical method for identifying open ports on a network that could serve as entry points for attackers. It highlights the importance of open ports, the use of nmap as a versatile open-source tool for port scanning, and discusses various scanning methods including TCP open scan, SYN scan, and stealth scans like FIN, NULL, and Xmas scans. The script also emphasizes the ethical considerations of port scanning, urging to only perform scans within one's own network or with proper permissions.

Takeaways

  • 🔒 Port scanning is a technique used to determine which ports on a device are open or closed, which is crucial for identifying potential access points for attackers.
  • 🚪 An open port acts as a potential 'door' for gaining access to a system, hence the analogy of knocking on all doors to see which ones are open.
  • 🔎 The purpose of port scanning is to find ports that may have been unintentionally left open by administrators, which could be exploited by attackers.
  • 🛡️ From a defender's perspective, port scanning helps identify unintended exposure to attacks and allows for proactive measures to be taken.
  • 🔧 Nmap is a well-known and widely used open-source tool for port scanning and network vulnerability assessment.
  • 🌐 Nmap's popularity stems from its ease of acquisition, extensive options, and rich functionality compared to other tools.
  • 🔄 Port scanning has evolved to include stealth techniques that avoid leaving traces in logs, such as TCP stealth scans, to evade detection.
  • 🚀 The script demonstrates practical port scanning using Nmap in a controlled virtual environment, emphasizing the importance of ethical scanning practices.
  • 📈 The script provides a detailed walkthrough of different port scanning methods, including TCP open scan, SYN scan, and various stealth scans like FIN, NULL, and Xmas scans.
  • 🕵️‍♂️ Analyzing packet captures with Wireshark is an essential skill for understanding the behavior of different port scanning techniques.
  • 📚 The script concludes by reiterating the importance of port scanning for both attackers to identify targets and defenders to secure their networks.

Q & A

  • What is port scanning?

    -Port scanning is a method used to determine which ports on a device in a network are open or closed. It helps in identifying potential access points to a system.

  • Why is finding an open port important?

    -Finding an open port is important because it can serve as a conduit for gaining access to the system, either for legitimate security testing or malicious activities.

  • What is the purpose of port scanning from an attacker's perspective?

    -From an attacker's perspective, port scanning helps to identify open ports that can be exploited, reducing the attack vector by focusing only on accessible services.

  • How can port scanning assist a network defender?

    -Port scanning can assist a network defender by identifying unintentionally open ports that could be a security risk, allowing them to take preventive measures.

  • What is nmap and why is it widely used for port scanning?

    -Nmap is an open-source program used for network scanning, including port scanning and vulnerability detection. It is widely used due to its availability, extensive options, and functionality.

  • What is a TCP open scan and how does it work?

    -A TCP open scan is a basic method of port scanning that uses the three-way handshake process to verify if a port is open. It involves sending a SYN packet and waiting for a SYN-ACK response, indicating an open port.

  • What is a SYN scan and how does it differ from a TCP open scan?

    -A SYN scan, also known as a half-open scan, sends SYN packets to a target and waits for a SYN-ACK response to identify open ports. Unlike a TCP open scan, it sends an RST packet to terminate the connection, leaving no logs behind.

  • What are stealth scans and why are they used?

    -Stealth scans are scanning techniques designed to avoid detection by not leaving logs on the target system. They are used to minimize the trace of a scan, making it harder for defenders to identify the scanning activity.

  • What are the differences between FIN, NULL, and Xmas scans?

    -FIN scan sets the FIN flag in packets, NULL scan sends packets without setting any flags, and Xmas scan sets the FIN, PSH, and URG flags. All three methods interpret no response as an open port and an RST packet as a closed port.

  • What does the 'filtered' state in port scanning indicate?

    -The 'filtered' state in port scanning indicates that no response was received from the target port, but it does not provide a clear indication of whether the port is open or closed due to a firewall or filtering device blocking the response.

  • Why is it important to practice port scanning in a controlled environment?

    -Practicing port scanning in a controlled environment, like a virtual machine or a personal network, is important to avoid legal issues and potential damage to real servers. It ensures ethical and safe learning and testing of scanning techniques.

Outlines

00:00

🔍 Introduction to Port Scanning Techniques

The video introduces the concept of port scanning, a technique used to identify open or closed ports on a network device. It emphasizes the importance of open ports as potential access points for attackers and the necessity for administrators to identify and secure them. The video also highlights the use of nmap, an open-source tool for vulnerability and port scanning, and discusses the evolution of port scanning to avoid detection. A basic scan is demonstrated in a virtual environment, using nmap commands to scan ports and analyze the results, including the identification of services running on open ports.

05:00

🕵️‍♂️ Analyzing TCP Open and SYN Scans with nmap

This section delves into the specifics of TCP open and SYN scans, two methods used to determine the status of network ports. The TCP open scan is explained as a full connection scan that leaves logs, while the SYN scan is a stealthier method that does not establish full connections, thus reducing the time required for scanning. The video demonstrates these scans using nmap, showing the commands used and the results obtained, including the identification of open ports and the services associated with them. It also discusses the use of Wireshark to analyze the packets exchanged during the scanning process.

10:01

🛡️ Stealth Scans and Their Impact on Network Security

The final paragraph discusses various stealth scanning methods, such as FIN, NULL, and Xmas scans, which are designed to avoid leaving traces in logs. These methods are similar in that they send packets with specific flags set and interpret the responses (or lack thereof) to determine if a port is open or closed. The video shows how to perform these scans using nmap and interprets the results, including the appearance of the 'filtered' keyword, which indicates that a response was not received but the port may still be open. The importance of understanding these stealth techniques is highlighted for both attackers looking to minimize their detection and defenders seeking to secure their networks.

Mindmap

Keywords

💡Port Scanning

Port scanning is the process of checking a range of IP addresses to identify open ports and the services running on them. In the context of the video, it is a fundamental technique used by both attackers to find potential vulnerabilities and by defenders to audit their systems for unintentionally open ports. The script mentions various types of port scans, such as TCP open scan and SYN scan, to illustrate how the process is carried out.

💡Open Port

An open port signifies a network communication endpoint that is listening for incoming connections. The video script emphasizes the importance of finding open ports as they can be used by attackers to gain access to a system. Examples from the script include ports 22, 23, and 80, which are found to be open and associated with specific services like SSH, a web server, and Apache.

💡Vulnerable Port

A vulnerable port is one that is open unintentionally by an administrator or is running a service that has known vulnerabilities. The script discusses how attackers look for such ports to exploit them, while defenders aim to identify and close them to mitigate risks.

💡Nmap

Nmap is an open-source network scanning tool that is widely recognized for its ability to perform port scanning and vulnerability detection. The video script highlights Nmap's popularity due to its ease of acquisition and the variety of functions it offers compared to other tools.

💡Stealth Scan

A stealth scan is a type of port scanning technique designed to avoid detection by not leaving logs on the target system. The script describes SYN scan as a form of stealth scan that does not fully establish a connection, thus reducing the chances of being noticed.

💡Three-Way Handshake

The three-way handshake is a process used in the TCP protocol to establish a connection between a client and a server. The script explains how this process is utilized in TCP open scans to verify if a port is open by completing the handshake or receiving a reset packet if the port is closed.

💡Attack Vector

An attack vector refers to a path or method that an attacker uses to compromise a system. The video script mentions that identifying open ports can reduce the attack vector by allowing attackers to focus on services running on those ports.

💡Netstat

Netstat is a command-line tool used to display network connections, routing tables, and interface statistics. In the script, it is used with the 'nltp' options to list ports that are currently serving the target, providing a snapshot of the listening ports and their associated services.

💡Packet Analysis

Packet analysis involves examining the data packets transmitted over a network to understand their structure, content, and behavior. The script describes using a tool like Wireshark to observe packets during a port scan, helping to understand the responses from the target system to the scan requests.

💡Filtered

In the context of port scanning, 'filtered' is a term used to describe a state where no response is received from a port, but it is not possible to determine if the port is open or closed due to possible firewalls or filters in place. The script mentions this term when discussing the results of certain stealth scans.

💡FIN Scan, NULL Scan, and XMAS Scan

These are specific types of stealth scans mentioned in the script that behave similarly for both open and closed ports. A FIN scan sets the FIN flag, a NULL scan sends packets without setting any flags, and an XMAS scan sets the FIN, PSH, and URG flags. The lack of response to these scans can indicate an open port, while a reset packet indicates a closed port.

Highlights

Port scanning is a technique for determining the status of ports on a device within a network, identifying open ports which can be exploited for access.

Open ports serve as potential entry points for gaining access to a system, making their identification crucial for both attackers and defenders.

Nmap is introduced as a well-known open-source tool for port scanning and network vulnerability assessment.

Port scanning methods have evolved to avoid detection, with stealth scans leaving no trace in logs.

Basic port scans can be tracked through logs, which is why stealthier methods like SYN scan have been developed.

A demonstration of port scanning using nmap in a virtual environment is provided to ensure safe practice.

The importance of conducting port scans within one's own network to avoid legal issues is emphasized.

Netstat command with specific options is used to list ports currently in use by the target, showcasing open ports and their services.

TCP open scan is explained as the basic method using three-way handshake to verify port status, leaving logs behind.

SYN scan, a stealth method, is detailed, which performs half of the three-way handshake without establishing a full connection.

A comparison of scanning times between TCP open scan and SYN scan shows SYN scan to be faster.

Wireshark analysis is used to illustrate the packet exchange during port scanning, showing the differences between open and closed ports.

The concept of 'filtered' state in port scanning is introduced, indicating no response but potential openness due to scanning method.

Advanced stealth scanning methods like FIN, NULL, and Xmas scans are introduced, which behave similarly for both open and closed ports.

FIN scan is explained as sending packets with the FIN flag to determine if a port is open based on the lack of response.

NULL and Xmas scans are detailed, where the absence of flags or specific flag combinations indicate open ports.

The video concludes by reiterating the importance of port scanning for network security and the evolution of scanning techniques to avoid detection.

Transcripts

play00:00

in this video we will look at the port

play00:02

scan techniques and practice

play00:05

process Port scanning is a method of

play00:08

determining whether the ports are open

play00:10

or closed on a specific device of a

play00:12

network finding an open port is

play00:14

important because it serves as a conduit

play00:16

for gaining access to the system Port

play00:19

scanning is like knocking on all open

play00:21

doors if a door opens it's a door that

play00:24

you can use the way it works is simple

play00:27

you can request a response to all ports

play00:29

of

play00:31

65,535 ports once and wait for the

play00:34

response the reason for checking the

play00:36

ports is to find any port that is opened

play00:38

unintentionally by the administrator a

play00:41

vulnerable Port left open for

play00:43

convenience or a port on which the

play00:45

vulnerable service is running an

play00:47

attacker can navigate the attack surface

play00:49

via port scan this reduces the attack

play00:52

vector by only attacking open ports on

play00:55

the other hand from the defender's point

play00:57

of view a port search can help to

play00:59

determine if there is an unintended

play01:01

surface and take an action in

play01:04

advance there are many tools that you

play01:06

can use to scan the port and nmap is a

play01:09

well-known tool for this nmap is an

play01:11

open-source program that can check for

play01:13

vulnerabilities in your network as well

play01:15

as Port scanning the reason why nmap is

play01:18

best known is that it is easy to acquire

play01:20

as an open source program and so there

play01:22

are many options and functions compared

play01:24

to other tools Port scanning is simply

play01:27

to check if the port is open and there

play01:29

are many other resources and ways to do

play01:30

it the reason why Port scans have

play01:33

evolved in so many ways is in order to

play01:35

avoid attack detection basic Port scans

play01:37

can be tracked through logs Port

play01:39

scanning has evolved in a way that

play01:41

leaves no Trace these attacks that scan

play01:43

a port without leaving a log or cold

play01:46

stealth scans nmap supports these

play01:48

different port scanning methods and is

play01:50

available with simple

play01:53

options however it is not recommended

play01:55

that you try a commercial server that is

play01:57

actually running when you're working

play01:59

with mmap

play02:00

a simple scan alone could even bring the

play02:02

server down and scanning a

play02:04

non-administrator port can be seen as an

play02:06

attack in this curriculum we will show

play02:09

you the practice process using

play02:12

nmap I will proceed with the scanning

play02:14

process in a separate virtual

play02:16

environment if anyone wants to practice

play02:19

please build a virtual environment of

play02:21

your own and proceed only within your

play02:22

own network if it is difficult to build

play02:25

an environment please scan your device

play02:27

using a loop pack IP is written in the

play02:29

sub title as I said earlier scans of

play02:32

commercial servers without proper

play02:34

permission in advance can be seen as

play02:36

attacks therefore be aware of external

play02:39

scanning attacks now let's take a look

play02:41

at the configuration of my environment

play02:44

Target's IP address is 1 192 1 168 123

play02:49

110 while the Hacker's IP address is 192

play02:53

1 1681 123

play02:56

106 the image below shows a list of

play02:59

ports currently serving the target you

play03:01

can check it with the netstat command

play03:03

and with the nltp

play03:06

option option n is the option to Output

play03:09

a number of Port serviced option L is an

play03:12

option that filters only the listening

play03:14

State option T is an option that filters

play03:17

only the TCP protocol option P prints

play03:20

the program name associated with that

play03:21

Port therefore the above result is a

play03:24

port list that uses the TCP protocol

play03:27

being listened to if you look closely

play03:29

you can see that Port 22 is connected to

play03:32

the SSH program you can also see that

play03:34

Port 23 is connected to a web server

play03:37

called in it and Port 80 is Apache to

play03:40

thus an attacker can perform a port scan

play03:43

before attacking the server to ensure

play03:44

that ports 22 23 and 80 are open an

play03:49

attacker who identifies an open port can

play03:52

reduce the scope of the attack vector by

play03:54

targeting only services that operate on

play03:56

that

play03:58

Port TCP open scan is the most basic

play04:01

method of Port scanning it uses the

play04:03

three-way handshaking to verify that the

play04:05

port is open it is also called TCP

play04:08

connection scan because it forms a

play04:09

connection through three-way handshaking

play04:12

however a connection leaves a log of

play04:14

session establishment in the Target

play04:16

which can be an important clue during

play04:19

Post tracking request syy end packet is

play04:22

the first step of the 3way handshaking

play04:24

for Port scanning if the port is open Sy

play04:27

YN AK packets will will be answered and

play04:30

the last AK will be sent on the other

play04:33

hand if the port is closed the rst AK

play04:37

packet is

play04:39

answered this is a TCP open scan

play04:42

practice I ran an nmap application on

play04:45

hackers PC I use the St option which

play04:48

means it is for TCP open scan for the

play04:50

Target IP address I entered 192 1 168

play04:55

123 110 the results are successful we

play05:00

have identified that the previously

play05:01

checked ports 22 23 and 0 are open we

play05:06

also identified the services that

play05:08

operate on every listed Port

play05:11

additionally the more interesting part

play05:13

is the scanning time in the last line

play05:16

you can see that it took a total of 2.3

play05:18

seconds to navigate the port with TCP

play05:20

open

play05:22

scan this time when the port scan is in

play05:26

progress I will check on the packets the

play05:28

left side is the screen that shows the

play05:30

list of wies shock packets and the right

play05:32

side is the action that we want to

play05:34

understand in wies shock let's start by

play05:36

looking at the Port when they are closed

play05:39

if the port is closed nsyn request is

play05:41

made as shown on the right and the rst a

play05:45

packet is answered now let's take a look

play05:47

at the

play05:49

packets to facilitate analysis it is

play05:52

recommended that you know both the

play05:53

hackers and the target's IP addresses

play05:56

also it will be helpful to analyze if

play05:58

you know the IP addresses of the source

play06:00

and destination and where the packet is

play06:02

directed when you view the packet note

play06:05

the direction of the packets by

play06:06

referring to the IPS in the source and

play06:08

the destination columns along with the

play06:10

info column on the right first of all if

play06:13

you look at the gray packets you can see

play06:15

that Hacker's device sent the packet to

play06:17

the target's device as shown in the info

play06:20

column we are requesting SN packets for

play06:23

several well known ports now let's look

play06:26

at the red packet as opposed to the

play06:29

previous one you can see that it is a

play06:31

packet scent from the target to the

play06:32

Hacker's device if you look at the info

play06:35

column you can see that rst AK packets

play06:38

are being answered on the ports that you

play06:40

requested

play06:42

earlier this time the port is open in

play06:45

the TCP open scan as I explained when

play06:48

the port is open it will perform the

play06:50

three-way shaking process as it is pause

play06:53

the image and analyze the packet let's

play06:55

move on to the left wire shock screen

play06:58

focus on the packets in lines 3 4 and 7

play07:01

The Hacker sent SN packets to the Target

play07:03

via ports 22 23 and 8 respectively

play07:08

because ports 22 23 and8 are opened you

play07:12

must respond with an syn a packet to the

play07:15

AK packet the fifth sixth and eighth

play07:19

packets are those sent from Target to

play07:21

the hacker and syn AK packets were sent

play07:25

from 22 23 and 80 as I just requested it

play07:29

doesn't end here it should eventually

play07:32

send an NE packet to establish a session

play07:35

if you look at the 9th 11th and 13

play07:38

packets you can see that the C packet is

play07:40

being sent back to the port that is

play07:42

serving the attacker as

play07:45

expected next one of the stealth scans

play07:48

is the SN scan because it is classified

play07:51

as a stealth scan it does not leave

play07:53

behind any logs the principle is simple

play07:57

similar to TCP open scan it initially

play07:59

sends SN packets if the port is closed

play08:03

it receives an rst a response just like

play08:07

the TCP open scan if the port is open

play08:10

the server responds with an syn A C

play08:13

packet to proceed with the three-way

play08:14

handshake if it was a TCP open scan it

play08:18

would have sent an packet here but the S

play08:20

YN scan sends an rst packet to terminate

play08:23

the communication it's also called the

play08:26

CP half open scan because it uses a

play08:28

three-way hand but it's not fully

play08:32

established this is a practice of SN

play08:35

scan the hacker PC used the SS command

play08:38

option in mmap which means s YN scan for

play08:41

the Target IP I entered

play08:43

192

play08:45

16823 110 which is the IP of a Target

play08:49

the result was also successful this time

play08:52

we have also identified that the

play08:54

previously checked ports 22 23 and 80

play08:58

are open we also identified the services

play09:01

that operate on that Port as

play09:04

well let's check out the time again you

play09:07

can see that it took a total of 1.4

play09:09

seconds to navigate through the port

play09:11

with syn scan you can see that it is

play09:14

much faster than the 2.3 seconds

play09:17

required for the TCP open scan during

play09:20

the previous TCP open scan we sent the a

play09:22

CK packet and terminated the connection

play09:25

immediately with the rst a packet in

play09:28

contrast syn scan is the one that sends

play09:31

the rst packets instead this means that

play09:34

there is no connection process so the

play09:36

scan process is simplified and the time

play09:38

is

play09:40

shortened when the SN scan is in

play09:43

progress I will check on the packets if

play09:45

the port is closed and S YN request is

play09:48

made as shown on the right and the rst

play09:51

AK packet is answered now let's take a

play09:54

look at the packets first of all if you

play09:56

look at the gray packets you can see

play09:58

that hackers device sent the packets to

play10:00

the targets device as shown in the info

play10:03

column we are requesting syn packets for

play10:05

several well-known ports now let's look

play10:09

at the red packet as opposed to the

play10:11

previous one you can see that it is a

play10:13

packet scent from the target to the

play10:15

Hacker's device if you look at the info

play10:18

column you can see that rst CK packets

play10:21

are being answered on the ports that you

play10:23

requested

play10:25

earlier this time the port is open in

play10:28

syn scan as I explained the principle is

play10:31

that when the port is open only half of

play10:33

the threeway handshake process is

play10:35

performed pause the image and analyze

play10:38

the packets let's look at the left wire

play10:40

shark screen focus on the packets on the

play10:43

third fifth and sixth lines the hacker

play10:46

sent Sy YN packets to the Target through

play10:48

ports 22 23 and 80 respectively since

play10:53

the three ports are actually open ports

play10:55

they will respond with SN AK packets

play10:59

look at the fourth seventh and eighth

play11:02

packets this is the packet sent from the

play11:05

target to the hacker and the S YN AK

play11:08

packets are sent from ports 22 23 and 80

play11:13

just as I just requested now that you

play11:16

have verified that the port is open

play11:18

there is no longer a need to continue

play11:20

communicating look at the bottom three

play11:22

lines of packets you can see the hacker

play11:25

sent the rst packets to the Target to

play11:27

end the session

play11:30

next I would like to introduce many of

play11:33

the famous methods of stealth scanning

play11:35

there are the fin scan n scan and xmus

play11:38

scan these three scanning methods are

play11:41

grouped together because they behave

play11:42

very similar for both open and closed

play11:44

ports first a fin scan is literally

play11:47

setting a fin flag and sending it to the

play11:49

Target if the port is open no response

play11:52

is received but if the port is closed

play11:55

the rst packet is received the no scan

play11:57

also declares that the port is open when

play11:59

there is no response and that the port

play12:01

is closed when it receives an rst

play12:04

response when you scan the transmitting

play12:06

packets it sends without setting any

play12:08

Flags the XMS scan sends packets with

play12:11

Fin psh and urg flag set similarly if

play12:16

there is no response it is considered

play12:18

open and if an rst packet is received it

play12:21

is considered

play12:23

closed these are the images of

play12:25

practicing the three stealth scans

play12:28

hackers PC used the SF SN and SX command

play12:32

options in nmap which stands for Finn

play12:35

null and XM scan respectively for the

play12:37

Target IP I entered

play12:40

192 168 123 110 the results are all

play12:46

successful we have identified that the

play12:49

previously checked ports 22 23 and 80

play12:53

are all open we also have a good

play12:56

understanding of the services that work

play12:57

on the ports one and new usual thing is

play12:59

that Port scanning is a method of

play13:01

determining whether the ports are open

play13:03

or closed on a specific device of a

play13:05

network finding an open port is

play13:08

important because it serves as a conduit

play13:10

for gaining access to the system Port

play13:12

scanning is like knocking on all open

play13:14

doors if a door opens it's a door that

play13:18

you can use the way it works is simple

play13:21

you can request a response to all ports

play13:23

up to

play13:25

65,535 Ports once and wait for the

play13:27

response

play13:30

the reason for checking the ports is to

play13:31

find any port that is opened

play13:33

unintentionally by the administrator a

play13:36

vulnerable Port left open for

play13:38

convenience or a port on which the

play13:40

vulnerable service is running an

play13:42

attacker can navigate the attack surface

play13:44

via port scan this reduces the attack

play13:47

vector by only attacking open ports on

play13:50

the other hand from the defender's point

play13:52

of view a port search can help to

play13:54

determine if there is an unintended

play13:56

surface and take an action in advance

play13:58

the keyword filtered was added to the

play14:00

state entry the filtered keyword is a

play14:03

keyword that appears when you don't

play14:04

receive a response but if you think

play14:06

about the scanning method you can see

play14:08

why the keyword appears all fin no XMS

play14:12

scans do not respond to determine that

play14:14

they are open therefore we decided that

play14:17

the port was open because there was no

play14:19

response but we specified the keyword

play14:21

filtered because there was no response

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
Port ScanningNetwork SecurityNmap ToolTCP HandshakesStealth ScansCyber DefenseHacking TechniquesOpen PortsSecurity AnalysisVulnerability Assessment
هل تحتاج إلى تلخيص باللغة الإنجليزية؟