nmap network scanning

29/12/2020
Chưa phân loại
This tutorial is part of a series of tutorial to get started with nmap from the beginning. The first tutorial was an introduction to nmap flags and what they do. This tutorial will explain additional methods to carry out network scans with nmap.  I will cover the follow topics.

  • Nmap phases
  • Scanning top ports with Nmap
  • Specifying a port with Nmap
  • Running a fast scan with Nmap
  • Showing IP ranges opened ports with Nmap
  • OS detection using Nmap
  • Aggressive OS detection using Nmap
  • Saving Nmap results

Note: Remember to replace the used IPs addresses and network devices for yours.

About Nmap phases:

Nmap Security Port Scanner has 10 stages during the scanning process: Script pre-scanning > Target enumeration > Host discovery (ping scanning) > Reverse-DNS resolution > Port scanning > Version detection > OS detection > Traceroute > Script scanning > Output > Script post-scanning.

Where:
Script pre-scanning: This phase is optional and does not take place in default scans, the “Script pre scanning” option is to call scripts from the Nmap Scripting Engine (NSE)  for the pre scanning phase like dhcp-discover.
Target enumeration: In this phase, the first one in default scan methods, nmaps only incorporates information on the targets to scan such as IP addresses, hosts, IP ranges, etc.
Host discovery (ping scanning): In this phase nmap learns what targets are online or reachable.
Reverse-DNS resolution: in this phase nmap will look for hostnames for the IP addresses.
Port Scanning: Nmap will discover ports and their status: open, closed or filtered.
Version detection: in this phase nmap will try to learn the version of the software running in open ports discovered in the previous phase, like what version of apache or ftp.
OS detection: nmap will try to learn the target’s OS.
Traceroute: nmap will discover the target’s route on the network or all routes in the network.
Script Scanning: This phase is optional, in this phase NSE scripts are executed, NSE scripts can be executed before the scan, during the scan and after it, but are optional.
Output: Nmap shows us information on the gathered data.
Script post-scanning: optional phase to run scripts after the scan was finished.

Note: for more information on nmap’s phases visit https://nmap.org/book/nmap-phases.html

Scanning top ports with Nmap:

Now let’s use the parameter –top-ports to scan the 5 top ports of the IP range 172.31.1.* including all possible addresses for the last octet. Nmap top ports are based on the most common services ports used. To scan the top 5 ports run:

nmap –top-ports 5 172.31.1.1-255

Where:
Nmap: calls the program
–top-ports 5: limits the scan to 5 top ports, top ports are the most used ports, you can edit the number.

The following example is the same but we use the wildcard (*) to define an IP range from 1 to 255, nmap will scan all them:

nmap –top-ports 5 172.31.1.*

Specifying a port with Nmap

To specify a port the option -p is used, to carry a scan to check a ftp of all IP addresses 172.31.1.* (with wildcard) execute:

nmap -p 21  172.31.1.*

Where:
Nmap: calls the program
-p 21: defines port 21
*: IP range from 1 to 255.

Running a fast scan with Nmap:

To run a Fast scan on all ports on devices belonging to an IP you need to apply the -F option:

nmap -F   172.31.1.*

The following command with parameter –open will show all ports opened on devices within an IP range:

Showing IP ranges opened ports with Nmap:

nmap –open   172.31.1.*

OS detection using Nmap:

To instruct Nmap to detect the target operating system (OS) run:

nmap -O <target>

Nmap detected a Linux Operating System and it’s kernel.

Aggressive OS detection using Nmap:

For a more aggressive OS detection you can run the following command:

nmap -sV –version-intensity 5 <Target>

Saving Nmap results:

To instruct Nmap to save results as txt you can use the -oN option as shown in the image below:

nmap -oN <FileName.txt> <Target>

The command above creates the file “result.txt” with the following format:

If you want to export results as XML use the options -oX instead.

nmap -oX <FileName.xml> <Target>

I hope this tutorial was useful as an introduction to nmap network scanning,

For more information on Nmap type “man nmap”. Keep following LinuxHint for more tips and updates on Linux.

Related articles:

Nmap flags and what they do
Nmap ping sweep
How to scan for services and vulnerabilities with Nmap

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to keep a Debian Network installation up-to-date

The Linux distribution Debian GNU/Linux [1] is made available as different CD/DVD ISO images. These images are prepared...
29/12/2020

How to Setup and Get Started with Kodi on Ubuntu

Kodi is a very popular open source media player for Windows, Mac, Linux and smartphone platforms like Android and iOS. It...
12/02/2020

How to install Calligra 3.0.1 Office Suite on Ubuntu 17.04

Calligra 3.0.1 recently released, is a set of applications written to help you to accomplish your day to day work. It...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024