Advanced Covert Scanning Techniques
In this step, we're going to explore more advanced scanning techniques that offer an even higher level of stealth. These techniques are crucial in cybersecurity because they allow you to gather information about a target network without easily being detected. One such powerful technique is the Idle Scan, also known as the Zombie Scan. This method enables you to scan a target while masking your identity behind another host.
Before we start, it's important to ensure that you are in your workspace. This is where all your project - related files and commands will be executed. To navigate to your workspace, run the following command in your terminal:
cd /home/labex/project
Understanding Idle Scanning
The Idle Scan is one of the most stealthy scanning techniques available in Nmap. But how does it work? Well, it uses a third - party host, which we call a "zombie", to carry out the scan. This makes it seem like the scan is coming from the zombie host instead of you.
Let's break down the process of an Idle Scan step by step:
- First, the scanner sends a probe to the zombie host. This probe helps the scanner figure out the current IP ID sequence of the zombie. The IP ID sequence is a unique number that the host assigns to each IP packet it sends.
- Next, the scanner sends a SYN packet to the target. However, it sets the source IP address of this packet to be the IP address of the zombie. A SYN packet is used to initiate a TCP connection.
- If the port on the target is open, the target will respond with a SYN - ACK packet. This packet is sent to the zombie because that's the source IP address it saw in the SYN packet.
- The zombie, which wasn't expecting this SYN - ACK packet, will send a RST packet back to the target. A RST packet is used to reset a TCP connection.
- The scanner then probes the zombie again. It checks if the IP ID sequence of the zombie has increased.
- If the IP ID sequence has incremented, it indicates that the port on the target is open. This is because the zombie sent a RST packet in response to the SYN - ACK from the target.
The beauty of this technique is its stealth. The target only sees communication coming from the zombie, not from the actual scanner. So, it's very difficult for the target to detect that it's being scanned.
Executing an Idle Scan
Now, let's execute an idle scan using Nmap. In a real - world situation, you would use an external zombie host. But for this lab, we'll simulate the process using your local machine.
Run the following command in your terminal:
sudo nmap -sI 127.0.0.1 localhost -p 8080 > /home/labex/project/idle_scan.txt
Let's understand each part of this command:
sudo is used because Nmap needs raw socket access to perform the idle scan. Raw socket access allows Nmap to create and send custom IP packets, which is necessary for this type of scan.
nmap is the well - known scanning tool that we're using for this task.
-sI 127.0.0.1 specifies that we're performing an idle scan and using 127.0.0.1 (which is the localhost) as the zombie host.
localhost is the target that we want to scan.
-p 8080 tells Nmap to only scan port 8080 on the target.
> /home/labex/project/idle_scan.txt redirects the output of the scan to a text file. This way, we can easily review the results later.
After running the scan, let's examine the results. Use the following command to view the contents of the output file:
cat /home/labex/project/idle_scan.txt
You might see output similar to this:
Starting Nmap 7.80 ( https://nmap.org ) at 2023-10-25 12:10 UTC
Idle scan using zombie 127.0.0.1 (127.0.0.1:80); Class: Incremental
Skipping Idle Scan against localhost (127.0.0.1) -- you can't idle scan your own machine (localhost).
Nmap scan report for localhost (127.0.0.1)
Host is up.
PORT STATE SERVICE
8080/tcp unknown http-proxy
Nmap done: 1 IP address (1 host up) scanned in 2.03 seconds
Notice that Nmap reports that it's skipping the idle scan. This is because you're trying to use your own machine as both the zombie and the target. In a real - world scenario where you have separate hosts, this technique would be very effective for covert scanning.
Even though we have this limitation in our lab environment, this exercise still shows you how to use the idle scan command. In practice, you would choose a different host as the zombie, and the scan would run without this warning message.
This advanced technique is very valuable when you need maximum stealth. It makes it extremely difficult for the target to trace the scan back to the actual scanner.
Comparing Scan Results
Let's compare the outputs of both scan types to see the differences:
echo "=== Stealth Scan Results ===" && cat /home/labex/project/stealth_scan.txt
echo "=== Idle Scan Results ===" && cat /home/labex/project/idle_scan.txt
Both scans successfully detected the open port 8080, but the idle scan shows additional information about the scanning technique being used.
Clean Up
Before finishing, let's clean up our environment by stopping the web server:
pkill -f "nc -lvp 8080"
This terminates the netcat process running our web server on port 8080.