Footprinting & Scanning
Never run any of these tools and techniques on any machine or network without proper authorization!
Mapping a Network
These techniques work both on local and remote. Every host connected to the Internet or a private network must have a unique IP address.
Example:
ping
command tests whether a machine is alive.Ping works by sending one or more special ICMP packets (echo request - Type 8).
If the destination host replies with ICMP echo reply.
ICMP is part of the IP protocol.
fping
is an improved version of theping
utility.When running
fping
on a LAN you are directly attached to, even if you use the-a
option, you will get some warning messages about the offline hosts (ICMP Host Unreachable
). Those messages are easily removed by:fping -a g 192.168.82.0 192.168.82.255 2>/dev/null
.
Nmap Ping Scan
HOST DISCOVERY:
-sL
: List Scan - simply list targets to scan.-sn
: Ping Scan - disable port scan.-Pn
: Treat all hosts as online -- skip host discovery.-PS/PA/PU/PY[portlist]
: TCP SYN/ACK, UDP or SCTP discovery to given ports.-PE/PP/PM
: ICMP echo, timestamp, and netmask request discovery probes.-PO[protocol list]
: IP Protocol Ping.
OS Fingerprinting
Possible to identify OS because of some tiny differences in the network stack implementation of the various OS.
Signature of the host behavior.
The signature is compared against a database of known OS signatures.
Offline OS fingerprinting can be done with
p0f
but we'll usenmap
.
OS DETECTION:
-O
: Enable OS detection.--osscan-limit
: Limit OS detection to promising targets.--osscan-guess
: Guess OS more aggressively.
Port Scanning
Goals
Prepare for the vulnerability assessment phase.
Perform stealth reconnaissance.
Detect firewalls.
Port Scanning goes after knowing the active targets on the network.
Determine what TCP/UDP ports are opened.
Also knowing what services are running, software and version, on an specific port.
Port scanners automate probes requests and response analysis.
Also let you detect if there's a firewall between you and your target.
3-way handshake: If port is closed ➝ RST + ACK.
TCP Connect Scan
Simplest way to perform a port scan.
If the scanner receives a
RST
packet, then the port is closed.If the scanner is able to complete the connection, then the port is open.
TCP Connect Scans are recoded in the daemon logs (from the app point of view, the probe looks like a legitimate connection).
TCP SYN Scan
Default nmap scan.
Stealthy by design
Sends a SYN packet and analyzes the response coming from the target machine.
If a RST packet is received, then port is closed.
if a ACK packet is received, then the port is open (and RST packet is sent to the target to stop the handshake).
Cannot be detected by looking at daemons logs.
Nmap Scan Types
-sV
version detection scan mixes a TCP connect scan with some probes, which are used to detect what application is listening on a particular port, which isn't stealthy but useful.During version detection scan, Nmap performs a TCP connect and reads from the banner of the daemon listening on a port.
If the daemon does not send a banner, nmap sends some probes to understand what application is, by studying its behavior
NMAP Port Scanning
Specifying targets
Discovering Network with Port Scanning
You might encounter networks that are protected by firewalls and where pings are blocked.
It's not uncommon to come across a server that does not respond to pings but has many TCP/UDP ports open.
-Pn
: forces the scan on a server.If you would like to find an alive host, you can scan typical ports instead of performing a ping sweep.
The four most basic TCP ports (22, 445, 80, 443) can be used as indicators of live hosts in the network.
Spotting a Firewall
You might often see that a version was not recognized regardless of the open port.
Or even the service type is not recognized.
tcpwrapped
means that the TCP handshake was completed but the remote host closed the connection without receiving any data.--reason
nmap flag will show an explanation of why a port is marked as open or closed.
masscan
masscan
Another interesting tool that can help you to discover a network via probing TCP ports.
Designed to deal with large networks and to scan thousands of IP addresses at once.
Like
nmap
but a lot faster, however is less accurate.Maybe best to use this for host discovery and then conduct a detailed scan with nmap against certain hosts.
Examples: Scanning and OS Fingerprinting
Last updated