If you’re planning on taking the Security+ exam, you should have a basic understanding of port scan attacks.
For example, can you answer this question?
Q. You want to identify all of the services running on a server. Which of the following tools is the BEST choice to meet this goal?
A. Penetration test
B. Protocol analyzer
C. Sniffer
D. Port scanner
More, do you know why the correct answer is correct and the incorrect answers are incorrect? The answer and explanation is available at the end of this post.
Anatomy of an Attack
From a defensive perspective, it’s valuable to understand how attackers operate. Many penetration testers use similar methodologies, so you can also apply this knowledge to penetration testing. Although there is no single definition that identifies all attackers, one thing is clear: Attackers are sophisticated and clever. They should not be underestimated.
Imagine an organization that has unlimited funds to launch attacks. They could be government employees employed by another country, or they could be a group of criminals. They may be trying to steal secrets or steal some of the millions of dollars that attackers are pocketing from businesses and individuals monthly. How will they go about it?
They often combine reconnaissance with fingerprinting techniques to identify targets. Reconnaissance provides a big-picture view of a network, including the Internet Protocol (IP) addresses of a target network. Fingerprinting then homes in on individual systems to provide details of each. Some of the attackers may be experts on reconnaissance, while others are experts on different elements of fingerprinting. Once they identify their targets, attackers use this information to launch an attack.
Identifying Open Ports with a Port Scanner
One group in the organization takes the list of IP addresses and identifies open ports on each system. As a reminder, many protocols use well-known ports. For example, Telnet uses port 23 and Hypertext Transfer Protocol (HTTP) uses port 80. If a port scanner detects port 80 is open, it’s likely that the HTTP protocol is running and it may be a web server.
Additionally, ports also identify applications running on a system. For example, peer-to-peer (P2P) software, used for file sharing, uses specific ports for communications with other peers on the Internet. A port scan can discover these ports and detect P2P software running on a system.
A common Transmission Control Protocol (TCP) port scan sends a TCP SYN (synchronize) packet to a specific port of a server as part of the TCP three-way handshake. If the server responds with a SYN/ACK (synchronize/acknowledge) packet, the scanner knows the port is open. However, instead of completing the three-way handshake, the scanner can send an RST (reset) packet to reset the connection and then repeat the process with a different port.
Even though it’s not recommended for services to use ports other than the well-known ports for specific services, it is possible. Because of this, an open port doesn’t definitively say the related service or protocol is running.
Some port scanners send additional queries to the system’s open ports. For example, if port 25 is open, indicating it’s running Simple Mail Transfer Protocol (SMTP), the scanner can send SMTP queries to the system and analyze the response. These queries provide verification that the protocol is running and often include additional details on the system. Similarly, HTTP queries can identify if it’s a Windows Internet Information Services (IIS) web server or an Apache web server running on a Linux system.
Each open port represents a potential attack vector, so by identifying open ports, attackers can determine the attack surface. As a reminder, you can reduce the attack surface by disabling all unused services and removing all unneeded protocols. This is a key step in hardening a system, or making it more secure from the default configuration.
Many vulnerability-scanning tools like Nmap, Netcat, and Nessus include port-scanning abilities and scan systems to determine open ports. Security professionals use these tools for vulnerability scans within their networks, but attackers also use these same tools. In addition to scanning for open ports, these tools can also fingerprint a system.
Remember this
A port scanner can help determine what services and protocols are running on a remote system by identifying open ports. Port scanners typically take additional steps to verify the port is open.
Q. You want to identify all of the services running on a server. Which of the following tools is the BEST choice to meet this goal?
A. Penetration test
B. Protocol analyzer
C. Sniffer
D. Port scanner
Answer is D. A port scanner identifies open ports on a system and is commonly used to determine what services are running on the system.
A penetration test attempts to exploit a vulnerability.
A protocol analyzer (also called a sniffer) could analyze traffic and discover protocols in use, but this would be much more difficult than using a port scanner.