Chapter 3 Scanning Networks
Chapter 3 Scanning Networks
to IP packets. Because of UDP’s simplicity, UDP headers contain fewer bytes and
consume less network overhead than TCP. Following diagram shows the TCP header: -
Flag filed in the TCP header is of 9 bits. Which includes the following 6 TCP flags: -
Flag Use
SYN Initiates a connection between two hosts to facilitate communication.
ACK Acknowledge the receipt of a packet.
URG Indicates that the data contained in the packet is urgent and should process
immediately.
PSH Instructs the sending system to send all buffered data immediately.
FIN Tells the remote system about the end of the communication. In essence, this
gracefully closes a connection.
RST Reset a connection.
Table 3-01 TCP Flags
There is three-way handshaking while establishing a TCP connection between hosts. This
handshaking ensures successful, reliable and connection-oriented session between these
hosts. The process of establishment of a TCP connection includes three steps. As shown
in the figure below: -
Consider Host A wants to communicate with Host B. TCP Connection establishes when
host A sends a Sync packet to host B. Host B upon receipt of Sync packet from Host A,
reply to Host A with Sync+Ack packet. Host A reply with Ack packet when it receives
Sync+Ack packet from host B. After successful handshaking results in the establishment
of TCP connection.
U.S Dept proposes TCP/IP model. Of Defence by combining OSI Layer Model and DOD.
The Transmission Control Protocol (TCP) and the Internet Protocol (IP) are two of the
network standards that define the Internet. IP defines how computers can get data to
each other over a routed, interconnected set of networks. TCP defines how applications
can create reliable channels of communication across such a network. IP defines
addressing and routing, while TCP defines how to have a conversation across the link
without garbling or losing data. Layers in TCP/IP model perform similar functions with
similar specifications like in OSI model. The only difference is they combine top three
layers into a single Application Layer.
Creating Custom Packet Using TCP Flags
Colasoft Packet Builder software enables to create the customized network packets. These
Customized Network packets can penetrate the network for attacks. Customization can
also use to create fragmented packets. You can download the software from
www.colasoft.com.
Colasoft packet builder offers Import and Export options for a set of packets. You can also
add a new packet by clicking Add/button. Select the Packet type from the drop-down
option. Available options are: -
ARP Packet
IP Packet
TCP Packet
UDP Packet
After Selecting the Packet Type, now you can customize the packet, Select the Network
Adapter and Send it towards the destination.
Scanning Methodology
The Scanning Methodology includes the following step: -
Checking for live systems
Discovering open ports
Scanning beyond IDS
Banner grabbing
Scanning Vulnerabilities
Network Diagram
Proxies
The host having IP address 192.168.0.2/24 is trying to identify if the Host 192.168.0.1/24 is
live by sending the ICMP Echo packets targeted to the destination IP address 192.168.0.1.
If the destination host successfully responds to ICMP Echo packets, the host is live.
If the host is not live, Observe the following response of ICMP Echo packets.
ICMP Scanning
ICMP Scanning is a method of identifying live hosts by sending ICMP Echo requests to a
host. ICMP Echo reply packet from host verify the host is live. Ping Scanning is a useful
tool for not only identification of live host, but also for determining ICMP packet are
passing through firewalls, and TTL value.
Ping Sweep
Ping Sweep determines live host on a large scale. Ping Sweep is a method of sending
ICMP Echo Request packets to a range of IP addresses instead of sending one by one
requests and observing the response. Live hosts respond with ICMP Echo Reply packets.
Thus, instead of probing individually, we can probe a range of IPs using Ping Sweep.
There are several tools available for Ping Sweep. Using these ping sweep tools such as
SolarWinds Ping Sweep tool or Angry IP Scanner, you can ping the range of IP addresses.
Additionally, they can perform reverse DNS lookup, resolve hostnames, bring MAC
addresses, and Scan ports.
Upon successful response from the targeted host, If the command successfully finds a live
host, it returns a message indicating that the IP address of the targeted host is up, along
with the media access control (MAC) address and the network card vendor.
Apart from ICMP Echo Request packets and using ping sweep, nmap also offers a quick
scan. Enter the following command for quick scan: -
Nmap in a nutshell, offers Host discovery, Port discovery, Service discovery. Operating
system version information. Hardware (MAC) address information, Service version
detection, Vulnerability & exploit detection using Nmap scripts (NSE).
Procedure:
Performing ping scans the network 10.10.50.0/24, listing machines that respond to ping.
Command: nmap –sP 10.10.50.0/24
Now, scanning for Operating System details of target host 10.10.50.210. We can scan for all
host using command nmap –O 10.10.50.*
Command: nmap –O 10.10.50.210
Commands:
To create an ACK packet:
root@kali:~# hping3 –A 192.168.0.1
Scanning Techniques
Scanning techniques include UDP & TCP Scanning technique. Observe the following
figure showing the classification of Scanning techniques: -
While using Full Open Scanning and a Closed port is encountered, RST response is sent
to the incoming request to terminate the attempt. To perform Full Open Scan, you must
use -sT option for Connect Scan.
Type the command to execute Full Open Scan: -
For example, observe the output shown in the figure below, using Zenmap tool to
perform Full Open Scan.
Xmas Scan
Xmas Scan is the type of scan in which contains multiple flags. Packet sent to the target
along with URG, PSH & FIN; or a packet having all flags creates an abnormal situation for
the receiver. Receiving system has to take a decision when this condition occurs. Closed
port responds with single RST packet. If the port is open, some systems respond as an
open port, but the modern system ignores or dropped these requests because the
combination of these flags is bogus. FIN Scan works only with Operating Systems with
RFC-793 based TCP/IP Implementation. FIN Scan does not work with any current version
of Windows typically Windows XP or later.
Procedure:
Open Windows Server 2016 & verify if the firewall is enabled.
Open a terminal on your Kali Linux & enter the following command:
Observe the output as shown above in the figure, all scanned ports are Open & Filtered.
It means the firewall is enabled. A firewall basically not respond these packet hence
assumed as Open & filtered ports.
In this case, the firewall is disabled, hence showing all ports as closed.
FIN Scan
FIN Scan is the process of sending the packet having only FIN flag set. These packets can
reliably pass the firewall. FIN Scan packets, when sent to the target, the port is considered
to be open if there is no response. If the port is closed, RST is returned.
To perform this type of scan, use the syntax:
NULL Scan
NULL Scan is the process of sending the packet without any flag set. Responses are
similar to FIN and XMAS Scan. If Null Scan packet sends to an open port, it brings no
response. If Null Scan packet sends to the closed port, it brings RST packet. Performing
this scan is comparatively easier to be detected as there is logically no reason to send a
TCP packet without any flag.
To perform this type of scan, use the syntax:
ACK Probe scanning also helps in identifying the filtering system. If RST packet receives
from the target, it means that packets toward this port are not filtering. If there is no
response, it means Stateful firewall is filtering the port.
Step: 01
Send Sync+Ack packet to Zombie to get its IPID Number.
Zombie is not waiting for Sync+Ack, hence respond with RST packet. Its Reply
discloses the IPID.
Extract IPID from Packet.
Step: 02
Send Sync packet to target spoofing the IP address of Zombie.
IP port is open; Target reply with Sync+Ack to Zombie & Zombie reply back to target
with RST packet.
If the port is closed; Target reply with RST to Zombie & Zombie reply nothing back to
target. IPID of Zombie is not incremented.
Step: 03
Send Sync+Ack packet to Zombie again, to get & compare its IPID Numbers to IPID
extracted in step 01 (i.e. 1234).
Zombie responds with RST packet. Its Reply discloses the IPID.
Extract IPID from Packet.
Compare the IPID.
Port is open if IPID is incremented by 2.
UDP Scanning
Like TCP-based scanning techniques, there are also UDP Scanning methods. Keeping in
mind, UDP is a connectionless protocol. UDP does not have flags. UDP packets are
working with ports; no connection orientation requires. No response if the targeted port
is open however if the port is closed, the response message of "Port unreachable"
returned. Most of the Malicious Programs, Trojans, Spywares uses UDP ports to access
the target.
Scanning Tool
NetScan Tools Pro is an application which collects information, perform network
troubleshooting, monitors, discover and diagnose with its integrated tools designed for
Windows Operating system offering a focused examination of IPv4, IPv6, Domain names,
Email and URL using Automatic and Manual Tool.
Network Scanner
“Network Scanner” tool offering IP Calculator, DNS lookup, Whois tool, Traceroute &
Port Scanner option.
Xprobe
pof
Maltego
Mind Map
perform discovery of routes, TCP/IP nodes using DNS, ports, and other network
protocols. List of some popular tools are: -
1. Network Topology Mapper
2. OpManager
3. Network View
4. LANState Pro
After complete scan process, it will show a list of detected devices to add into topology
diagram. Select all or required devices to add to the topology.
Topology view of the scanned network. Now you can add nodes manually, export it to
Vision and use other features of the tool.
Prepare Proxies
Proxy is the system that is stands in between attacker and the target. Proxy systems play
an important role in networks. Proxy systems are basically used by scanners to hide their
identity to be traced back to the target.
Proxy Servers
Proxy server anonymizes the web traffic to provide anonymity. When a user sends a
request for any resources to the other publically available servers, proxy server act as an
intermediary for these requests. Users request is forwarded to proxy server first. the proxy
server will entertain these requests like a web page, file download, connection to another
server, etc. The most popular use of the proxy server is in terms of web proxy servers.
These Web proxy servers are used to provide access to world wide web by bypassing the
IP address blocking.
Uses Proxy server, in a nutshell, can be summarized as: -
Hiding Source IP address for bypassing IP address blocking.
Impersonating.
Remote Access to Intranet.
Redirecting all requests to the proxy server to hide identity.
Proxy Chaining to avoid detection.
Proxy Chaining
Proxy Chaining is basically a technique of using multiple proxy servers. In addition to
proxy servers, one proxy server forwards the traffic to next proxy server. This process is
not recommended for production environments, or a long-term solution, however, this
technique leverages your existing proxy.
Proxy Tool
There is a number of proxy tools available as well as you can online search for a proxy
server and configure manually on your web browser. These tools include: -
1. Proxy Switcher
2. Proxy Workbench
3. TOR
4. CyberGhost
Proxy Switcher
Proxy Switcher tool scans for Available proxy servers. You can enable any proxy server to
hide your IP address. The following figure is showing the searching process of Proxy
servers using Proxy Switcher tool.
Introduction to Anonymizers
Anonymizer is a tool that completely hides or removes identity-related information to
make the activity untraceable. The basic purpose of using anonymizers are: -
Minimizing risk
Identity theft prevention
Bypass restrictions and censorship
Untraceable activity on the Internet
Censorship Circumvention Tool
Tails
Tails (The Amnesic Incognito Live System) is a popular censorship circumvention tool
based on Debian GNU/Linux. It is basically a live operating system that can run on
almost every computer from USB or DVD. It is an operating system that is specially
designed to help you to use the internet anonymously leaving no trace behind. Tails
preserve privacy and anonymity.
Anonymizers for Mobile
Orbot
Psiphon
Open door
Spoofing IP Address
IP Address Spoofing is a technique, that is used to gain unauthorized access to machines
by spoofing IP address. An attacker illicitly impersonates any user machine by sending
manipulated IP packets with spoofed IP address. Spoofing process involves modification
of header with a spoofed source IP address, a checksum, and the order values. Packet-
switched networking causes the packets arriving at the destination in different order.
When these out of order packets are received at the destination, these packets are
resembled to extract the message.
IP spoofing can be detected by different techniques including Direct TTL probing
technique and through IP Identification Number. In the process of sending direct TTL
probes, packets are sent to the host that is suspected of sending spoofed packets and
responses are observed. By comparing TTL value from the reply from the suspected host,
IP spoofing can be detected. It will be a spoofed packet if TTL value is not same as in
spoofed packet. However, TTL values can vary in even normal traffic and this technique
identify the spoofing when the attacker is on a different subnet.
Similarly, additional probes are sent to verify the IPID of the host. If IPID values are not
closer, suspect traffic is spoofed. This technique can be used in case if the attacker is
within a subnet.