端口扫描之nmap命令

nmap

Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
  -sL: List Scan - simply list targets to scan
  -sn: Ping Scan - disable port scan
  -Pn: Treat all hosts as online -- skip host discovery
  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -PO[protocol list]: IP Protocol Ping
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
  --traceroute: Trace hop path to each host
SCAN TECHNIQUES:
  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
  -sU: UDP Scan
  -sN/sF/sX: TCP Null, FIN, and Xmas scans
  --scanflags <flags>: Customize TCP scan flags
  -sI <zombie host[:probeport]>: Idle scan
  -sY/sZ: SCTP INIT/COOKIE-ECHO scans
  -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,S:9
  --exclude-ports <port ranges>: Exclude the specified ports from scanning
  -F: Fast mode - Scan fewer ports than the default scan
  -r: Scan ports consecutively - don't randomize
  --top-ports <number>: Scan <number> most common ports
  --port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
  -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
  -sC: equivalent to --script=default
  --script=<Lua scripts>: <Lua scripts> is a comma separated list of
           directories, script-files or script-categories
  --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
  --script-args-file=filename: provide NSE script args in a file
  --script-trace: Show all data sent and received
  --script-updatedb: Update the script database.
  --script-help=<Lua scripts>: Show help about scripts.
           <Lua scripts> is a comma-separated list of script-files or
           script-categories.
OS DETECTION:
  -O: Enable OS detection
  --osscan-limit: Limit OS detection to promising targets
  --osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
  Options which take <time> are in seconds, or append 'ms' (milliseconds),
  's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
  -T<0-5>: Set timing template (higher is faster)
  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
  --min-parallelism/max-parallelism <numprobes>: Probe parallelization
  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
      probe round trip time.
  --max-retries <tries>: Caps number of port scan probe retransmissions.
  --host-timeout <time>: Give up on target after this long
  --scan-delay/--max-scan-delay <time>: Adjust delay between probes
  --min-rate <number>: Send packets no slower than <number> per second
  --max-rate <number>: Send packets no faster than <number> per second
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
  --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
  --data <hex string>: Append a custom payload to sent packets
  --data-string <string>: Append a custom ASCII string to sent packets
  --data-length <num>: Append random data to sent packets
  --ip-options <options>: Send packets with specified ip options
  --ttl <val>: Set IP time-to-live field
  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
  --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
  -oN/-oX/-oS/-oG <file>: Output scan 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 -vv or more for greater effect)
  -d: Increase debugging level (use -dd or more for greater effect)
  --reason: Display the reason a port is in a particular state
  --open: Only show open (or possibly open) ports
  --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
  --webxml: Reference stylesheet from Nmap.Org for more portable XML
  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
  -6: Enable IPv6 scanning
  -A: Enable OS detection, version detection, script scanning, and traceroute
  --datadir <dirname>: Specify custom Nmap data file location
  --send-eth/--send-ip: Send using raw ethernet frames or IP packets
  --privileged: Assume that the user is fully privileged
  --unprivileged: Assume the user lacks raw socket privileges
  -V: Print version number
  -h: Print this help summary page.
EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sn 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -Pn -p 80

-sT	         TCP connect()扫描,这种方式会在目标主机的日志中记录大批连接请求和错误信息。
-sS	         半开扫描,很少有系统能把它记入系统日志。不过,需要Root权限。
-sF  -sN	 秘密FIN数据包扫描、Xmas Tree、Null扫描模式
-sP	         ping扫描,Nmap在扫描端口时,默认都会使用ping扫描,只有主机存活,Nmap才会继续扫描。
-sU	         UDP扫描,但UDP扫描是不可靠的
-sA	         这项高级的扫描方法通常用来穿过防火墙的规则集
-sV	         探测端口服务版本
-Pn	         扫描之前不需要用ping命令,有些防火墙禁止ping命令。可以使用此选项进行扫描
-v	         显示扫描过程,推荐使用
-h	         帮助选项,是最清楚的帮助文档
-p	         指定端口,如“1-65535、1433、135、22、80”等
-O	         启用远程操作系统检测,存在误报
-A	         全面系统检测、启用脚本检测、扫描等
-oN/-oX/-oG	 将报告写入文件,分别是正常、XML、grepable 三种格式
-T4	         针对TCP端口禁止动态扫描延迟超过10ms
-iL	         读取主机列表,例如,“-iL C  ip.txt”
 
-iflist      查看本地主机的接口信息和路由信息
-A           选项用于使用进攻性方式扫描
-T4          指定扫描过程使用的时序,总有6个级别(0-5),级别越高,扫描速度越快,但也容易被防火墙或IDS检测并屏蔽掉,在网络通讯状况较好的情况下推荐使用T4
-oX test.xml 将扫描结果生成 test.xml 文件,如果中断,则结果打不开
-oA test.xml 将扫描结果生成 test.xml 文件,中断后,结果也可保存
-oG test.txt 将扫描结果生成 test.txt 文件
-sn    只进行主机发现,不进行端口扫描
-O    指定Nmap进行系统版本扫描
-sV   指定让Nmap进行服务版本扫描
-p <port ranges>   扫描指定的端口
-sS/sT/sA/sW/sM  指定使用 TCP SYN/Connect()/ACK/Window/Maimon scans的方式来对目标主机进行扫描
-sU   指定使用UDP扫描方式确定目标主机的UDP端口状况
-script <script name>    指定扫描脚本
-Pn             不进行ping扫描
-sP     用ping扫描判断主机是否存活,只有主机存活,nmap才会继续扫描,一般最好不加,因为有的主机会禁止ping
-PI     设置这个选项,让nmap使用真正的ping(ICMP echo请求)来扫描目标主机是否正在运行。
-iL 1.txt    批量扫描1.txt中的目标地址
 
-sL   List Scan 列表扫描,仅将指定的目标的IP列举出来,不进行主机发现
-sY/sZ   使用SCTP INIT/COOKIE-ECHO来扫描SCTP协议端口的开放的情况
-sO   使用IP protocol 扫描确定目标机支持的协议类型
-PO    使用IP协议包探测对方主机是否开启 
-PE/PP/PM    使用ICMP echo、 ICMP timestamp、ICMP netmask 请求包发现主机
-PS/PA/PU/PY    使用TCP SYN/TCP ACK或SCTP INIT/ECHO方式进行发现
 
-sN/sF/sX   指定使用TCP Null, FIN, and Xmas scans秘密扫描方式来协助探测对方的TCP端口状态
-e eth0           指定使用eth0网卡进行探测
-f    --mtu <val>   指定使用分片、指定数据包的 MTU.
-b <FTP relay host>   使用FTP bounce scan扫描方式
-g            指定发送的端口号
-r   不进行端口随机打乱的操作(如无该参数,nmap会将要扫描的端口以随机顺序方式扫描,以让nmap的扫描不易被对方防火墙检测到)
-v 表示显示冗余信息,在扫描过程中显示扫描的细节,从而让用户了解当前的扫描状态
-n    表示不进行DNS解析;
-D  <decoy1,decoy2[,ME],...>   用一组 IP 地址掩盖真实地址,其中 ME 填入自己的 IP 地址
-R            表示总是进行DNS解析。 
-F    快速模式,仅扫描TOP 100的端口 
-S <IP_Address>   伪装成其他 IP 地址
--ttl <val>   设置 time-to-live 时间
--badsum   使用错误的 checksum 来发送数据包(正常情况下,该类数据包被抛弃,如果收到回复,说明回复来自防火墙或 IDS/IPS)
--dns-servers     指定DNS服务器
--system-dns    指定使用系统的DNS服务器   
--traceroute    追踪每个路由节点 
--scanflags <flags>   定制TCP包的flags
--top-ports <number>   扫描开放概率最高的number个端口
--port-ratio <ratio>   扫描指定频率以上的端口。与上述--top-ports类似,这里以概率作为参数
--version-trace   显示出详细的版本侦测过程信息
--osscan-limit   限制Nmap只对确定的主机的进行OS探测(至少需确知该主机分别有一个open和closed的端口)
--osscan-guess   大胆猜测对方的主机的系统类型。由此准确性会下降不少,但会尽可能多为用户提供潜在的操作系统
--data-length <num>   填充随机数据让数据包长度达到 Num
--ip-options <options>   使用指定的 IP 选项来发送数据包
--spoof-mac <mac address/prefix/vendor name>    伪装 MAC 地址
--version-intensity <level>   指定版本侦测强度(0-9),默认为7。数值越高,探测出的服务越准确,但是运行时间会比较长。
--version-light   指定使用轻量侦测方式 (intensity 2)
--version-all   尝试使用所有的probes进行侦测 (intensity 9)
--version-trace   显示出详细的版本侦测过程信息

原文地址:https://www.cnblogs.com/linagcheng/p/13033704.html