[EH Wk 2] Module 03: Scanning
Overview of Network Scanning
- Set of procedures to identify hosts, ports, and services
- Component of intelligence gathering
Network Flags
TCP Communication Flags
- URG (Urgent): Packet to be processed ASAP
- FIN (Finished): No further data from sender
- RST (Reset): Reset connection (Commonly seen in Stealth Scans where three-way handshake is not completed)
- PSH (Push): Sends all buffered data immediately (Tells receiver to process data ASAP instead of buffering it)
- SYN (Synchronize): Initiates connection between hosts, synchronises sequence numbers for data transmission
- ACK (Acknowledge): Acknowledges packet being received
TCP Session Establishment Steps (Three-way Handshake)
- Client -> Server:
SYN
(Please open, it’s chit chat time) - Server -> Client:
SYN
+ACK
(Okay, chit chat at 1 of my 65,535 ports) - Client -> Server:
ACK
(Okay, see you at the port)
TCP Session Termination Steps
- Client -> Server:
FIN
(I’ve heard enough) - Server -> Client:
ACK
(Okay) - Server -> Client:
FIN
(I have clearly received your message) - Client -> Server:
ACK
(I acknowledge that you have received my message)
Types of Scans
Host Discovery Scans
- ARP Ping Scan
- Efficient and accurate
- TCP ping Scan
- SYN: Does not create any connection; logs are not recorded. SYN+ACK = Port open; RST = Port closed
- ACK: Maximises chances of bypassing firewall. RST = Port open; No response = Port closed
- NULL/FIN/XMAS: No response = Port open; RST = Port closed
- UDP ping Scan
- Able to detect systems behind firewalls with strict TCP filtering
- ICMP ping Scan
- Useful for locating active devices / if ICMP pass through firewall
- Does not work on Windows
Service Version Discovery
- Determines versions of services running on target system based on responses to probes
- Determine vulnerabilities based on service versions
- Tools: Nmap, Zenmap - Both
-sV
flag
OS Discovery
- Banner grabbing / OS fingerprinting to determine OS of remote target system based on TCP/IP behaviour
- Figure out vulnerabilities based on OS to plan exploits
- Tools: Nmap, Zenmap - Both
-O
flag
Active Banner Grabbing
- Specially crafted packets sent to observe responses
- Compare responses to known OS signatures
- Response varies due to TCP/IP stack implementation
- Tools: Telnet, Netcat, Nmap, wget, curl
Passive Banner Grabbing
- From error messages provided by target via information leakage
- Sniffing network traffic generated by target
- Banner grabbing from page extensions, e.g.
.aspx
means IIS server - Tools: Shodan, Censys
Identifying OS
- Attackers identify OS running through the TTL and TCP Window Size (amount of data that can be sent before
receiving
ACK
) - Sniff response generated from target machine
- Passive Tools: Shodan, Censys
IDS/Firewall Evasion Techniques
- Packet Fragmentation: Split packets into smaller fragments
- Source Routing: Specify route packets should take
- Source Port Manipulation: Change source port to prevent suspicious traffic
- IP Address Decoy: Send packets from multiple IP addresses to prevent IDS from identifying real source
- IP Address Spoofing: Change source IP address
- MAC Address Spoofing: Change MAC address to bypass MAC filtering
- Creating Custom Packets: Craft packets to bypass IDS rules
- Randomising Host Order, Sending Bad Checksums: Scanning hosts in target network in random order and sending bad TCP/UDP checksums to avoid firewall rulesets
- Proxy Servers: Hide source of attack and impersonates the fake source address of proxy. Can also remotely access usually restricted resources.
This post is licensed under
CC BY 4.0
by the author.