8 24 23 Nmap
8 24 23 Nmap
8 24 23 Nmap
┌──(kali㉿ kali)-[~]
└─$ man nmap
┌──(kali㉿ kali)-[~]
└─$ nmap -help
Nmap 7.93 ( https://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks
-iR <num hosts>: Choose random targets
--exclude <host1[,host2][,host3],...>: Exclude hosts/networks
--excludefile <exclude_file>: Exclude list from file
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
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>: Specify custom DNS servers
--system-dns: Use OS's DNS resolver
--traceroute: Trace hop path to each host
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
--exclude-ports <port ranges>: Exclude the specified ports from scanning
-F: Fast mode - Scan fewer ports than the default scan
-r: Scan ports sequentially - don't randomize
--top-ports <number>: Scan <number> most common ports
--port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
--version-intensity <level>: Set from 0 (light) to 9 (try all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
-sC: equivalent to --script=default
--script=<Lua scripts>: <Lua scripts> is a comma separated list of
directories, script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
--script-args-file=filename: provide NSE script args in a file
--script-trace: Show all data sent and received
--script-updatedb: Update the script database.
--script-help=<Lua scripts>: Show help about scripts.
<Lua scripts> is a comma-separated list of script-files or
script-categories.
OS DETECTION:
-O: Enable OS detection
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append 'ms' (milliseconds),
's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
-T<0-5>: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
--max-retries <tries>: Caps number of port scan probe retransmissions.
--host-timeout <time>: Give up on target after this long
--scan-delay/--max-scan-delay <time>: Adjust delay between probes
--min-rate <number>: Send packets no slower than <number> per second
--max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
--data <hex string>: Append a custom payload to sent packets
--data-string <string>: Append a custom ASCII string to sent packets
--data-length <num>: Append random data to sent packets
--ip-options <options>: Send packets with specified ip options
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
--badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
--reason: Display the reason a port is in a particular state
--open: Only show open (or possibly open) ports
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--noninteractive: Disable runtime interactions via keyboard
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--webxml: Reference stylesheet from Nmap.Org for more portable XML
--no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
--unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
EXAMPLES:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
Introduction
What is Nmap?
Why learn about Nmap?
Nmap Command Examples in Linux and Unix
Features of Nmap
Nmap Commands
NMAP Commands Cheat Sheet
Frequently Asked Questions
Introduction
Nmap is a tool used for network mapping and it is one of the most popular ethical hacking tools in the market. Nmap
is used to discover free networks around you. Network administrators find Nmap very useful as they always need to
map their networks.
Nmap is a network scanning tool—an open source Linux command-line tool—used for network exploration, host
discovery, and security auditing. Gordon Lyon (pseudonym Fyodor Vaskovich) created it to help map an entire
network easily and find its open ports and services.
Hackers also started using Nmap for auditing networks and other purposes.
In this guide, we are going to look at What Nmap is, Nmap commands, and some more useful information about
Nmap.
What is Nmap?
Nmap is a short form of Network Mapper and it’s an open-source tool that is used for mapping networks, auditing
and security scanning of the networks. The reason behind its development is to quickly find large networks at a
specific location. For the discovery of networks, the raw IP packets are used by Nmap. The most common use of
Nmap is for security audits of networks.
As we see the rise in IoT devices and therefore, the networks are getting more complex for the companies using IoT
devices. In this situation, Nmap comes into view where it can be used for auditing the network traffic between web
servers of the organisation and the IoT devices.
It allows you to quickly find the networks and the devices on a specific network.
Nmap is useful to find out which services are running on a system that includes all the web services and DNS
servers.
You can also find information about the operating system running on devices on a network.
The GUI of Nmap is Zenmap which you can use to see the mappings of a network to use it for reporting and to
enhance its usage.
You can easily find out unauthorized services on your network.
Nmap helps you to find the devices with open ports and you can look at them to enhance their security.
Server (1) is powered by an Operating system such as Win/macOS or Linux that will work as an unpatched
server.
Wks01 shows your operating system used for scanning the local networks using Nmap.
Server (2) works the same as the server(1) where it is also powered by the operating system but the difference is
that it is a fully patched server integrated with a firewa
firewall.
All three systems such as Server(1), wks01 or the operating system, and server(2) are connected via a network
switch.
Check
out this Linux Tutorial
Features of Nmap
There are several features of Nmap that include the following:
OS Detection: OS scanning can be done in Nmap that detects the OS, version of the OS, and other details about
it.
Service Detection: The several service probs found in the Nmap
Nmap-services-probe-file
file are used to get the responses
from network services and their applications.
Host discovery: This method d is used by network hosts to gather data about other hosts in the network by the use
of TCP and UDP protocols.
Target Specification: The target specification feature can be used to specify a Target IP address that you want to
scan in Nmap.
IPv6 Support: IPv6 means Internet Protocol version 6 and it can be used in Nmap for scanning the network. As
IPv6 is capable of scanning larger addresses than IPv4, it makes scanning through CIDR-style scanning ranges
that make it idle for scanning larger addresses.
NSE Functionality: NSE stands for Nmap Scripting Engine and it comes in Nmap functionality that you can use
for host discovery, network scanning, and target specification.
TLS/SSL scanning: The TLS deployment problems can be analyzed fastly with the help of Nmap.
Nmap Commands
Here is the list of Nmap Commands
1. Scan a Range of IP Address: To scan a range of IP addresses, the Nmap command is as follows:
nmap 192.168.1.1-24
ifconfig, copy echo0 ip, cd Desktop, nmap –oG -192.168.1.0-255 –vv > /home/Desktop/Result
2. Port Scanning: There are multiple commands in Nmap for scanning ports such as:
To scan TCP port 80, the following Nmap command can be used:
3. Ping Scan Using Nmap: It can be used for host discovery and the following command can be used:
nmap -sP 192.168.1.1/20
4. Saving the Nmap Scan Output to a File: The syntax for the command to save the Nmap output to a text file
is as follows:
nmap 192.168.1.1 > op.txt
5. Most Popular Ports Scanning: The most popular TCP ports can be scanned using TCP SYN scan and the
following command exists for this purpose:
nmap -sS 192.168.1.1
6. Display Open Ports: The command for displaying open ports on the network is as follows:
nmap –open 192.168.1.1
7. Exclude Host/ IP Addresses for the Scan: In order to exclude the hosts from the Nmap scan, you can use the
following Nmap commands:
If you are scanning a number of hosts/networks, then you can exclude hosts/IPs from a scan by using:
nmap 192.168.1.1-24 –exclude 192.168.1.4
or
8. Service Version Detection: The service version can be detected for IPv4 script with the help of Nmap by
using any of the following commands:
nmap -A 192.168.1.254
or
nmap -v -A 192.168.1.1
or
Description Commands
If you want to scan all the 65532 ports of the network, then use the
nmap -p- 192.168.1.1
corresponding command:
Description Commands
nmap
If you want to scan a single host:
www.<hostname>.com
For scanning targets from text file, you should use the corresponding
nmap -iL target-ip-lists.txt
Nmap command:
These commands are used to perform default scans using Nmap and it scans 1000 TCP ports where host discovery
will also take place.
Description Commands
The above commands are used to determine the operating system running on a particular port of the network. The
command that we discussed for aggressive services detection can be used for the services running on unusual ports
of the network.
Description Commands
If you want to save default output to a file: nmap -oN op.txt 192.168.1.1
To save the Nmap results in format for grep: nmap -oG op.txt 192.168.1.1
The default output can also be saved by simple redirecting the file with the command: command>file. In the above
command, oN is used to save the results and also monitors the terminal for scanning.
The command above can be used to get the details related to the IP address and owner of that IP address. This
command uses WhoIS, GeoIP location lookups and ASN query.
Description Commands
To gather the data about page titles from HTTP services: nmap –script=http-title 192.168.10/24
These commands used to get the details about HTTP service are very useful for larger networks as it identifies the
HTTP services on the network and reports immediately results.
Description Commands
Nmap command for scanning a set of scripts: nmap -sV –script=aqb* 192.168.1.1
There are several NSE scripts in nmap that can be used for a wide range of security testing in the network. These
scripts are also helpful in the discovery of new networks. The -sV parameter used in the commands above is used as
a service detection parameter.
Description Commands
Nmap command to scan UDP ports: nmap -sU -p 123, 161, 162, 192.168.1.1
These commands are very useful to scan port types. The SYN scan requires some privileged access and it uses TCP
connect scan for insufficient privileges. The -Pn in the above commands is used for the PING parameter.
Conclusion
Nmap is a powerful tool used for networking and security auditing of networks. Nmap is helpful for quickly finding
useful information about the networks, ports, hosts, and operating systems. There are other settings of Nmap too that
enhance its productivity. In this article, we discussed the features of Nmap and why it should be learned. Also, we
saw its cheatsheet where we included some commonly used commands of Nmap. Here comes the end of this article.
https://www.javatpoint.com/what-is-nmap#
https://u-next.com/blogs/cyber-security/nmap-commands/
https://www.tutorialspoint.com/nmap-cheat-sheet
https://www.interviewbit.com/blog/nmap-commands/
https://www.stationx.net/nmap-cheat-sheet/
https://www.upguard.com/blog/how-to-use-nmap#:~:text=network%2C%20read%20on.-
,What%20is%20Nmap%3F,its%20open%20ports%20and%20services. \
https://www.geeksforgeeks.org/nmap-cheat-sheet/
https://www.upguard.com/blog/how-to-use-nmap#:~:text=network%2C%20read%20on.-
,What%20is%20Nmap%3F,its%20open%20ports%20and%20services.