{"id":2276,"date":"2018-07-03T10:04:44","date_gmt":"2018-07-03T10:04:44","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=2276"},"modified":"2026-01-20T10:39:31","modified_gmt":"2026-01-20T10:39:31","slug":"nmap-cheat-sheet","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=2276","title":{"rendered":"Nmap Cheat Sheet"},"content":{"rendered":"<p>Nmap has a multitude of options and when you first start playing with this excellent tool it can be a bit daunting. In this cheat sheet you will find a series of practical example commands for running Nmap and getting the most of this powerful tool.<\/p>\n<p>Keep in mind that this cheat sheet merely touches the surface of the available options. The <a href=\"http:\/\/nmap.org\/docs.html\">Nmap Documentation portal<\/a> is your reference for digging deeper into the options available.<\/p>\n<p><!--more--><\/p>\n<h3>Nmap Target Selection<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan a single IP<\/td>\n<td>nmap 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan a host<\/td>\n<td>nmap www.testhostname.com<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan a range of IPs<\/td>\n<td>nmap 192.168.1.1-20<\/td>\n<\/tr>\n<tr>\n<td>Scan a subnet<\/td>\n<td>nmap 192.168.1.0\/24<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan targets from a text file<\/td>\n<td>nmap -iL list-of-ips.txt<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These are all default scans, which will scan 1000 TCP ports. Host discovery will take place.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Nmap Port Selection<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan a single Port<\/td>\n<td>nmap -p 22 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan a range of ports<\/td>\n<td>nmap -p 1-100 192.168.1.1<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan 100 most common ports (Fast)<\/td>\n<td>nmap -F 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan all 65535 ports<\/td>\n<td>nmap -p- 192.168.1.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Nmap Port Scan types<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan using TCP connect<\/td>\n<td>nmap -sT 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan using TCP SYN scan (default)<\/td>\n<td>nmap -sS 192.168.1.1<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan UDP ports<\/td>\n<td>nmap -sU -p 123,161,162 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan selected ports &#8211; ignore discovery<\/td>\n<td>nmap -Pn -F 192.168.1.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Privileged access is required to perform the default <code>SYN<\/code> scans. If privileges are insufficient a TCP connect scan will be used. A TCP connect requires a full TCP connection to be established and therefore is a slower scan. Ignoring discovery is often required as many firewalls or hosts will not respond to <code>PING<\/code>, so could be missed unless you select the <code>-Pn<\/code> parameter. Of course this can make scan times much longer as you could end up sending scan probes to hosts that are not there.<\/p>\n<p>Take a look at the <a href=\"https:\/\/hackertarget.com\/nmap-tutorial\/\">Nmap Tutorial<\/a> for a detailed look at the scan process.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Service and OS Detection<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Detect OS and Services<\/td>\n<td>nmap -A 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Standard service detection<\/td>\n<td>nmap -sV 192.168.1.1<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>More aggressive Service Detection<\/td>\n<td>nmap -sV &#8211;version-intensity 5 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Lighter banner grabbing detection<\/td>\n<td>nmap -sV &#8211;version-intensity 0 192.168.1.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Service and OS detection rely on different methods to determine the operating system or service running on a particular port. The more aggressive service detection is often helpful if there are services running on unusual ports. On the other hand the lighter version of the service will be much faster as it does not really attempt to detect the service simply grabbing the banner of the open service.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Nmap Output Formats<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Save default output to file<\/td>\n<td>nmap -oN outputfile.txt 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Save results as XML<\/td>\n<td>nmap -oX outputfile.xml 192.168.1.1<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Save results in a format for grep<\/td>\n<td>nmap -oG outputfile.txt 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Save in all formats<\/td>\n<td>nmap -oA outputfile 192.168.1.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The default format could also be saved to a file using a simple file redirect <code>command &gt; file<\/code>. Using the <code>-oN<\/code> option allows the results to be saved but also can be monitored in the terminal as the scan is under way.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Digging deeper with NSE Scripts<\/h3>\n<table class=\"table table-condensed\">\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan using default safe scripts<\/td>\n<td>nmap -sV -sC 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Get help for a script<\/td>\n<td>nmap &#8211;script-help=ssl-heartbleed<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan using a specific NSE script<\/td>\n<td>nmap -sV -p 443 \u2013script=ssl-heartbleed.nse 192.168.1.1<\/td>\n<\/tr>\n<tr>\n<td>Scan with a set of scripts<\/td>\n<td>nmap -sV &#8211;script=smb* 192.168.1.1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>According to my Nmap install there are currently <strong>471 NSE scripts<\/strong>. The scripts are able to perform a wide range of security related testing and discovery functions. If you are serious about your network scanning you really should take the time to get familiar with some of them.<\/p>\n<p>The option <code>--script-help=$scriptname<\/code> will display help for the individual scripts. To get an easy list of the installed scripts try <code>locate nse | grep script<\/code>.<\/p>\n<p>You will notice I have used the <code>-sV<\/code> service detection parameter. Generally most NSE scripts will be more effective and you will get better coverage by including service detection.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>A scan to search for DDOS reflection UDP services<\/h3>\n<table>\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Scan for UDP DDOS reflectors<\/td>\n<td>nmap \u2013sU \u2013A \u2013PN \u2013n \u2013pU:19,53,123,161 \u2013script=ntp-monlist,dns-recursion,snmp-sysdescr 192.168.1.0\/24<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>UDP based DDOS reflection attacks are a common problem that network defenders come up against. This is a handy Nmap command that will scan a target list for systems with open UDP services that allow these attacks to take place. Full details of the command and the background can be found on the <a href=\"https:\/\/isc.sans.edu\/diary\/Using+nmap+to+scan+for+DDOS+reflectors\/18193\">Sans Institute Blog<\/a> where it was first posted.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>HTTP Service Information<\/h3>\n<table>\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Gather page titles from HTTP services<\/td>\n<td>nmap &#8211;script=http-title 192.168.1.0\/24<\/td>\n<\/tr>\n<tr>\n<td>Get HTTP headers of web services<\/td>\n<td>nmap &#8211;script=http-headers 192.168.1.0\/24<\/td>\n<\/tr>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Find web apps from known paths<\/td>\n<td>nmap &#8211;script=http-enum 192.168.1.0\/24<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There are many HTTP information gathering scripts, here are a few that are simple but helpful when examining larger networks. Helps in quickly identifying what the HTTP service is that is running on the open port. Note the <code>http-enum<\/code> script is particularly noisy. It is similar to <a href=\"https:\/\/hackertarget.com\/nikto-website-scanner\/\">Nikto<\/a> in that it will attempt to enumerate known paths of web applications and scripts. This will inevitably generated hundreds of <code>404 HTTP responses<\/code> in the web server error and access logs.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Detect Heartbleed SSL Vulnerability<\/h3>\n<table>\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Heartbleed Testing<\/td>\n<td>nmap -sV -p 443 &#8211;script=ssl-heartbleed 192.168.1.0\/24<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Heartbleed detection is one of the available SSL scripts. It will detect the presence of the well known Heartbleed vulnerability in SSL services. Specify alternative ports to test SSL on mail and other protocols <em>(Requires Nmap 6.46)<\/em>.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>IP Address information<\/h3>\n<table>\n<tbody>\n<tr class=\"btx-table-body-row btx-s-bg-bg\">\n<td>Find Information about IP address<\/td>\n<td>nmap &#8211;script=asn-query,whois,ip-geolocation-maxmind 192.168.1.0\/24<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Gather information related to the IP address and netblock owner of the IP address. Uses ASN, whois and geoip location lookups. See the <a title=\"IP and Domain Information Tools\" href=\"https:\/\/hackertarget.com\/ip-tools\/\">IP Tools<\/a> for more information and similar IP address and DNS lookups.<\/p>\n<div class=\"btx-col-12\">\n<div class=\"btx-item js-item-divider btx-divider btx-divider--single btx-center-align\">\n<div class=\"btx-divider-line btx-p-border-bg btx-p-border-border\"><\/div>\n<\/div>\n<\/div>\n<h3>Remote Scanning<\/h3>\n<p>Testing your network perimeter from an external perspective is key when you wish to get the most accurate results. By assessing your exposure from the attackers perspective you can validate firewall rule audits and understand exactly what is allowed into your network. This is the reason we offer a hosted or <a class=\"tooltips\" title=\"\" href=\"https:\/\/hackertarget.com\/nmap-online-port-scanner\/\">online version of the Nmap port scanner<\/a>. To enable remote scanning easily and effectively because anyone who has played with <code>shodan.io<\/code> knows very well how badly people test their perimeter networks.<\/p>\n<p>&nbsp;<\/p>\n<p>https:\/\/hackertarget.com\/nmap-cheatsheet-a-quick-reference-guide\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nmap has a multitude of options and when you first start playing with this excellent tool it can be a bit daunting. In this cheat sheet you will find a series of practical example commands for running Nmap and getting the most of this powerful tool. Keep in mind that this cheat sheet merely touches [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,14,42],"tags":[],"class_list":["post-2276","post","type-post","status-publish","format-standard","hentry","category-networking","category-tutorials","category-utils","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2276"}],"version-history":[{"count":2,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2276\/revisions"}],"predecessor-version":[{"id":2278,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2276\/revisions\/2278"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2276"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}