Keamanan

Nmap: Network Scanning — Panduan Lengkap

Kuasai Nmap (Network Mapper) — dari basic port scanning hingga advanced NSE scripting, OS fingerprinting, service detection, dan teknik stealth scanning untuk penetration testing dan vulnerability assessment

1. Pengenalan Nmap

Nmap (Network Mapper) adalah tool open-source yang dirancang untuk network discovery dan security auditing. Dikembangkan oleh Gordon Lyon (Fyodor) sejak tahun 1997, Nmap telah menjadi standar emas dalam network scanning dan digunakan oleh administrator jaringan, security professional, dan penetration tester di seluruh dunia.

Nmap mampu mendeteksi host yang aktif di jaringan, port yang terbuka, layanan yang berjalan, sistem operasi target, dan bahkan menjalankan script otomatis untuk vulnerability assessment. Nmap tersedia untuk Linux, Windows, macOS, dan BSD.

Fitur Utama Nmap

Fitur Deskripsi
Host DiscoveryMenemukan host aktif di jaringan (ping sweep, ARP scan)
Port ScanningMemindai port TCP/UDP yang terbuka, tertutup, atau terfilter
Service DetectionMengidentifikasi layanan dan versi yang berjalan di port terbuka
OS DetectionMendeteksi sistem operasi target melalui TCP/IP fingerprinting
NSE ScriptsScript Lua untuk vulnerability detection, exploitation, dan enumeration
Stealth ScanningTeknik scanning yang sulit dideteksi oleh IDS/IPS
Output FormatsNormal, XML, grepable, dan script kiddie output
Zenmap GUIAntarmuka grafis untuk Nmap
Diagram: Ekosistem Nmap dalam Security Assessment
┌────────────────────────────────────────────────────────────┐
│              NMAP ECOSYSTEM                                 │
│                                                            │
│  ┌──────────────┐     ┌──────────────┐    ┌────────────┐  │
│  │ Host         │────▶│ Port         │───▶│ Service    │  │
│  │ Discovery    │     │ Scanning     │    │ Detection  │  │
│  └──────────────┘     └──────────────┘    └────────────┘  │
│         │                   │                    │         │
│         ▼                   ▼                    ▼         │
│  ┌──────────────┐     ┌──────────────┐    ┌────────────┐  │
│  │ Network      │     │ OS           │    │ Vulnerability│ │
│  │ Mapping      │     │ Fingerprinting│   │ Assessment │  │
│  └──────────────┘     └──────────────┘    └────────────┘  │
│         │                   │                    │         │
│         ▼                   ▼                    ▼         │
│  ┌──────────────────────────────────────────────────────┐  │
│  │              NSE (Nmap Scripting Engine)              │  │
│  │  Vuln • Exploit • Auth • Brute • Discovery • Safe    │  │
│  └──────────────────────────────────────────────────────┘  │
│                          │                                 │
│                          ▼                                 │
│  ┌──────────────────────────────────────────────────────┐  │
│  │  Output: Normal • XML • Grepable • Script Kiddie    │  │
│  └──────────────────────────────────────────────────────┘  │
└────────────────────────────────────────────────────────────┘
⚠️ Peringatan Legal
  • HANYA scan jaringan yang Anda miliki atau memiliki izin tertulis untuk di-scan
  • Scanning tanpa izin adalah tindakan ilegal di banyak negara termasuk Indonesia (UU ITE)
  • Gunakan Nmap hanya untuk authorized penetration testing, security audit, atau belajar di lab sendiri
  • Untuk belajar, gunakan target yang sah seperti scanme.nmap.org (izin dari Nmap team)

2. Instalasi & Setup

Bash — Instalasi Nmap
# =============================================
# Instalasi Nmap di Berbagai OS
# =============================================

# Linux (Debian/Ubuntu)
sudo apt update
sudo apt install nmap -y

# Linux (RHEL/CentOS/Fedora)
sudo dnf install nmap -y
# atau
sudo yum install nmap -y

# Linux (Arch)
sudo pacman -S nmap

# macOS (Homebrew)
brew install nmap

# Windows
# Download installer dari https://nmap.org/download.html
# atau gunakan Chocolatey:
choco install nmap

# Verifikasi instalasi
nmap --version
# Output: Nmap version 7.94 ( https://nmap.org )

# =============================================
# Nmap Zenmap (GUI) — Opsional
# =============================================
# Linux
sudo apt install zenmap -y

# macOS/Windows: Sudah termasuk dalam installer

Syntax Dasar Nmap

Bash — Nmap Basic Syntax
# Syntax umum Nmap
nmap [scan type] [options] {target}

# =============================================
# Target Specification
# =============================================

# Scan satu host
nmap 192.168.1.1

# Scan berdasarkan hostname
nmap scanme.nmap.org

# Scan range IP
nmap 192.168.1.1-100        # 192.168.1.1 sampai 192.168.1.100

# Scan subnet (CIDR)
nmap 192.168.1.0/24          # Seluruh subnet /24

# Scan multiple target
nmap 192.168.1.1 192.168.1.2 192.168.1.3

# Scan dari file list
nmap -iL targets.txt

# Kecualikan host
nmap 192.168.1.0/24 --exclude 192.168.1.1
nmap 192.168.1.0/24 --excludefile exclude.txt

# =============================================
# Scan Semua Port
# =============================================

# Scan 1000 port default (cepat)
nmap 192.168.1.1

# Scan semua 65535 port (lambat tapi lengkap)
nmap -p- 192.168.1.1

# Scan port spesifik
nmap -p 22,80,443,8080 192.168.1.1

# Scan range port
nmap -p 1-1000 192.168.1.1

# Scan port terkenal (1-1024)
nmap -F 192.168.1.1

# Scan top 20 port paling umum
nmap --top-ports 20 192.168.1.1

3. Port Scanning Techniques

Nmap mendukung berbagai teknik port scanning yang berbeda dalam hal kecepatan, keakuratan, dan stealth. Memahami perbedaan antara setiap teknik sangat penting untuk memilih metode yang tepat sesuai situasi.

Status Port

Status Deskripsi
openAda layanan yang mendengarkan di port ini — menerima koneksi
closedTidak ada layanan, tapi port accessible — meresponse RST
filteredNmap tidak bisa menentukan — firewall/filter memblokir probe
unfilteredPort accessible tapi Nmap tidak bisa menentukan open/closed (hanya ACK scan)
open|filteredNmap tidak bisa membedakan open dan filtered
closed|filteredNmap tidak bisa membedakan closed dan filtered

Teknik TCP Scanning

Bash — TCP Scan Techniques
# =============================================
# 1. TCP Connect Scan (-sT)
# Melengkapi 3-way handshake penuh
# Paling akurat tapi paling terdeteksi
# =============================================
sudo nmap -sT 192.168.1.1

# =============================================
# 2. SYN Scan / Half-Open Scan (-sS) — DEFAULT
# Mengirim SYN, menerima SYN/ACK → port open
# Tidak menyelesaikan handshake (lebih stealth)
# Memerlukan root/sudo
# =============================================
sudo nmap -sS 192.168.1.1

# =============================================
# 3. NULL Scan (-sN)
# Mengirim paket tanpa flag TCP
# Open port → tidak ada response
# Closed port → RST response
# =============================================
sudo nmap -sN 192.168.1.1

# =============================================
# 4. FIN Scan (-sF)
# Mengirim paket dengan flag FIN
# Mirip dengan NULL scan
# Bisa melewati beberapa firewall stateless
# =============================================
sudo nmap -sF 192.168.1.1

# =============================================
# 5. XMAS Scan (-sX)
# Mengirim paket dengan FIN, PSH, URG flags
# Dinamakan "XMAS" karena flags menyala seperti pohon Natal
# =============================================
sudo nmap -sX 192.168.1.1

# =============================================
# 6. ACK Scan (-sA)
# Menentukan apakah port difilter oleh firewall
# Bukan untuk menentukan open/closed
# Open/Closed → RST response
# Filtered → tidak ada response / ICMP error
# =============================================
sudo nmap -sA 192.168.1.1

# =============================================
# 7. Window Scan (-sW)
# Mirip ACK scan tapi memeriksa TCP window size
# Bisa membedakan open dan closed pada beberapa sistem
# =============================================
sudo nmap -sW 192.168.1.1

# =============================================
# 8. Maimon Scan (-sM)
# Mengirim FIN/ACK flag
# Dinamai penemunya: Uriel Maimon
# =============================================
sudo nmap -sM 192.168.1.1

Teknik UDP Scanning

Bash — UDP Scan Techniques
# =============================================
# UDP Scan (-sU)
# UDP scanning LAMBAT karena tidak ada handshake
# Port terbuka → tidak ada response (atau aplikasi response)
# Port tertutup → ICMP Port Unreachable
# Filtered → ICMP unreachable diblokir (atau tidak ada)
# =============================================

# Scan port UDP tertentu
sudo nmap -sU -p 53,67,68,69,123,161,162,500,514,1900 192.168.1.1

# Scan top 100 port UDP
sudo nmap -sU --top-ports 100 192.168.1.1

# Kombinasi TCP + UDP scan
sudo nmap -sS -sU -p T:22,80,443,U:53,67,161 192.168.1.1

# =============================================
# Service yang Umum di Port UDP
# =============================================
# 53    - DNS
# 67/68 - DHCP
# 69    - TFTP
# 123   - NTP
# 161   - SNMP
# 162   - SNMP Trap
# 500   - IKE (IPSec)
# 514   - Syslog
# 1900  - UPnP/SSDP
# 5353  - mDNS

Tabel Perbandingan Scan Techniques

Scan Type Flag Stealth Kecepatan Root? Catatan
TCP Connect-sT❌ Rendah⚡ SedangTidak3-way handshake paling lengkap
SYN Scan-sS✅ Tinggi⚡ CepatYaDefault Nmap — half-open scan
NULL Scan-sN✅ Tinggi⚡ LambatYaTidak bekerja di Windows
FIN Scan-sF✅ Tinggi⚡ LambatYaBisa melewati stateless firewall
XMAS Scan-sX✅ Tinggi⚡ LambatYaFIN+PSH+URG flags
ACK Scan-sA✅ Sedang⚡ CepatYaMapping firewall rules
UDP Scan-sU⚠️ Sedang🐌 Sangat lambatYaUDP tanpa handshake

4. Service & Version Detection

Setelah menemukan port terbuka, langkah selanjutnya adalah mengidentifikasi layanan dan versi software yang berjalan. Informasi ini kritis untuk vulnerability assessment karena memungkinkan Anda mencari CVE (Common Vulnerabilities and Exposures) yang relevan.

Bash — Service & Version Detection
# =============================================
# Version Detection (-sV)
# Mengirim probe ke port terbuka untuk mengidentifikasi
# layanan dan versi yang tepat
# =============================================

# Version scan standar
sudo nmap -sV 192.168.1.1

# Output contoh:
# PORT    STATE SERVICE VERSION
# 22/tcp  open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.1
# 80/tcp  open  http    Apache httpd 2.4.52
# 443/tcp open  ssl/http Apache httpd 2.4.52
# 3306/tcp open mysql  MySQL 8.0.32

# Version scan dengan intensity lebih tinggi (lebih lambat, lebih akurat)
sudo nmap -sV --version-intensity 9 192.168.1.1

# Version intensity levels:
# 0 = Light (cepat, kurang akurat)
# 1-7 = Normal range
# 8-9 = All probes (lambat, paling akurat)

# =============================================
# Aggressive Scan (-A)
# Mengaktifkan: OS detection, version detection,
# script scanning, dan traceroute
# =============================================
sudo nmap -A 192.168.1.1

# Setara dengan: nmap -sV -sC -O --traceroute 192.168.1.1

# =============================================
# Banner Grabbing Manual
# =============================================

# Grab banner dari port 22 (SSH)
echo "" | nc -w 3 192.168.1.1 22

# Grab banner dari port 80 (HTTP)
echo "HEAD / HTTP/1.0\r\n\r\n" | nc -w 3 192.168.1.1 80

# =============================================
# Contoh Output Service Detection
# =============================================
# PORT     STATE SERVICE     VERSION
# 21/tcp   open  ftp         vsftpd 3.0.3
# 22/tcp   open  ssh         OpenSSH 8.9p1 Ubuntu 3
# 25/tcp   open  smtp        Postfix smtpd
# 80/tcp   open  http        nginx 1.18.0
# 443/tcp  open  ssl/https   nginx 1.18.0
# 3306/tcp open  mysql       MySQL 8.0.32-0ubuntu0.22.04.2
# 5432/tcp open  postgresql  PostgreSQL 14.7
# 8080/tcp open  http-proxy  Squid http proxy 5.2
# 8443/tcp open  ssl/https   Jetty 11.0.13
# Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

5. OS Detection & Fingerprinting

OS Detection di Nmap bekerja dengan mengirim serangkaian TCP dan UDP probe ke target, lalu menganalisis respons yang diterima. Setiap sistem operasi memiliki "sidik jari" unik dalam cara mereka menangani paket TCP/IP — seperti initial window size, TCP options, TTL, dan flag behavior.

Bash — OS Detection
# =============================================
# OS Detection (-O)
# Memerlukan root/sudo
# Membutuhkan minimal 1 port open dan 1 closed
# =============================================

# Basic OS detection
sudo nmap -O 192.168.1.1

# Contoh output:
# OS details: Linux 4.15 - 5.6
# Network Distance: 1 hop
# OS CPE: cpe:/o:linux:linux_kernel:4.15
# Aggressive OS guesses: Linux 4.15 (95%), Linux 5.0 (93%)

# OS detection dengan guess yang lebih agresif
sudo nmap -O --osscan-guess 192.168.1.1

# Limit detection ke 5 hasil terbaik
sudo nmap -O --max-os-tries 5 192.168.1.1

# Kombinasi lengkap: OS + Version + Scripts + Traceroute
sudo nmap -A 192.168.1.1

# =============================================
# TCP/IP Fingerprinting Detail
# =============================================
# Nmap menganalisis:
# 1. Initial Sequence Number (ISN) randomness
# 2. IP ID sequence generation
# 3. TCP initial window size
# 4. TCP options (order, values)
# 5. Don't Fragment (DF) bit
# 6. Initial TTL value
# 7. TCP timestamp behavior
# 8. SYN/ACK/RST response behavior

# =============================================
# Contoh Output Detail OS Detection
# =============================================
# Running: Linux 4.X|5.X (95%)
# OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
# OS details: Linux 4.15 - 5.6
# Uptime guess: 45.231 days (since Sun May 11 03:42:17 2026)
# Network Distance: 1 hop
# TCP Sequence Prediction: Difficulty 256 (Good luck!)
# IP ID Sequence Generation: All zeros
Diagram: TCP/IP Fingerprinting
┌────────────────────────────────────────────────────────────┐
│          OS DETECTION VIA TCP/IP FINGERPRINTING            │
│                                                            │
│  Nmap mengirim probe → menganalisis response              │
│                                                            │
│  Probe 1: TCP SYN ke port open                            │
│  → Analisis: Initial Window Size, TCP Options, TTL        │
│                                                            │
│  Probe 2: TCP SYN ke port closed                          │
│  → Analisis: RST response behavior, TTL                   │
│                                                            │
│  Probe 3: TCP ACK ke port open                            │
│  → Analisis: Window size dalam response                   │
│                                                            │
│  Probe 4: TCP FIN+PSH+URG ke port closed                  │
│  → Analisis: Response handling of abnormal flags          │
│                                                            │
│  Probe 5: UDP ke port closed                              │
│  → Analisis: ICMP unreachable response                    │
│                                                            │
│  ┌──────────────────────────────────────────────┐          │
│  │ Fingerprints Database (nmap-os-db)           │          │
│  │ 26,000+ OS fingerprints                      │          │
│  │ Match dengan response yang diterima           │          │
│  │ Confidence: 0-100%                           │          │
│  └──────────────────────────────────────────────┘          │
│                                                            │
│  Hasil: "Linux 4.15 - 5.6 (95%)"                          │
└────────────────────────────────────────────────────────────┘

6. NSE Scripts (Nmap Scripting Engine)

Nmap Scripting Engine (NSE) adalah salah satu fitur paling powerful dari Nmap. NSE memungkinkan Anda menjalankan script Lua untuk otomasi berbagai tugas: dari vulnerability detection, service enumeration, hingga bahkan exploitation. Saat ini tersedia 600+ script yang sudah termasuk dalam instalasi Nmap.

Kategori NSE Scripts

Kategori Deskripsi Contoh
authAuthentication bypass dan brute forcehttp-brute, ftp-brute, ssh-brute
defaultScript yang dijalankan dengan -sChttp-title, ssh-hostkey, ssl-cert
discoveryNetwork discovery dan enumerationdns-brute, snmp-brute, smb-enum-shares
dosDenial of Service testingdhcp-dos (hanya di lab!)
exploitExploit vulnerability yang diketahuihttp-shellshock, smb-vuln-ms17-010
externalInteraksi dengan layanan externalwhois-ip, ip-geolocation
fuzzerFuzzing untuk menemukan vulnerabilityhttp-form-fuzzer
intrusiveBerpotensi crash/membebani targethttp-sql-injection
malwareDeteksi malware di targetsmtp-open-relay, http-malware-host
safeTidak berbahaya untuk targethttp-headers, banner, ssl-cert
versionMembantu version detectionhttp-server-header
vulnDeteksi vulnerability spesifikvulners, http-vuln-cve2021-41773
Bash — NSE Script Usage
# =============================================
# Menggunakan NSE Scripts
# =============================================

# Jalankan script "default" (sama dengan -sC)
sudo nmap -sC 192.168.1.1
# Setara dengan: nmap --script=default 192.168.1.1

# Jalankan script spesifik
sudo nmap --script=http-title 192.168.1.1
sudo nmap --script=ssl-cert -p 443 192.168.1.1

# Jalankan beberapa script sekaligus
sudo nmap --script=http-title,http-headers,http-methods -p 80,443 192.168.1.1

# Jalankan semua script dalam kategori
sudo nmap --script=vuln 192.168.1.1
sudo nmap --script=safe 192.168.1.1
sudo nmap --script=discovery 192.168.1.1

# Jalankan semua script dalam beberapa kategori
sudo nmap --script="safe and vuln" 192.168.1.1

# Kecualikan script tertentu
sudo nmap --script="not dos" 192.168.1.1

# =============================================
# Contoh Script Penting untuk Security Audit
# =============================================

# SSL/TLS audit
sudo nmap -sV --script=ssl-enum-ciphers -p 443 192.168.1.1

# SMB vulnerability scan (EternalBlue, dll)
sudo nmap --script=smb-vuln* -p 445 192.168.1.1

# HTTP vulnerability scan
sudo nmap --script=http-vuln* -p 80,443,8080 192.168.1.1

# DNS enumeration
sudo nmap --script=dns-brute --script-args dns-brute.threads=10 example.com

# FTP anonymous login check
sudo nmap --script=ftp-anon -p 21 192.168.1.1

# SNMP enumeration
sudo nmap --script=snmp-brute,snmp-info -p 161 -sU 192.168.1.1

# MySQL enumeration
sudo nmap --script=mysql-info,mysql-enum -p 3306 192.168.1.1

# SSH audit
sudo nmap --script=ssh2-enum-algos,ssh-hostkey -p 22 192.168.1.1

# Vulners — cek CVE dari versi service yang terdeteksi
sudo nmap -sV --script=vulners 192.168.1.1

Menulis NSE Script Custom

Lua — Custom NSE Script
-- custom-http-check.nse
-- Script NSE untuk mengecek header keamanan HTTP

local http = require "http"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"

-- Metadata script
description = [[
Mengecek apakah web server memiliki security headers yang lengkap.
Digunakan untuk security audit konfigurasi web server.
]]

-- Kategorisasi
categories = {"safe", "discovery"}

-- Hanya jalankan pada port HTTP
portrule = shortport.http

-- Fungsi utama
action = function(host, port)
  local result = {}

  -- Kirim HTTP GET request
  local response = http.get(host, port, "/")

  if not response or not response.header then
    return "Tidak bisa mengakses web server"
  end

  -- Cek security headers
  local headers_to_check = {
    "Content-Security-Policy",
    "X-Frame-Options",
    "X-Content-Type-Options",
    "Strict-Transport-Security",
    "X-XSS-Protection",
    "Referrer-Policy",
    "Permissions-Policy"
  }

  for _, header_name in ipairs(headers_to_check) do
    local value = response.header[header_name:lower()]
    if value then
      table.insert(result, string.format("✅ %s: %s", header_name, value))
    else
      table.insert(result, string.format("❌ %s: TIDAK ADA", header_name))
    end
  end

  -- Cek server header (informasi disclosure)
  local server = response.header["server"]
  if server then
    table.insert(result, string.format("⚠️ Server: %s (info disclosure)", server))
  end

  -- Cek X-Powered-By header
  local powered = response.header["x-powered-by"]
  if powered then
    table.insert(result, string.format("⚠️ X-Powered-By: %s (info disclosure)", powered))
  end

  return stdnse.format_output(true, result)
end

-- Simpan di: /usr/share/nmap/scripts/custom-http-check.nse
-- Jalankan: nmap --script=custom-http-check -p 80,443 target
-- Update database: nmap --script-updatedb

7. Stealth Scanning Techniques

Stealth scanning bertujuan untuk memindai target tanpa (atau dengan minimal) terdeteksi oleh sistem IDS/IPS (Intrusion Detection/Prevention System). Teknik-teknik ini memanipulasi paket TCP/IP untuk mengurangi footprint dan menghindari signature-based detection.

Bash — Stealth Scanning Techniques
# =============================================
# 1. Timing & Performance (-T)
# Mengontrol kecepatan scan untuk menghindari deteksi
# =============================================

# T0 - Paranoid (sangat lambat, untuk IDS evasion)
sudo nmap -T0 192.168.1.1

# T1 - Sneaky (lambat)
sudo nmap -T1 192.168.1.1

# T2 - Polite (lambat, kurangi bandwidth)
sudo nmap -T2 192.168.1.1

# T3 - Normal (default)
sudo nmap -T3 192.168.1.1

# T4 - Aggressive (cepat, untuk jaringan cepat)
sudo nmap -T4 192.168.1.1

# T5 - Insane (sangat cepat, akurasi berkurang)
sudo nmap -T5 192.168.1.1

# =============================================
# 2. Fragmentation (-f)
# Memecah paket menjadi fragmen kecil (8 byte)
# Bisa melewati beberapa packet filter/IDS
# =============================================
sudo nmap -f 192.168.1.1

# Fragmen dengan ukuran tertentu
sudo nmap -f --mtu 24 192.168.1.1

# =============================================
# 3. Spoof Source IP (-S)
# Mengirim paket dengan IP source palsu
# Perlu berada di network yang sama atau me-route
# =============================================
sudo nmap -S 10.0.0.100 -e eth0 192.168.1.1

# =============================================
# 4. Decoy Scan (-D)
# Mengirim scan dari banyak IP (termasuk IP palsu)
# IDS akan melihat traffic dari banyak sumber
# =============================================
sudo nmap -D RND:10 192.168.1.1    # 10 IP random decoy

# Tentukan decoy spesifik
sudo nmap -D 10.0.0.1,10.0.0.2,ME,10.0.0.3 192.168.1.1
# ME = IP asli Anda (posisikan di tengah)

# =============================================
# 5. Spoof MAC Address (--spoof-mac)
# Mengubah MAC address pada paket
# Hanya untuk Ethernet/WiFi
# =============================================
sudo nmap --spoof-mac 00:11:22:33:44:55 192.168.1.1
sudo nmap --spoof-mac Cisco 192.168.1.1     # Spoof sebagai Cisco
sudo nmap --spoof-mac 0 192.168.1.1          # Random MAC

# =============================================
# 6. Idle Scan (-sI) — Paling Stealth
# Menggunakan "zombie host" sebagai perantara
# Target hanya melihat traffic dari zombie, bukan Anda
# =============================================
sudo nmap -sI zombie_host:port 192.168.1.1
# Contoh: sudo nmap -sI 10.0.0.50:80 192.168.1.1

# =============================================
# 7. Source Port Manipulation (-g / --source-port)
# Mengirim dari port spesifik (misal 53/80)
# Firewall sering mengizinkan traffic dari port terkenal
# =============================================
sudo nmap -g 53 192.168.1.1     # DNS port
sudo nmap -g 80 192.168.1.1     # HTTP port
sudo nmap --source-port 443 192.168.1.1

# =============================================
# 8. Custom TTL (--ttl)
# Mengatur TTL untuk mengelabui deteksi
# =============================================
sudo nmap --ttl 128 192.168.1.1

# =============================================
# 9. Randomize Host Order (--randomize-hosts)
# Scan host dalam urutan acak untuk menghindari pattern
# =============================================
sudo nmap --randomize-hosts 192.168.1.0/24

# =============================================
# 10. Scan Delay (--scan-delay)
# Tambah delay antara probe
# =============================================
sudo nmap --scan-delay 5s 192.168.1.1
sudo nmap --max-rate 100 192.168.1.1   # Max 100 packets/detik
💡 Tips Stealth Scanning yang Efektif
  • Kombinasikan beberapa teknik — decoy + fragment + slow timing
  • Gunakan SYN scan (-sS) sebagai baseline — sudah cukup stealth untuk kebanyakan kasus
  • Idle scan (-sI) adalah teknik paling stealth, tapi memerlukan zombie host yang tepat
  • Timing T0-T1 sangat lambat — butuh berjam-jam untuk scan satu host
  • Fragment scan bisa melewati beberapa IDS lama tapi tidak efektif melawan IDS modern
  • Scan dari VPS/VPN — gunakan infrastruktur yang tidak terkait dengan identitas Anda
  • Selalu miliki izin tertulis sebelum melakukan penetration testing

8. Output & Report Formats

Bash — Nmap Output Formats
# =============================================
# Output Formats
# =============================================

# Normal output (ke layar, default)
sudo nmap 192.168.1.1

# Simpan ke file normal
sudo nmap -oN scan_result.txt 192.168.1.1

# XML output (untuk di-parse tool lain)
sudo nmap -oX scan_result.xml 192.168.1.1

# Grepable output (mudah di-grep/awk)
sudo nmap -oG scan_result.gnmap 192.168.1.1

# Simpan dalam SEMUA format sekaligus
sudo nmap -oA scan_result 192.168.1.1
# Menghasilkan: scan_result.nmap, scan_result.xml, scan_result.gnmap

# Script kiddie output (hanya untuk fun)
sudo nmap -oS scan_result.skid 192.168.1.1

# =============================================
# Verbosity & Debugging
# =============================================

# Increase verbosity (lebih banyak info di layar)
sudo nmap -v 192.168.1.1
sudo nmap -vv 192.168.1.1    # Lebih verbose
sudo nmap -vvv 192.168.1.1   # Sangat verbose

# Debug level
sudo nmap -d 192.168.1.1     # Debug level 1
sudo nmap -dd 192.168.1.1    # Debug level 2

# Reason (tampilkan alasan status port)
sudo nmap --reason 192.168.1.1

# Packet trace (tampilkan semua paket yang dikirim/diterima)
sudo nmap --packet-trace 192.168.1.1

# Open only (hanya tampilkan port open)
sudo nmap --open 192.168.1.1

# =============================================
# Contoh Scan Komprehensif
# =============================================

# Full comprehensive scan
sudo nmap -sS -sV -sC -O -A \
  -p- \
  --script=default,vuln \
  -T4 \
  --reason \
  --open \
  -oA full_scan_$(date +%Y%m%d) \
  192.168.1.0/24

# Penjelasan flags:
# -sS    = SYN scan (default, stealth)
# -sV    = Version detection
# -sC    = Default scripts
# -O     = OS detection
# -A     = Aggressive (OS + version + scripts + traceroute)
# -p-    = Scan semua 65535 port
# --script=default,vuln = Jalankan default + vuln scripts
# -T4    = Aggressive timing (cepat)
# --reason = Tampilkan alasan status port
# --open = Hanya tampilkan port terbuka
# -oA    = Simpan dalam semua format

9. Quiz: Uji Pemahamanmu!

Setelah membaca tutorial di atas, jawablah 5 pertanyaan berikut untuk menguji pemahamanmu tentang Nmap:

Pertanyaan 1: Apa default scan type yang digunakan Nmap dengan hak akses root?

a) TCP Connect Scan (-sT)
b) SYN Scan / Half-Open Scan (-sS)
c) NULL Scan (-sN)
d) UDP Scan (-sU)

Pertanyaan 2: Flag apa yang digunakan untuk aggressive scan (OS + version + scripts + traceroute)?

a) -v
b) -F
c) -A
d) -O

Pertanyaan 3: Teknik Nmap apa yang menggunakan "zombie host" sebagai perantara?

a) Decoy Scan (-D)
b) Fragment Scan (-f)
c) Idle Scan (-sI)
d) XMAS Scan (-sX)

Pertanyaan 4: Kategori NSE script apa yang digunakan untuk mendeteksi vulnerability spesifik?

a) safe
b) exploit
c) vuln
d) discovery

Pertanyaan 5: Flag apa untuk menyimpan output Nmap dalam semua format sekaligus?

a) -oN
b) -oX
c) -oA
d) -oG
🔍 Zoom
100%
🎨 Tema