2 Scanning
2 Scanning
1 Introduction
SYN
SYN+ ACK
ACK
Time Time
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
During the first step, the client sends a TCP packet to the
server. This packet has the SYN flag enabled and a random
sequence number set.
SYN
SYN
Seq: 329 Ack: 0
Time Time
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
In the second step, the server replies by sending a packet
with both the SYN and ACK flag set and contains another
random sequence number.
SYN
SYN
Seq: 329 Ack: 0
SYN/ACK
Seq: SYN+
498 Ack:
ACK330
Time Time
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
The ACK number is always a simple increment of the SYN
number sent by the client.
SYN
SYN
Seq: 329 Ack: 0
SYN/ACK
Seq: SYN+
498 Ack:
ACK330
Time Time
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
Finally, the client completes the synchronization by sending
an ACK packet. Note that the client behaves just like the
server when sending ACK packets.
SYN
SYN
Seq: 329 Ack: 0
SYN/ACK
Seq: SYN+
498 Ack:
ACK330
ACK
Seq: 330 Ack: 499
Time Time
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
This is the process that makes TCP/IP such a reliable protocol.
Knowing how hosts communicate via TCP and UDP can help
testers in analyzing packet traces and identifying the
responses in discovery scans.
Before inspecting tools and techniques that will allow us to
scan remote hosts, in the next video we will study a very
important packet analyzer software: Wireshark.
4 packets
Continue…
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
And getting to something like this!
Nmap tells us that port 135 is open. This means that the
target probably sent a SYN-ACK in response to our SYN.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
While inspecting the traffic with Wireshark, we can see that
we start the communication setting the SYN flag (packet #6);
the remote host responds with a SYN-ACK (#7) and then we
close the connection by sending a RST flag (#8).
Remember that -sS does not open a full TCP connection.
As you can see above, Nmap tells us that the port is closed.
Once again let us inspect the traffic with Wireshark to see the
details.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
As we can see from the screenshot above, this time we sent
the packet with the SYN flag enabled and the remote
machine responds with a RST-ACK.
This means that the port is closed and does not accept any
communication.
SYN|ACK
RST Ip FragID=100
SYN SRC IP: «Zombie»
SYN|ACK
RST Ip FragID=101
SYN|ACK
SYN|ACK
RST Ip FragID=100
SYN SRC IP: «Zombie»
RST
SYN|ACK
Note
You can see a detailed list of every packet sent and received with Nmap by
using the --packet-trace option.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
If you want to dig deeper in the details about how to both use
Nmap to perform idle scans and, how this technology is
implemented, then you should study the Nmap
documentation at the following link:
http://nmap.org/book/idlescan.html.
Relative ID:
Likely a good
candidate
Let us now see a video that explains the steps used in order
to run this scanning technique.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
Although Nmap is the most popular tool for both network
discovery and security auditing, there are many other tools
freely available online that are very similar:
• Angry IP Scanner (Linux, Windows, Mac OS X)
• Masscan (Linux, Mac OS X, Windows)
• SuperScan (Windows)
We will not study these tools during this course however, we
do encourage you to try them in Hera lab in order to both see
how they work and what features they offer.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
During the previous phases of the assessment, we should
have gathered a list of not only alive hosts (in the target
network) but also, information about open and closed ports
for each host.
The next step is to identify which services are running on
these ports. This is a very important step simply because it
allows us to narrow down our attack surface. It gives us the
last bit of information necessary to begin researching
potential exploits on the target systems.
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
There are different techniques that tools like Nmap use to
identify a service running on a specific port. The easiest way
to do this is a process known as banner grabbing.
The term banner refers to the message that the service,
running on the target host, sends back when another host
tries to establish a connection to it. Many banners contain
information such as the current version of the service
(commonly default settings).
netcat
nc 192.168.0.25 22
telnet
telnet 192.168.0.25 22
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
--version-intensity <level>: 0 (light) 9 (all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity
Active OS Sends packets and waits for a response (or lack of one). Active
fingerprinting OS fingerprinting sometimes sends unexpected packets, because
different implementations respond differently to such errors.
With fragmentation
where:
• -T2 tells Nmap to send the probes every 0.4 sec
• --max-retries 1 tells Nmap to resend the probe only
one time (if the host does not respond)
• -p can be used to scan only specific ports
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
The following screenshot shows the traffic sent. As you can
see, the probes are sent every 0.4 seconds. Moreover, if the
host does not respond, Nmap tries the probe once more.
Packet Analysis
TCP/IP Tutorial
Reference Guide
Hping Nping
Nmap: Scanning
Nmap
techniques
Professional Penetration Testing 4.0 - eLearnSecurity © 2016
Fragmentation ID Nmap Idlescan
AngryIPScanner Masscan
SuperScan Telnet
Fingerprinting
OS Detection Techniques
Methodologies