Nmap使用

来源:互联网 发布:虚拟货源商源码 编辑:程序博客网 时间:2024/06/04 08:38

From: nmap 中文 man page nmap 英文 man page

Nmap扫描原理与用法:http://blog.csdn.net/aspirationflow/article/details/7694274

Nmap速查手册:http://wooyun.tangscan.cn/static/drops/tips-4333.html

扫描神器nmap最佳实践使用:http://blog.csdn.net/qq_29277155/article/details/50971727

使用nmap 验证多种漏洞:http://blog.csdn.net/jiangliuzheng/article/details/51992220

在nmap运行时直接按键盘的d键打“断点”,按下X键可以知道运行的进度

Nmap参考指南(Man Page)
描述

nmap : 网络探测工具和安全/端口扫描器。

nmap [ <扫描类型> …] [ <选项> ] { <扫描目标说明> }

    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协议而不是正在监听的端口的信息。    除了所感兴趣的端口表,Nmap还能提供关于目标机的进一步信息,包括反向域名,操作系统猜测,设备类型,和MAC地址。    一个典型的Nmap扫描如例 1 “一个典型的Nmap扫描”所示。在这个例子中,唯一的选项是-A, 用来进行操作系统及其版本的探测,-T4 可以加快执行速度,接着是两个目标主机名。

一个典型的Nmap扫描

译注

该Nmap参考指南中文版由Fei Yang fyang1024@gmail.com和Lei Lililei_721@6611.org 从英文版本翻译而来。 我们希望这将使全世界使用中文的人们更了解Nmap,但我们不能保证该译本和官方的 英文版本一样完整,也不能保证同步更新。 它可以在Creative Commons Attribution License下被修改并重新发布。
nmap 选项概要

选项(Options)。 当Nmap不带选项运行时,该选项概要会被输出,最新的版本在这里 http://www.insecure.org/nmap/data/nmap.usage.txt。 它帮助人们记住最常用的选项,但不能替代本手册其余深入的文档,一些晦涩的选项甚至不在这里。
[plain] view plain copy

Nmap 7.25BETA1 ( https://nmap.org )  Usage: nmap [Scan Type(s)] [Options] {target specification}  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                                         // 等价于 -sP 参数。都是ping 扫描    -Pn: Treat all hosts as online -- skip host discovery                      //-P0  (无Ping) 和 -Pn 参数效果一样    -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                                       //-P0  (无Ping) 和 -Pn 参数效果一样    -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: 防火墙/IDS 逃避和欺骗    -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  // -A是nmap全面扫描选项。有叫总和扫描,是一种完整扫描目标的方式    --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  SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES   //nmap man 手册地址  

Nmap还提供了无数选项。有一个是”-PT”,,我们已经介绍过了。在目标机或网络上常见的未经过滤的端口,进行TCP “ping”扫描。

另一个选项是”-P0”。在缺省设置下试图扫描一个端口之前,Nmap将用TCP ping” 和 ICMPecho命令ping一个目标机,如果ICMP和TCP的探测扫描得不到响应,目标主机或网络就不会被扫描,即使他们是运行着的。而”-P0”选项允许在扫描之前不进行ping,即可进行扫描。

你应该习惯使用”-v”命令,它详细列出所有信息,能和所有的扫描选项一起使用。你能反复地使用这个选项,获得有关目标机的更多信息。
使用”-p “选项,可以指定扫描端口。比如 ,攻击者想探测你的web服务器的ftp(port 21),telnet (port 23), dns (port 53), http (port 80),想知道你所使用的操作系统,它将使用SYN扫描。

nmap -sS -p 21,23,53,80 -O -v www.yourserver.com

小结:
使用什么样的方法来抵制一个黑客使用Nmap,这样的工具是有的,比如 Scanlogd, Courtney, and Shadow;,然而使用这样的工具并不能代替网络安全管理员。因为扫描只是攻击的前期准备,站点使用它只可以进行严密的监视。
使用Nmap监视自己的站点,系统和网络管理员能发现潜在入侵者对你的系统的探测。
目标说明

除了选项,所有出现在Nmap命令行上的都被视为对目标主机的说明。 最简单的情况是指定一个目标IP地址或主机名。

有时候您希望扫描整个网络的相邻主机。为此,Nmap支持CIDR风格的地址。您可以附加 一个/在一个IP地址或主机名后面, Nmap将会扫描所有和该参考IP地址具有 相同比特的所有IP地址或主机。 例如,192.168.10.0/24将会扫描192.168.10.0 (二进制格式: 11000000 10101000 00001010 00000000)和192.168.10.255 (二进制格式: 11000000 10101000 00001010 11111111)之间的256台主机。 192.168.10.40/24 将会做同样的事情。假设主机 scanme.nmap.org的IP地址是205.217.153.62, scanme.nmap.org/16 将扫描205.217.0.0和205.217.255.255之间的65,536 个IP地址。 所允许的最小值是/1, 这将会扫描半个互联网。最大值是/32,这将会扫描该主机或IP地址, 因为所有的比特都固定了。

CIDR标志位很简洁但有时候不够灵活。例如,您也许想要扫描 192.168.0.0/16,但略过任何以.0或者.255 结束的IP地址,因为它们通常是广播地址。 Nmap通过八位字节地址范围支持这样的扫描 您可以用逗号分开的数字或范围列表为IP地址的每个八位字节指定它的范围。 例如,192.168.0-255.1-254 将略过在该范围内以.0和.255结束的地址。 范围不必限于最后的8位:0-255.0-255.13.37 将在整个互联网范围内扫描所有以13.37结束的地址。 这种大范围的扫描对互联网调查研究也许有用。

IPv6地址只能用规范的IPv6地址或主机名指定。 CIDR 和八位字节范围不支持IPv6,因为它们对于IPv6几乎没什么用。

Nmap命令行接受多个主机说明,它们不必是相同类型。命令nmap scanme.nmap.org 192.168.0.0/8 10.0.0,1,3-7.0-255将和您预期的一样执行。

虽然目标通常在命令行指定,下列选项也可用来控制目标的选择:

-iL (从列表中输入)

从 <inputfilename>中读取目标说明。在命令行输入 一堆主机名显得很笨拙,然而经常需要这样。 例如,您的DHCP服务器可能导出10,000个当前租约的列表,而您希望对它们进行 扫描。如果您不是使用未授权的静态IP来定位主机,或许您想要扫描所有IP地址。 只要生成要扫描的主机的列表,用-iL 把文件名作为选项传给Nmap。列表中的项可以是Nmap在 命令行上接受的任何格式(IP地址,主机名,CIDR,IPv6,或者八位字节范围)。 每一项必须以一个或多个空格,制表符或换行符分开。 如果您希望Nmap从标准输入而不是实际文件读取列表, 您可以用一个连字符(-)作为文件名。

-iR (随机选择目标)

对于互联网范围内的调查和研究, 您也许想随机地选择目标。 <hostnum> 选项告诉 Nmap生成多少个IP。不合需要的IP如特定的私有,组播或者未分配的地址自动 略过。选项 0 意味着永无休止的扫描。记住,一些网管对于未授权的扫描可能会很感冒并加以抱怨。 使用该选项的后果自负! 如果在某个雨天的下午,您觉得实在无聊, 试试这个命令nmap -sS -PS80 -iR 0 -p 80随机地找一些网站浏览。

–exclude

原创粉丝点击