Introduction

map (Network Mapper) is an open-source tool that specializes in network exploration and security auditing. Nmap is a free and open source (license) utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.


Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts.


Nmap runs on all major computer operating systems, and official binary packages are available for Linux, Windows, and Mac OS X.

Website:Download Nmap 

Installation Of Nmap

Nmap has great support for different environments.

Windows

Download Install Nmap from the official site.

Official site: Download

For Windows, both GUI and command line options are available. The GUI option for Nmap is Zenmap.

Linux (Ubuntu and Debian):

Fire the command in the Linux terminal

apt-get install nmap

For Red Hat and Fedora based systems:

yum install nmap

For Gentoo Linux based systems:

emerge nmap 

Basic Scanning Techniques

Scan a single target

nmap [target]

Scan multiple targets

nmap [target1,target2,etc]

Scan a list of targets

nmap -iL [list.txt]

Scan a range of hosts

nmap [range of IP addresses]

Scan an entire subnet

nmap [IP address/cdir]

Scan random hosts

nmap -iR [number]

Excluding targets from a scan

nmap [targets] –exclude [targets]

Excluding targets using a list

nmap [targets] –excludefile [list.txt]

Perform an aggressive scan

nmap -A [target]

Scan an IPv6 target

nmap -6 [target] 

Nmap Port Selection

Scan a single port

nmap -p [ports no] [target]

Scan a range of ports

nmap -p [ports range] [target]

Scan 100 most common ports (Fast)

nmap -F [target]

Scan all 65535 ports

nmap -p-[target] 

Nmap Port Scan types

Scan using TCP connect

nmap -sT [target]

/

Scan using TCP SYN scan (default)

nmap -sS [target]

/

Scan UDP ports

nmap -sU -p [port1, port2, …] [target]

/

Scan selected ports – ignore discovery

nmap -Pn -F [target] 

Discovery Options

Perform a ping scan only

nmap -sP [target]

Don’t ping

nmap -PN [target]

TCP SYN Ping

nmap -PS [target]

TCP ACK ping

nmap -PA [target]

UDP ping

nmap -PU [target]

SCTP Init Ping

nmap -PY [target]

ICMP echo ping

nmap -PE [target]

ICMP Timestamp ping

nmap -PP [target]

ICMP address mask ping

nmap -PM [target]

IP protocol ping

nmap -PO [target]

ARP ping

nmap -PR [target]

Traceroute

nmap –traceroute [target]

Force reverse DNS resolution

nmap -R [target]

Disable reverse DNS resolution

nmap -n [target]

Alternative DNS lookup

nmap –system-dns [target]

Manually specify DNS servers

nmap –dns-servers [servers] [target]

Create a host list

nmap -sL [targets] 

Firewall Evasion Techniques

Fragment packets

nmap -f [target]

Specify a specific MTU

nmap –mtu [MTU] [target]

Use a decoy

nmap -D RND: [number] [target]

Idle zombie scan

nmap -sI [zombie] [target]

Manually specify a source port

nmap –source-port [port] [target]

Append random data

nmap –data-length [size] [target]

Randomize target scan order

nmap –randomize-hosts [target]

Spoof MAC Address

nmap –spoof-mac [MAC|0|vendor] [target]

Send bad checksums

nmap –badsum [target] 

Version Detection

Operating system detection

nmap -O [target]

Attempt to guess an unknown

nmap -O –osscan-guess [target]

Service version detection

nmap -sV [target]

Troubleshooting version scans

nmap -sV –version-trace [target]

Perform a RPC scan

nmap -sR [target] 

Output Options

Save output to a text file

nmap -oN [scan.txt] [target]

Save output to a xml file

nmap -oX [scan.xml] [target]

Grepable output

nmap -oG [scan.txt] [target]

Output all supported file types

nmap -oA [path/filename] [target]

Periodically display statistics

nmap –stats-every [time] [target]

133t output

nmap -oS [scan.txt] [target] 

Ndiff

Comparison using Ndiff

ndiff [scan1.xml] [scan2.xml]

Ndiff verbose mode

ndiff -v [scan1.xml] [scan2.xml]

XML output mode

ndiff –xml [scan1.xml] [scan2.xml] 

Nmap Scripting Engine

The Nmap Scripting Engine (NSE) is one of Nmap’s most powerful and flexible features. It allows users to write (and share) simple scripts to automate a wide variety of networking tasks. Basically these scripts are written in Lua programming language.

Script categories

auth

Use to test whether you can bypass authentication mechanism.

broadcast

Use to find other hosts on the network and automatically add them to scanning que.

brute

Use for brute password guessing.

discovery

Use to discover more about the network.

dos

Use to test whether a target is vulnerable to DoS.

exploit

Use to actively exploit a vulnerability.

fuzzer

Use to test how server responds to unexpected or randomized fields in packets and determine other potential vulnerabilities.

intrusive

Use to perform more intense scans that pose a much higher risk of being detected by admins.

malware

Use to test target for presence of malware.

safe

Use to perform general network security scan that's less likely to alarm remote administrators.

vuln

Use to find vulnerabilities on the target.

Nmap Scripting Engine Example

Execute individual scripts

nmap –script [script.nse] [target]

Execute multiple scripts

nmap –script [expression] [target]

Execute scripts by category

nmap –script [cat] [target]

Execute multiple scripts categories

nmap –script [cat1,cat2, etc]

Troubleshoot scripts

nmap –script [script] –script-trace [target]

Update the script database

nmap –script-updatedb

acarsd-info.nse hostmap-crtsh.nse ip-geolocation-map-bing.nse rsync-brute.nse address-info.nse hostmap-robtex.nse ip-geolocation-map-google.nse rsync-list-modules.nse afp-brute.nse http-adobe-coldfusion-apsa1301.nse ip-geolocation-map-kml.nse rtsp-methods.nse afp-ls.nse http-affiliate-id.nse ip-geolocation-maxmind.nse rtsp-url-brute.nse afp-path-vuln.nse http-apache-negotiation.nse ip-https-discover.nse rusers.nse afp-serverinfo.nse http-apache-server-status.nse ipidseq.nse s7-info.nse afp-showmount.nse http-aspnet-debug.nse ipmi-brute.nse samba-vuln-cve-2012-1182.nse ajp-auth.nse http-auth-finder.nse ipmi-cipher-zero.nse script.db ajp-brute.nse http-auth.nse ipmi-version.nse servicetags.nse ajp-headers.nse http-avaya-ipoffice-users.nse ipv6-multicast-mld-list.nse shodan-api.nse ajp-methods.nse http-awstatstotals-exec.nse ipv6-node-info.nse sip-brute.nse ajp-request.nse http-axis2-dir-traversal.nse ipv6-ra-flood.nse sip-call-spoof.nse allseeingeye-info.nse http-backup-finder.nse irc-botnet-channels.nse sip-enum-users.nse amqp-info.nse http-barracuda-dir-traversal.nse irc-brute.nse sip-methods.nse asn-query.nse http-bigip-cookie.nse irc-info.nse skypev2-version.nse auth-owners.nse http-brute.nse irc-sasl-brute.nse smb2-capabilities.nse auth-spoof.nse http-cakephp-version.nse irc-unrealircd-backdoor.nse smb2-security-mode.nse backorifice-brute.nse http-chrono.nse iscsi-brute.nse smb2-time.nse backorifice-info.nse http-cisco-anyconnect.nse iscsi-info.nse smb2-vuln-uptime.nse bacnet-info.nse http-coldfusion-subzero.nse isns-info.nse smb-brute.nse banner.nse http-comments-displayer.nse jdwp-exec.nse smb-double-pulsar-backdoor.nse bitcoin-getaddr.nse http-config-backup.nse jdwp-info.nse smb-enum-domains.nse bitcoin-info.nse http-cookie-flags.nse jdwp-inject.nse smb-enum-groups.nse bitcoinrpc-info.nse http-cors.nse jdwp-version.nse smb-enum-processes.nse bittorrent-discovery.nse http-cross-domain-policy.nse knx-gateway-discover.nse smb-enum-services.nse bjnp-discover.nse http-csrf.nse knx-gateway-info.nse smb-enum-sessions.nse broadcast-ataoe-discover.nse http-date.nse krb5-enum-users.nse smb-enum-shares.nse broadcast-avahi-dos.nse http-default-accounts.nse ldap-brute.nse smb-enum-users.nse broadcast-bjnp-discover.nse http-devframework.nse ldap-novell-getpass.nse smb-flood.nse broadcast-db2-discover.nse http-dlink-backdoor.nse ldap-rootdse.nse smb-ls.nse broadcast-dhcp6-discover.nse http-dombased-xss.nse ldap-search.nse smb-mbenum.nse broadcast-dhcp-discover.nse http-domino-enum-passwords.nse lexmark-config.nse smb-os-discovery.nse broadcast-dns-service-discovery.nse http-drupal-enum.nse llmnr-resolve.nse smb-print-text.nse broadcast-dropbox-listener.nse http-drupal-enum-users.nse lltd-discovery.nse smb-protocols.nse broadcast-eigrp-discovery.nse http-enum.nse lu-enum.nse smb-psexec.nse broadcast-hid-discoveryd.nse http-errors.nse maxdb-info.nse smb-security-mode.nse broadcast-igmp-discovery.nse http-exif-spider.nse mcafee-epo-agent.nse smb-server-stats.nse broadcast-jenkins-discover.nse http-favicon.nse membase-brute.nse smb-system-info.nse broadcast-listener.nse http-feed.nse membase-http-info.nse smb-vuln-conficker.nse broadcast-ms-sql-discover.nse http-fetch.nse memcached-info.nse smb-vuln-cve2009-3103.nse broadcast-netbios-master-browser.nse http-fileupload-exploiter.nse metasploit-info.nse smb-vuln-cve-2017-7494.nse broadcast-networker-discover.nse http-form-brute.nse metasploit-msgrpc-brute.nse smb-vuln-ms06-025.nse broadcast-novell-locate.nse http-form-fuzzer.nse metasploit-xmlrpc-brute.nse smb-vuln-ms07-029.nse broadcast-ospf2-discover.nse http-frontpage-login.nse mikrotik-routeros-brute.nse smb-vuln-ms08-067.nse broadcast-pc-anywhere.nse http-generator.nse mmouse-brute.nse smb-vuln-ms10-054.nse broadcast-pc-duo.nse http-git.nse mmouse-exec.nse smb-vuln-ms10-061.nse broadcast-pim-discovery.nse http-gitweb-projects-enum.nse modbus-discover.nse smb-vuln-ms17-010.nse broadcast-ping.nse http-google-malware.nse mongodb-brute.nse smb-vuln-regsvc-dos.nse broadcast-pppoe-discover.nse http-grep.nse mongodb-databases.nse smb-vuln-webexec.nse broadcast-rip-discover.nse http-headers.nse mongodb-info.nse smb-webexec-exploit.nse broadcast-ripng-discover.nse http-hp-ilo-info.nse mqtt-subscribe.nse smtp-brute.nse broadcast-sonicwall-discover.nse http-huawei-hg5xx-vuln.nse mrinfo.nse smtp-commands.nse broadcast-sybase-asa-discover.nse http-icloud-findmyiphone.nse msrpc-enum.nse smtp-enum-users.nse broadcast-tellstick-discover.nse http-icloud-sendmsg.nse ms-sql-brute.nse smtp-ntlm-info.nse broadcast-upnp-info.nse http-iis-short-name-brute.nse ms-sql-config.nse smtp-open-relay.nse broadcast-versant-locate.nse http-iis-webdav-vuln.nse ms-sql-dac.nse smtp-strangeport.nse broadcast-wake-on-lan.nse http-internal-ip-disclosure.nse ms-sql-dump-hashes.nse smtp-vuln-cve2010-4344.nse broadcast-wpad-discover.nse http-joomla-brute.nse ms-sql-empty-password.nse smtp-vuln-cve2011-1720.nse broadcast-wsdd-discover.nse http-jsonp-detection.nse ms-sql-hasdbaccess.nse smtp-vuln-cve2011-1764.nse broadcast-xdmcp-discover.nse http-litespeed-sourcecode-download.nse ms-sql-info.nse sniffer-detect.nse cassandra-brute.nse http-ls.nse ms-sql-ntlm-info.nse snmp-brute.nse cassandra-info.nse http-majordomo2-dir-traversal.nse ms-sql-query.nse snmp-hh3c-logins.nse cccam-version.nse http-malware-host.nse ms-sql-tables.nse snmp-info.nse cics-enum.nse http-mcmp.nse ms-sql-xp-cmdshell.nse snmp-interfaces.nse cics-info.nse http-methods.nse mtrace.nse snmp-ios-config.nse cics-user-brute.nse http-method-tamper.nse murmur-version.nse snmp-netstat.nse cics-user-enum.nse http-mobileversion-checker.nse mysql-audit.nse snmp-processes.nse citrix-brute-xml.nse http-ntlm-info.nse mysql-brute.nse snmp-sysdescr.nse citrix-enum-apps.nse http-open-proxy.nse mysql-databases.nse snmp-win32-services.nse citrix-enum-apps-xml.nse http-open-redirect.nse mysql-dump-hashes.nse snmp-win32-shares.nse citrix-enum-servers.nse http-passwd.nse mysql-empty-password.nse snmp-win32-software.nse citrix-enum-servers-xml.nse http-phpmyadmin-dir-traversal.nse mysql-enum.nse snmp-win32-users.nse clamav-exec.nse http-phpself-xss.nse mysql-info.nse socks-auth-info.nse clock-skew.nse http-php-version.nse mysql-query.nse socks-brute.nse coap-resources.nse http-proxy-brute.nse mysql-users.nse socks-open-proxy.nse couchdb-databases.nse http-put.nse mysql-variables.nse ssh2-enum-algos.nse couchdb-stats.nse http-qnap-nas-info.nse mysql-vuln-cve2012-2122.nse ssh-auth-methods.nse creds-summary.nse http-referer-checker.nse nat-pmp-info.nse ssh-brute.nse cups-info.nse http-rfi-spider.nse nat-pmp-mapport.nse ssh-hostkey.nse cups-queue-info.nse http-robots.txt.nse nbd-info.nse ssh-publickey-acceptance.nse cvs-brute.nse http-robtex-reverse-ip.nse nbns-interfaces.nse ssh-run.nse cvs-brute-repository.nse http-robtex-shared-ns.nse nbstat.nse sshv1.nse daap-get-library.nse http-sap-netweaver-leak.nse ncp-enum-users.nse ssl-ccs-injection.nse daytime.nse http-security-headers.nse ncp-serverinfo.nse ssl-cert-intaddr.nse db2-das-info.nse http-server-header.nse ndmp-fs-info.nse ssl-cert.nse deluge-rpc-brute.nse http-shellshock.nse ndmp-version.nse ssl-date.nse dhcp-discover.nse http-sitemap-generator.nse nessus-brute.nse ssl-dh-params.nse dicom-brute.nse http-slowloris-check.nse nessus-xmlrpc-brute.nse ssl-enum-ciphers.nse dicom-ping.nse http-slowloris.nse netbus-auth-bypass.nse ssl-heartbleed.nse dict-info.nse http-sql-injection.nse netbus-brute.nse ssl-known-key.nse distcc-cve2004-2687.nse https-redirect.nse netbus-info.nse ssl-poodle.nse dns-blacklist.nse http-stored-xss.nse netbus-version.nse sslv2-drown.nse dns-brute.nse http-svn-enum.nse nexpose-brute.nse sslv2.nse dns-cache-snoop.nse http-svn-info.nse nfs-ls.nse sstp-discover.nse dns-check-zone.nse http-title.nse nfs-showmount.nse stun-info.nse dns-client-subnet-scan.nse http-tplink-dir-traversal.nse nfs-statfs.nse stun-version.nse dns-fuzz.nse http-trace.nse nje-node-brute.nse stuxnet-detect.nse dns-ip6-arpa-scan.nse http-traceroute.nse nje-pass-brute.nse supermicro-ipmi-conf.nse dns-nsec3-enum.nse http-trane-info.nse nntp-ntlm-info.nse svn-brute.nse dns-nsec-enum.nse http-unsafe-output-escaping.nse nping-brute.nse targets-asn.nse dns-nsid.nse http-useragent-tester.nse nrpe-enum.nse targets-ipv6-map4to6.nse dns-random-srcport.nse http-userdir-enum.nse ntp-info.nse targets-ipv6-multicast-echo.nse dns-random-txid.nse http-vhosts.nse ntp-monlist.nse targets-ipv6-multicast-invalid-dst.nse dns-recursion.nse http-virustotal.nse omp2-brute.nse targets-ipv6-multicast-mld.nse dns-service-discovery.nse http-vlcstreamer-ls.nse omp2-enum-targets.nse targets-ipv6-multicast-slaac.nse dns-srv-enum.nse http-vmware-path-vuln.nse omron-info.nse targets-ipv6-wordlist.nse dns-update.nse http-vuln-cve2006-3392.nse openflow-info.nse targets-sniffer.nse dns-zeustracker.nse http-vuln-cve2009-3960.nse openlookup-info.nse targets-traceroute.nse dns-zone-transfer.nse http-vuln-cve2010-0738.nse openvas-otp-brute.nse targets-xml.nse docker-version.nse http-vuln-cve2010-2861.nse openwebnet-discovery.nse teamspeak2-version.nse domcon-brute.nse http-vuln-cve2011-3192.nse oracle-brute.nse telnet-brute.nse domcon-cmd.nse http-vuln-cve2011-3368.nse oracle-brute-stealth.nse telnet-encryption.nse domino-enum-users.nse http-vuln-cve2012-1823.nse oracle-enum-users.nse telnet-ntlm-info.nse dpap-brute.nse http-vuln-cve2013-0156.nse oracle-sid-brute.nse tftp-enum.nse drda-brute.nse http-vuln-cve2013-6786.nse oracle-tns-version.nse tls-alpn.nse drda-info.nse http-vuln-cve2013-7091.nse ovs-agent-version.nse tls-nextprotoneg.nse duplicates.nse http-vuln-cve2014-2126.nse p2p-conficker.nse tls-ticketbleed.nse eap-info.nse http-vuln-cve2014-2127.nse path-mtu.nse tn3270-screen.nse enip-info.nse http-vuln-cve2014-2128.nse pcanywhere-brute.nse tor-consensus-checker.nse epmd-info.nse http-vuln-cve2014-2129.nse pcworx-info.nse traceroute-geolocation.nse eppc-enum-processes.nse http-vuln-cve2014-3704.nse pgsql-brute.nse tso-brute.nse fcrdns.nse http-vuln-cve2014-8877.nse pjl-ready-message.nse tso-enum.nse finger.nse http-vuln-cve2015-1427.nse pop3-brute.nse ubiquiti-discovery.nse fingerprint-strings.nse http-vuln-cve2015-1635.nse pop3-capabilities.nse unittest.nse firewalk.nse http-vuln-cve2017-1001000.nse pop3-ntlm-info.nse unusual-port.nse firewall-bypass.nse http-vuln-cve2017-5638.nse port-states.nse upnp-info.nse flume-master-info.nse http-vuln-cve2017-5689.nse pptp-version.nse uptime-agent-info.nse fox-info.nse http-vuln-cve2017-8917.nse puppet-naivesigning.nse url-snarf.nse freelancer-info.nse http-vuln-misfortune-cookie.nse qconn-exec.nse ventrilo-info.nse ftp-anon.nse http-vuln-wnr1000-creds.nse qscan.nse versant-info.nse ftp-bounce.nse http-waf-detect.nse quake1-info.nse vmauthd-brute.nse ftp-brute.nse http-waf-fingerprint.nse quake3-info.nse vmware-version.nse ftp-libopie.nse http-webdav-scan.nse quake3-master-getservers.nse vnc-brute.nse ftp-proftpd-backdoor.nse http-wordpress-brute.nse rdp-enum-encryption.nse vnc-info.nse ftp-syst.nse http-wordpress-enum.nse rdp-ntlm-info.nse vnc-title.nse ftp-vsftpd-backdoor.nse http-wordpress-users.nse rdp-vuln-ms12-020.nse voldemort-info.nse ftp-vuln-cve2010-4221.nse http-xssed.nse realvnc-auth-bypass.nse vtam-enum.nse ganglia-info.nse iax2-brute.nse redis-brute.nse vulners.nse giop-info.nse iax2-version.nse redis-info.nse vuze-dht-info.nse gkrellm-info.nse icap-info.nse resolveall.nse wdb-version.nse gopher-ls.nse iec-identify.nse reverse-index.nse weblogic-t3-info.nse gpsd-info.nse ike-version.nse rexec-brute.nse whois-domain.nse hadoop-datanode-info.nse imap-brute.nse rfc868-time.nse whois-ip.nse hadoop-jobtracker-info.nse imap-capabilities.nse riak-http-info.nse wsdd-discover.nse hadoop-namenode-info.nse imap-ntlm-info.nse rlogin-brute.nse x11-access.nse hadoop-secondary-namenode-info.nse impress-remote-discover.nse rmi-dumpregistry.nse xdmcp-discover.nse hadoop-tasktracker-info.nse informix-brute.nse rmi-vuln-classloader.nse xmlrpc-methods.nse hbase-master-info.nse informix-query.nse rpcap-brute.nse xmpp-brute.nse hbase-region-info.nse informix-tables.nse rpcap-info.nse xmpp-info.nse hddtemp-info.nse ip-forwarding.nse rpc-grind.nse hnap-info.nse ip-geolocation-geoplugin.nse rpcinfo.nse hostmap-bfk.nse ip-geolocation-ipinfodb.nse rsa-vuln-roca.nse