Study Guide
Study Guide
Course Name
Created By: Arnav Banerjee, Teaching Assistant
Module 1: Introduction
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
1
○ Mod-3: TCP/IP protocol suite, TCP, UDP and ICMP headers, how Nmap crafts
packets, wireshark analysis of package, nmap and Ipv6, etc.
○ Mod-4: Popular nmap scans, host discovery, port scanning, service and
application version detection and OS detection.
● Pre-requisites:
○ General understanding of TCP/IP protocol suite.
○ 3-5 years of experience.
○ CompTIA Network+, Security+ or Cisco CCNA.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
2
• Installation with dpkg or apt is possibly a version behind.
• RPM installation commands:
o rpm -vhU https://nmap.org/dist/nmap-7.80-1.x86_64.rpm
o rpm -vhU https://nmap.org/dist/zenmap-7.80-1.noarch.rpm
o rpm -vhU https://nmap.org/dist/ncat-7.80-1.x86_64.rpm
o rpm -vhU https://nmap.org/dist/nping-0.7.80-1.x86_64.rpm
• Debian-based distro (Ubuntu and similar) command sequence:
o sudo apt-get update
o sudo apt-get install nmap
o sudo apt-get install zenmap -y
• Test scan: nmap scanme.nmap.org
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
3
• Free, Open-Source and FHS Compliant.
• Download: kali.org/downloads.
• Can be run as main OS, dual-boot with Mac or Windows, as a VM or as a “Live
CD/DVD”.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
4
• Open terminal and remove Zenmap, first, using: sudo apt-get remove --auto-remove
zenmap.
• Then remove nmap: sudo apt-get remove --auto-remove nmap.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
5
Lesson 2.10: Phases of the Nmap Scan - NM
Skills Learned From This Lesson: Nmap, ZenMap, traceroute, r-DNS, NSE.
• Reference: https://nmap.org/book/nmap-phases
• Knowing scan phases helps in tuning the scan and also, constructing the required nmap
scan.
• Scan Phases of Nmap:
o Phase 1: Script Pre-scanning
▪ Occurs while running NSE scans.
▪ Scripts that only have to be run once per Nmap execution.
o Phase 2: Target Enumeration
▪ Occurs with every scan.
▪ Determines hosts to scan.
o Phase 3: Host Discovery
▪ “Ping Scanning”.
▪ Determines which targets are online.
▪ Can be skipped.
▪ Improves performance if not used or needed.
o Phase 4: Reverse-DNS resolution
▪ Occurs by default when specifying IPs.
▪ Hostnames can provide valuable insight about the host.
▪ Can be skipped or forced, based on requirement.
o Phase 5: Port Scanning
▪ Backbone of Nmap usage.
▪ Significant but is only a single component.
▪ Probes sent; responses evaluated.
▪ Default for every Nmap scan but can be skipped.
o Phase 6: Version Detection
▪ Port open – Determine server software.
▪ Compares responses to known signatures.
▪ Can be enabled on any scan.
o Phase 7: OS Detection
▪ Optional, but part of some default scans.
▪ Can be run in any scan.
▪ Compares responses to known signatures.
▪ Provides a degree of likelihood.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
6
▪ Can be enhanced with several NSE script scans.
o Phase 8: Traceroute
▪ Enhanced traceroute engine.
▪ Can be forced on any scan.
▪ Determines route to target, then runs reverse-DNS lookup.
▪ Reverse-DNS lookup occur in parallel for enhanced performance.
o Phase 9: Script scanning
▪ Most of the script scan is done in this phase.
o Phase 10: Output
▪ Final phase of most scans.
▪ O/p results to screen or to a file.
▪ Sometimes the most important phase.
▪ Can be both searchable and/or report quality.
o Phase 11: Script post-scanning
▪ Theoretical so far.
▪ Can process results and deliver final reports and statistics.
▪ Not used by any official NSE script, so far.
▪ Likely to change.
▪ Custom Scripts in Lua can be processed by this.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
7
▪ nmap <option(s)> --script= <script-name> <target(s)>
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
8
• Uses 3-way handshake: SYN→ SYN-ACK→ ACK.
• TCP and UDP both use ports to identify the type of data, application and service
running.
• IP Addressing:
o 4-octets (max value is composed of 8 bits, hence octet) separated by a decimal
point with numbers in their decimal form.
o ipconfig – Windows and ifconfig – linux, unix and mac os.
o The physical address of the host cannot be determined remotely. Need physical
access to switch/router/host to determine the address. Exception- when the
scanning device sits on span or mirrored port.
• CIDR:
o Classless Inter-Domain Routing.
o CIDR notation: <IP address(es)>/<Set bits from Subnet mask>.
o Nmap allows use of CIDR notation.
• DNS:
o Domain Name System.
o Name to IP address resolution.
o Nmap allows use of FQDN for target.
o By default, it uses the DNS service of the scanning system. This can be changed
for using alternate name servers.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
9
o This uses the Nmap packet crafter: Nping, for this purpose.
o Reference: https://youtu.be/LyDqA-dAPW4
• TCP Header:
o Important Components for Nmap in TCP header: Source port, Destination port,
TCP flags.
o Source port is determined by Nmap when initiating the connection.
o Destination port can be determined by the user or by Nmap based on the scan
option set.
o TCP SYN scan: nmap -sS
o TCP ACK scan: nmap -sA
o TCP full connect scan: nmap -sT
o X-mas scan: nmap -sX -> Sets up all the flags in TCP header.
o Other switches in TCP header: U: Urgent, P: Push, R: Reset, F: Finish.
o Reference: https://youtu.be/M-zX_6FuFKg
• UDP header:
o Important Components: Source port, Destination port.
o UDP scan: nmap -sU
o DNS uses TCP/UDP port 53, NTP uses UDP port 123, NetBIOS uses UDP port
137, LDAP uses UDP port 389.
• IP header:
o Important Component: Version, Protocol, Source and Destination IP address.
o Version: for IPv4 the value is 4. But IPv6 has a different header structure.
o Protocol: protocol used in the creation of the package. TCP: 6, UDP: 17, ICMP: 1
o IP protocol scan: nmap -sO
o By default, nmap scans for all possible 256 Protocol values.
o Reference: https://youtu.be/UrO-9Uagn24
• ICMP header:
o Important Component: Type, Code.
o Ping scan is not the same as ICMP scan.
o ICMP scan: nmap -sn -PE
o Reference: https://youtu.be/FprZF9agJJI
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
10
• Wireshark by default does not capture all network traffic. To do that, we need to set it to
Promiscuous mode.
• Wireshark with Nmap provides an insight to how Nmap works and analyse granular
details on requests made by Nmap.
• Wireshark Cheat Sheet:
https://packetlife.net/media/library/13/Wireshark_Display_Filters.pdf
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
11
• Common Target Specification:
o nmap <ip-address>
o nmap <ip-address-range>
o nmap <network in CIDR notation>
o nmap <fqdn>
o nmap <Domain name in CIDR>
o nmap <ip1> <ip2> <ip3>
o nmap -iL <targets.txt>
o nmap -iR <number of targets to scan>
o nmap –exclude <ip>
o nmap –excludefile <exclude.txt>
o Reference: https://nmap.org/book/man-target-specification.html
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
12
Skills Learned From This Lesson: Nmap, ZenMap, nping.
• Scanning entire network results in quicker blocking.
• To narrow down potential targets.
• Reference: https://nmap.org/book/man-host-discovery.html
• Host discovery options:
o List Scan: nmap -sL
o No port/ping scan or ping sweep: nmap -sn
o No ping: nmap -Pn
o Additional features/options:
▪ -n : No DNS resolution
▪ -R : resolve all using DNS
▪ --traceroute : Trace path to host
▪ --dns-servers <server1>, <server2>, … : Custom DNS server for PTR
lookup.
o Other Host Discovery Options:
▪ nmap -PS (Syn Ping), -PA (Ack Ping), -PU (UDP Ping), -PY (SCTP Init
Ping), -PO (IP Protocol Ping).
▪ nmap -PE, -PP, -PM – Results in nmap sending ICMP pings.
▪ Nmap -PR (arp ping) – Provides MAC Addresses of the target.
▪ Additionally:
• --disable-arp-ping
• --system-dns
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
13
o Unfiltered: Port is accessible but NMAP is unable to determine if it’s open or
close.
o Open| Filtered: Port might be open or filtered.
o Closed| Filtered: Port might be closed or filtered.
• Help InfoSec to determine attack surface.
• Open ports are possible points of breach.
• Information from this helps in asset tracking, n/w design mapping and policy compliance
checks.
• Reference: https://nmap.org/book/port-scanning.html
• Useful commands:
o Nmap <target> -> 1000 ports SYN scan
o Nmap -F <target> -> Popular 100 ports scan.
o Nmap -p <ports/service name> <target>
o Nmap -sU -p < ports/service name> <target>
o Nmap -sS -sU -p <ports> <target>
o Nmap <scan technique> -p <ports> <target>
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
14
• Basic Command: nmap -O
• Organised Command Structure: nmap -O –script=smb-os-discovery -v <target>
• Useful OS versioning switches:
o –osscan-limit
o –osscan-guess or –fuzzy
o –max-os-tries <values>
o -A
• Reference: https://nmap.org/book/osdetect.html
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
15
• Timing templates:
o T0- Paranoid (for IDS evasion)
o T1- Sneaky (for IDS evasion)
o T2- Polite (for less bandwidth and resource consumption
o T3- Normal (Default)
o T4- Aggressive (Assumed to be on a fast and reliable network)
o T5- Insane (Very fast network, with preference for speed over accuracy)
• Fine grain timing options take precedence over timing templates.
• Fine grained timing controls:
o –host-timeout <time>
o –min-rtt-timeout/ --max-rtt-timeout/ --initial-rtt-timeout <time>
o –min-hostgroup/ --max- hostgroup <num hosts>
o –min-parallelism/ --max- parallelism <num probes>
o –scan-delay/ --max-scan-delay <time>
o –max-retries <tries>
o –min-rate/ --max-rate <number> (number of packets sent per minute)
• Time specs in nmap can be ms, s, m, h.
• Reference: https://nmap.org/book/performance-timing-templates.html.
Brought to you by: Develop your team with the fastest growing catalog in the
cybersecurity industry. Enterprise-grade workforce development
management, advanced training features and detailed skill gap and
competency analytics.
16