Enumeration = جمع معلومات عن الهدف بشكل منهجي
Nmap = السلاح الأساسي
# الفلسفة:
# 1. اكتشف الأجهزة الحية
# 2. اكتشف البورتات المفتوحة
# 3. حدد الخدمات والإصدارات
# 4. شغّل scripts للمعلومات الإضافية
# تثبيت (موجود في Kali)
sudo apt install nmap
# آخر إصدار
nmap --version
# Help
nmap --help
man nmap
# Ping Scan — اكتشاف الأجهزة الحية (بدون port scan)
nmap -sn 10.10.10.0/24
nmap -sn 192.168.1.0/24
# Disable Host Discovery — افحص حتى لو ما يرد على ping
nmap -Pn 10.10.10.5
# ARP Scan (أسرع في نفس الـ subnet)
nmap -sn -PR 10.10.10.0/24
# ICMP Ping
nmap -sn -PE 10.10.10.0/24
# TCP SYN Discovery
nmap -sn -PS80,443 10.10.10.0/24
# من list
nmap -sn -iL hosts.txt
# Output أجهزة الحية فقط
nmap -sn 10.10.10.0/24 | grep "Nmap scan report"
nmap -sn 10.10.10.0/24 -oG - | grep "Up"
# أنواع الـ Scans:
# SYN Scan (default مع root) — الأسرع والأخفى
sudo nmap -sS <IP>
# TCP Connect Scan (بدون root)
nmap -sT <IP>
# UDP Scan (بطيء)
sudo nmap -sU <IP>
sudo nmap -sU --top-ports 20 <IP>
# Scan جميع البورتات (65535)
nmap -p- <IP>
nmap -p- --min-rate 5000 <IP> # أسرع
# بورتات محددة
nmap -p 22,80,443,8080 <IP>
nmap -p 1-1000 <IP>
nmap -p 80,443-445 <IP>
# أشهر 1000 بورت (default)
nmap <IP>
# أشهر 100 بورت
nmap --top-ports 100 <IP>
# Service + Version Detection
nmap -sV <IP>
nmap -sV --version-intensity 5 <IP> # 0-9 (أعلى = أدق لكن أبطأ)
# OS Detection
sudo nmap -O <IP>
# Aggressive Scan (-A = -sV -O -sC --traceroute)
nmap -A <IP>
# Default Scripts
nmap -sC <IP>
nmap -sV -sC <IP> # الأشيع
# Normal Output
nmap -sV <IP> -oN output.txt
# Grepable Format (للمعالجة)
nmap -sV <IP> -oG output.gnmap
# XML Format
nmap -sV <IP> -oX output.xml
# كل الصيغ معاً
nmap -sV <IP> -oA output # ينشئ .nmap + .xml + .gnmap
# تحويل XML → HTML
xsltproc output.xml -o output.html
# قراءة نتائج سابقة
nmap --resume output.gnmap
# استخراج معلومات من gnmap
grep "open" output.gnmap
grep "22/open" output.gnmap
cat output.gnmap | grep "Ports:" | cut -d" " -f2 | tr ',' '\n' | grep open
# Version Detection كامل
nmap -sV --version-all <IP>
# Banner Grabbing
nc -nv <IP> 22
nc -nv <IP> 80
# خدمات مهمة وطريقة فحصها:
# FTP
nmap -sV -p 21 --script ftp-anon,ftp-syst <IP>
# SSH
nmap -sV -p 22 --script ssh-auth-methods,ssh2-enum-algos <IP>
# HTTP
nmap -sV -p 80,443 --script http-enum,http-headers,http-server-header <IP>
# SMB
nmap -sV -p 445 --script smb-security-mode,smb-os-discovery <IP>
# SNMP
sudo nmap -sU -p 161 --script snmp-info <IP>
# MySQL
nmap -sV -p 3306 --script mysql-info,mysql-empty-password <IP>
# NSE Scripts موجودة في:
ls /usr/share/nmap/scripts/
# البحث عن scripts
nmap --script-help "smb*"
ls /usr/share/nmap/scripts/ | grep http
# تشغيل script محدد
nmap --script http-enum <IP>
nmap --script ftp-anon -p 21 <IP>
# تشغيل مجموعة scripts
nmap --script "smb-enum-*" -p 445 <IP>
nmap --script "vuln" <IP>
# تشغيل script مع arguments
nmap --script http-brute --script-args http-brute.path=/admin -p 80 <IP>
nmap --script smtp-enum-users --script-args smtp-enum-users.methods={VRFY,RCPT} -p 25 <IP>
# Categories:
# auth, broadcast, brute, default, discovery, dos, exploit, external
# fuzzer, intrusive, malware, safe, version, vuln
nmap --script "default and safe" <IP>
nmap --script "auth" <IP>
nmap --script "vuln and not intrusive" <IP>