Nmap: SYN Scans, UDP Scans.
Nmap SYN Scans
A SYN scan, also known as a half-open scan, is a popular network scanning technique. SYN scans are designed to determine which ports on a target system are open, closed, or filtered without completing a full TCP connection.
Here's how a SYN scan works in Nmap:
1. TCP Three-Way Handshake: In a normal TCP connection, a three-way handshake occurs. The client sends a SYN (synchronize) packet to the server, the server responds with a SYN-ACK (synchronize-acknowledgment) packet, and the client completes the handshake with an ACK (acknowledgment) packet.
2. SYN Packet: In a SYN scan, Nmap sends a TCP SYN packet to the target system for each port it wants to scan. This is just the first step of the three-way handshake. If the port is open, the target system should respond with a SYN-ACK packet.
3. Nmap analyzes the responses it receives:
- If the target system responds with a SYN-ACK, Nmap considers the port open.
- If the target system responds with a RST (reset) packet, Nmap considers the port closed.
- If there's no response or an ICMP unreachable message is received, Nmap may consider the port filtered, as it couldn't determine the state.
5. Incomplete Connection: One of the advantages of SYN scans is that they don't complete the connection, which can be beneficial in situations where you want to minimize your footprint or avoid leaving logs on the target system.
To perform a SYN scan with Nmap, you can use the following command:
nmap -sS target_ip
Replace target_ip with the IP address or hostname of the system you want to scan. You can also specify a range of ports to scan, like so:
nmap -sS -p 1-100 target_ip
Answer: Half-Open, Stealth
Nmap UDP Scans
1. UDP Packet Transmission:
- When you initiate a UDP scan using Nmap, the tool sends UDP packets to the target system's UDP ports.
- Each packet contains a UDP header with the source and destination port numbers, along with some payload data.
- Nmap sends these packets without establishing a connection or waiting for a response, which is characteristic of UDP.
2. Response Analysis:
- If the target system responds with an ICMP "Port Unreachable" message, Nmap interprets the port as closed.
- If the target system responds with any other UDP packet (indicating that the port is open), Nmap interprets the port as open or filtered, depending on the specific response.
- If Nmap receives no response to its UDP probe, it may consider the port to be either open or filtered. This is because it cannot definitively determine if the lack of response is due to the port being open or blocked by a firewall.
3. Time-Consuming:
- UDP scanning can be more time-consuming than TCP scanning because Nmap has to wait for potential responses from each probed port.
- Some UDP services may take longer to respond or may not respond at all, further extending the scan time.
4. Common UDP Services:
- DNS (Domain Name System) Port: 53 Purpose: DNS is used for translating human-friendly domain names into IP addresses.
- DHCP (Dynamic Host Configuration Protocol) Port: 67 (Server) and 68 (Client) Purpose: DHCP is used to dynamically assign IP addresses and network configuration information to devices on a network.
- TFTP (Trivial File Transfer Protocol) Port: 69 Purpose: TFTP is a simple file transfer protocol used for transferring files, often used in network device configuration.
- SNMP (Simple Network Management Protocol)Port: 161 (SNMP) and 162 (SNMP Trap) Purpose: SNMP is used for monitoring and managing network devices and their functions.
- Syslog, Port: Typically 514 | Purpose: Syslog is a standard for message logging on Unix-based systems and network devices.
- NTP (Network Time Protocol) Port: 123 | Purpose: NTP is used for time synchronization between devices on a network.
- NetBIOS Name Service Port: 137 | Purpose: NetBIOS Name Service is used for name resolution in Windows networks.
- NetBIOS Datagram Service Port: 138 | Purpose: NetBIOS Datagram Service is used for datagram-based communication in Windows networks.
- NetBIOS Session Service Port: 139 | Purpose: NetBIOS Session Service is used for establishing and maintaining sessions in Windows networks.
- RADIUS (Remote Authentication Dial-In User Service) Port: 1812 (Authentication) and 1813 (Accounting) | Purpose: RADIUS is used for centralized authentication, authorization, and accounting for network access.
- SMB (Server Message Block) Port: 137-139 (NetBIOS over TCP/IP) and 445 (Direct SMB) | Purpose: SMB is used for file and printer sharing in Windows networks.
- SNTP (Simple Network Time Protocol) Port: Typically 123 | Purpose: SNTP is a simplified version of NTP used for time synchronization.
- RIP (Routing Information Protocol) Port: 520 | Purpose: RIP is a routing protocol used for exchanging routing information in IP networks.
- RIPng (RIP Next Generation) Port: 521 | Purpose: RIPng is an extension of RIP designed for IPv6 networks.
- BFD (Bidirectional Forwarding Detection) Port: Typically 3784 | Purpose: BFD is used for rapid detection of network path failures.
Answer: open|filtered
Question 2: When a UDP port is closed, by convention the target should send back a "port unreachable" message. Which protocol would it use to do so?
Answer: ICMP
Comments