Penetration Testing with Kali Linux
PWK - Copyright © 2023 OffSec Services Limited. All rights reserved.
139
client network such as overloading servers and network links or triggering an IDS/IPS.
251
Running
the wrong scan could result in downtime for the customer.
Using a proper port scanning methodology can significantly improve our efficiency as penetration
testers while also limiting many of the risks. Depending on the scope of the engagement, instead
of running a full port scan against the target network, we can start by only scanning for ports 80
and 443. With a list of possible web servers, we can run a full port scan against these servers in
the background while performing other enumeration. Once the full port scan is complete, we can
further narrow our scans to probe for more and more information with each subsequent scan.
Port scanning should be understood as a dynamic process that is unique to each engagement.
The results of one scan determine the type and scope of the next scan.
We’ll begin our exploration of port scanning with a simple TCP and UDP port scan using Netcat. It
should be noted that Netcat is not a port scanner, but it can be used as such in a rudimentary way
to showcase how a typical port scanner works.
Since Netcat is already present on many systems, we can repurpose some of its functionality to
mimic a basic port scan when we are not in need of a fully-featured port scanner. We will also
explore better tools dedicated to port scanning in detail.
Let’s start by covering TCP scanning techniques, focusing on UDP later. The simplest TCP port
scanning technique, usually called CONNECT scanning, relies on the three-way TCP handshake
252
mechanism. This mechanism is designed so that two hosts attempting to communicate can
negotiate the parameters of the network TCP socket connection before transmitting any data.
In basic terms, a host sends a TCP
SYN
packet to a server on a destination port. If the destination
port is open, the server responds with a
SYN-ACK
packet and the client host sends an
ACK
packet
to complete the handshake. If the handshake completes successfully, the port is considered
open.
We can demonstrate this by running a TCP Netcat port scan on ports 3388-3390. We’ll use the -w
option to specify the connection timeout in seconds, as well as -z to specify zero-I/O mode, which
is used for scanning and sends no data.
kali@kali:~$
Yüklə
Dostları ilə paylaş: