Back to Blog

Port Scan Attack Review

Jul 9, 20264 min readNetwork Attacks · Port Scan

Port scanning is a common method attackers use to scope out their target environment by sending packets to specific ports on a host and using the responses to identify vulnerabilities and determine which services and service versions are running. Generally, port scanning tries to classify ports into one of three categories:

  • Open: In this case, the destination responds with a packet, meaning it is listening on that port and the service used to scan (generally TCP or UDP) is being used.

  • Closed: This means that the destination received the packet but does not have the service listening at the port.

  • Filtered: The packet was filtered by a firewall, or the service listening on that port didn't receive an acceptable traffic format, so there is no reply.

Common Port Scan Techniques

  • TCP SYN Scans: Also called a half-open scan. In this type, the attacker sends SYN packets; if a SYN/ACK is received, the port is open; if an RST response is received, the port is closed. No reply means a firewall protects the port.

  • UDP Scan: UDP scans send a packet to ports on a target system and use the response to determine if the port is open, closed, or filtered.

  • Ping Scan: The simplest port scanning technique. Ping scans send multiple ICMP requests to various servers to obtain responses.

Dectection

There are some common ways to detect portscan attacks in such CIC-based datasets like CIC-IDS2017, CIC-IDS2018, ... Here are some of these ways:

  • Signature Based: Basically, it can be easily detected based on these signatures: No complete handshake, no application payload, very few bytes, very small flow duration, ... In a CIC based dataset such as CIC-IDS2017, here are some typical features of TCP Scan: Protocol == TCP, Flow Duration < threshold, Total Forward Packets = 1, Total Backward Packets = 0 or 1 SYN Flag Count = 1, ACK Flag count = 0, RST Flag Count = 1 (sometimes)

These are some UDP Scan characteristics: No response, 1 UDP packet And these are some typical features based on CIC datasets: Protocol == UDP, Total Forward Packets = 1, Total Backward Packets = 0, Packet Length very small, Flow Duration very short

And finally, the Ping Scan signatures, which are too simple: ICMP Echo Request and ICMP Echo Reply. For CIC-based databases: Protocol = ICMP, 2 packets, small payload, small duration.

  • Behavioral Based: In this case, instead of looking at one flow, we look at many flows together(but, for these simple attacks, we don't need to do much of this kind of effort). For example, if we see the same source IP but requesting many destination ports, which have very short flows and mostly are SYN packets, this obviously means something... which can be detected in CIC with these features: Unique Destination Ports, Flows per second, Average Flow Duration, Average Packet Count, SYN Count. For UDP Scan, we use the same idea as we used for TCP Scans(Same source IP, Many UDP destination ports, few packets, few bytes), just without the SYN part, and for Ping Scan, we again use the same idea but way simpler (Same source, Many destination IPs, Protocol ICMP, Small packets, High rate)

For simplicity, here you can use this table, which provides the most useful scan-detection features for the CIC dataset:

FeatureSYN ScanUDP ScanPing Scan
ProtocolTCPUDPICMP
Flow DurationVery lowVery lowLow
Total Fwd Packets111
Total Bwd Packets0–10–11
Flow Bytes/sLowLowLow
Flow Packets/sHighHighHigh
SYN Flag CountHigh00
ACK Flag CountLow00
RST Flag CountSometimes00
Average Packet SizeSmallSmallSmall
Init Win Bytes ForwardSmall0N/A
Subflow Fwd PacketsSmallSmallSmall