Nmap (“Network Mapper(网络映射器)”) 是一款开放源代码的 网络探测和安全审核的工具。它的设计目标是快速地扫描大型网络,当然用它扫描单个主机也没有问题。Nmap以新颖的方式使用原始IP报文来发现网络上有哪些主机,
那些主机提供什么服务(应用程序名和版本),那些服务运行在什么操作系统(包括版本信息),它们使用什么类型的报文过滤器/防火墙,以及一堆其它功能。虽然Nmap通常用于安全审核,许多系统管理员和网络管理员也用它来做一些日常的工作,
比如查看整个网络的信息, 管理服务升级计划,以及监视主机和服务的运行。
Nmap输出的是扫描目标的列表,以及每个目标的补充信息,至于是哪些信息则依赖于所使用的选项。 “所感兴趣的端口表格”是其中的关键。那张表列出端口号,协
议,服务名称和状态。状态可能是 open(开放的),filtered(被过滤的),closed(关闭的),或者unfiltered(未被过滤的)。 Open(开放的)意味着目标机器
上的应用程序正在该端口监听连接/报文。 filtered(被过滤的) 意味着防火墙,过滤器或者其它网络障碍阻止了该端口被访问,Nmap无法得知 它是 open(开
放的) 还是 closed(关闭的)。 closed(关闭的) 端口没有应用程序在它上面监听,但是他们随时可能开放。 当端口对Nmap的探测做出响应,但是Nmap无法确定
它们是关闭还是开放时,这些端口就被认为是 unfiltered(未被过滤的) 如果Nmap报告状态组合 open|filtered 和 closed|filtered时,那说明Nmap无法
确定该端口处于两个状态中的哪一个状态。 当要求进行版本探测时,端口表也可以包含软件的版本信息。当要求进行IP协议扫描时 (-sO),Nmap提供关于所支持的
IP协议而不是正在监听的端口的信息。
TARGET SPECIFICATION: 目标说明
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0-255.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks 从文件中或者扫描列表,参数值为文件名
-iR <num hosts>: Choose random targets 随机扫描几个host,参数为个数,0表示无限
--exclude <host1[,host2][,host3],...>: Exclude hosts/networks 排除目标主机
--excludefile <exclude_file>: Exclude list from file 排除文件里的主机
HOST DISCOVERY: 主机发现
-sL: List Scan - simply list targets to scan 不进行主机发现
-sP: Ping Scan - go no further than determining if host is online 只进行主机发现
-P0: Treat all hosts as online -- skip host discovery 不进行主机发现 执行后续其他需要
-PS/PA/PU [portlist]: TCP SYN/ACK or UDP discovery probes to given ports 向目的主机端口进行TCP或者UDP报文,ACK或者SYN报文,模拟三次握手中的过程,通过RST(错误报文)进行主机发现
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes 使用ICMP echo, timestamp, and netmask 请求包发现主机
-n/-R: Never do DNS resolution/Always resolve [default: sometimes resolve]
SCAN TECHNIQUES:
-sS不连接/sT连接/sA主机是否存活/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans 端口扫描
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idlescan IP扫描,查看主机支持协议
-sO: IP protocol scan
-b <ftp relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports 只扫指定端口
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080
-F: Fast - Scan only the ports listed in the nmap-services file) 快速扫描,具体端口在nmap-service文件中
-r: Scan ports consecutively - don't randomize 不随机扫描,默认情况下是随机扫描的,因为速度快
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info 版本探测 -A一起探测
--version-light: Limit to most likely probes for faster identification
--version-all: Try every single probe for version detection
--version-trace: Show detailed version scan activity (for debugging)
OS DETECTION:
-O: Enable OS detection 系统探测
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE: 时间和性能
-T[0-6]: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <msec>: Parallel host scan group sizes
--min-parallelism/max-parallelism <msec>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <msec>: Specifies
probe round trip time.
--host-timeout <msec>: Give up on target after this long
--scan-delay/--max-scan-delay <msec>: Adjust delay between probes
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--data-length <num>: Append random data to sent packets
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address, prefix, or vendor name>: Spoof your MAC address
OUTPUT: 输出
-oN/-oX/-oS/-oG <file>: Output scan results in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use twice for more effect) 输出详细信息
-d[level]: Set or increase debugging level (Up to 9 is meaningful)
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--no-stylesheet: Prevent Nmap from associating XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning 启用ipv6扫描
-A: Enables OS detection and Version detection 版本和系统扫描
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send packets using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
-V: Print version number
-h: Print this help summary page.
具体的说明都在
https://nmap.org/book/man.html
中文版本:https://nmap.org/man/zh/
实例
1.nmap 192.168.123.1-4 --exclude 192.168.123.3
扫描192.168.123.1-4内除了192.168.123.3的主机
2.nmap -v www.seu.edu.cn
扫描www.seu.edu.cn所有打开的TCP端口
3.nmap -sS -O www.seu.edu.cn/24
不连接的TCP端口扫面,并分析系统