Nmap是一款针对大型网络的端口扫描工具,被广泛应用于黑客领域做漏洞探测以及安全扫描,其主要功能有主机发现(Host Discovery)、 端口扫描(Port Scanning)、 版本侦测(Version Detection) 、操作系统侦测(Operating System Detection),可以适用于winodws,linux,mac等操作系统。

1、yum安装nmap

yum install nmap

nmap 命令参数:nmap -h

[root@lamp01 scripts]# nmap -h
Nmap 5.51 ( http://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
-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
-PR: ARP ping - does not need HW address -> IP translation
-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
-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
-sR: Check what service uses opened ports using RPC scan
--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-trace: Show all data sent and received
--script-updatedb: Update the script database.
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
--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)
--log-errors: Log errors/warnings to the normal-format output file
--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
SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES

2、nmap 常用命令介绍:

扫描单个主机:

nmap 192.168.43.118

扫描单个子网主机:

nmap 192.168.43.0/24

扫描多个主机:

nmap 192.168.43.117 192.168.43.43.99

扫描一个范围内的主机:

nmap 192.168.43.1-254

若你有一个ip地址表,将ip地址存在ip.log文件中,命令如下:

nmap -iL ip.log

若你想查看扫描的所有主机列表命令如下:

nmap -sL 192.168.43.1/24

扫描一子网主机且排除某一个ip命令:

nmap 192.168.43.1/24 -exclude 192.168.43.118

扫描一子网主机且排除某一个ip地址表命令:

nmap 192.168.43.1/24 -exclude ip.log

扫描主机路由跟踪信息:

nmap --traceroute 192.168.43.118

扫描主机信息结果详细输出:

nmap -vv --traceroute 192.168.43.118

扫描某主机上指定的端口或协议,例如80,21,22

nmap -p U:53,T:80,21,22,S:9 192.168.43.118 (其中T代表TCP协议、U代表UDP协议、S代表SCTP协议)

快速扫描端口模式,扫描100个最有可能开放的端口   -v 获取扫描的信息 

nmap -F -v 192.168.43.118

Tcp SYN Scan (sS)  隐蔽扫描

这是一个不完整的扫描方式,它被称为半开放扫描,Nmap发送SYN包到远程主机,但是它不会产生任何会话,在syn扫描中不需要通过完整3次的握手,因此不会在目标主机上产生任何日志记录,这个就是SYN扫描的优势,但是这种扫描是需要root权限(对于windows用户来说,是没有root权限这个概念的,root权限是linux的最高权限,对应windows的管理员权限)

nmap -sS 192.168.43.118

Tcp connect() scan(sT) 最常用

如果不选择SYN扫描,TCP connect()扫描就是默认的扫描模式,不同于Tcp SYN扫描,Tcp connect()扫描需要完成三次握手,并且要求调用系统的connect(),Tcp connect()扫描技术只适用于找出TCP和UDP端口,但是这种方式扫描的速度快,准确性高,对操作者没有权限上的要求,但是容易被防火墙和IDS(防入侵系统)发现。

nmap -sT 192.168.43.118

UDP scan(sU)  

顾名思义,这种扫描技术用来寻找目标主机打开的UDP端口,它不需要发送任何的SYN包,因为这种技术是针对UDP端口的。UDP扫描发送UDP数据包到目标主机,并等待响应,如果返回ICMP不可达的错误消息,说明端口是关闭的,如果得到正确的适当的回应,说明端口是开放的。

nmap -sU 192.168.43.118

FIN scan (sF)  

有时候Tcp SYN扫描不是最佳的扫描模式,因为有防火墙的存在,目标主机有时候可能有IDS和IPS系统的存在,防火墙会阻止掉SYN数据包。发送一个设置了FIN标志的数据包并不需要完成TCP的握手,收到RST回复说明该端口关闭,否则说明是open或filtered状态

nmap -sF 192.168.43.118

PING Scan (sP) 扫描在线主机

PING扫描它只用于找出主机是否是存在在网络中的,它不是用来发现是否开放端口的,PING扫描需要ROOT权限,如果用户没有ROOT权限,PING扫描将会使用connect()调用。

nmap -sP 192.168.43.118

版本检测(sV)  

版本检测是用来扫描目标主机和端口上运行的软件的版本,它不同于其它的扫描技术,它不是用来扫描目标主机上开放的端口,不过它需要从开放的端口获取信息来判断软件的版本,使用版本检测扫描之前需要先用TCP SYN扫描开放了哪些端口。

nmap -sV 192.168.43.118

Idle scan (sL)  

Idle scan是一种先进的匿名扫描技术,它不是用你真实的主机Ip发送数据包,而是使用另外一个目标网络的主机发送数据包,例如:通过目标网络中的192.168.43.118向主机192.168.43.4发送数据,来获取192.168.1.1开放的端口。

nmap -sL 192.168.43.118 192.168.43.4

有需要其它的扫描技术,如 FTP bounce(FTP反弹), fragmentation scan(碎片扫描),IP protocol scan(IP协议扫描),以上讨论的是几种最主要的扫描方式。

Nmap的OS检测(O)

Nmap最重要的特点之一是能够远程检测操作系统,Nmap的OS检测技术在渗透测试中用来了解远程主机的操作系统是非常有用的,通过获取的信息你可以知道已知的漏洞

nmap -O 192.168.43.17

 ACK扫描:

利用ACK扫描判断端口是否被过滤。针对ACK探测包,为被过滤的端口(无论打开或关闭)会回复RST包

nmap -sA -T4 p1521,80 192.168.43.17

使用TCP ACK (PA)和TCP Syn (PS)扫描远程主机

nmap -pA -T4 p1521,80 192.168.43.17

nmap -pA -T4 p1521,80 192.168.43.17

扫描前不进行Ping扫描测试:

nmap -Pn  p1521,80 192.168.43.17

通过tcp空扫描以绕过防火墙检测:

nmap -sN 192.168.43.17

打印主机接口和路由

nmap --iflist

按顺序扫描端口:

nmap -r 192.168.43.118

扫描主机检测是否有防火墙过滤:

nmap -PN -p 1521 192.168.43.17

扫描操作系统信息和路由跟踪

使用Nmap,你可以检测远程主机上运行的操作系统和版本。为了启用操作系统和版本检测,脚本扫描和路由跟踪功能,我们可以使用NMAP的“-A“选项。

nmap -A 192.168.43.17

扫描端口时状态介绍:

Open  端口开启,数据有到达主机,有程序在端口上监控

Closed  端口关闭,数据有到达主机,没有程序在端口上监控

Filtered  数据没有到达主机,返回的结果为空,数据被防火墙或者是IDS过滤

UnFiltered  数据有到达主机,但是不能识别端口的当前状态

Open|Filtered  端口没有返回值,主要发生在UDP、IP、FIN、NULL和Xmas扫描中

Closed|Filtered   只发生在IP ID idle扫描

以上总结来源于网络。

centos 6.5下安装nmap工具及简单用法的更多相关文章

  1. CentOS 6.4 下安装vsftpd

    概述: vsftpd是Linux下比较著名的FTP服务器,搭建FTP服务器当然首选这个. 本文介绍了在CentOS 6.4下安装vsftpd.配置虚拟用户登录FTP的过程. 正文: 一:安装vsftp ...

  2. centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记

    centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记 目录[-] 过程 1.安装RVM 2.利用rvm安装 Ruby 1.9.3 并设为默认 3.安装rails 4.安装 ...

  3. CentOS 6系统下安装 JDK1.6

    CentOS 6系统下安装 JDK1.6 JDK(Java Development Kit)是Sun Microsystems针对Java开发员的产品.自从Java推出以来,JDK已经成为使用最广泛的 ...

  4. centos 6.5下安装、配置并启动SSH远程访问

    centos 6.5下安装.配置并启动SSH远程访问 1.登录centos 6.5系统,使用root用户登录,如果为非root用户则执行su或su - 或su root或su - root切换为roo ...

  5. Centos 7.0 下安装 Zabbix server 3.0服务器的安装及 监控主机的加入(1)

    一.本系列分为6部分 1.Centos 7.0 下安装 Zabbix server 3.0服务器的安装及 监控主机的加入 2.Centos 6.5 下安装 Zabbix server 3.0服务器的安 ...

  6. CentOS 6.3下 安装 Mono 3.2 和Jexus 5.4

    最新更新参看: Centos 7.0 安装Mono 3.4 和 Jexus 5.6 2012年初写过一篇<32和64位的CentOS 6.0下 安装 Mono 2.10.8 和Jexus 5.0 ...

  7. Linux下安装项目管理工具Redmine

    http://www.redmine.org.cn/download Linux下安装项目管理工具Redmine1.Ruby安装Ruby on Rails网站推荐使用1.8.7版. 点击(此处)折叠或 ...

  8. CentOS 5.5 下安装Countly Web Server过程记录

    CentOS 5.5 下安装Countly Web Server过程记录 1. 系统更新与中文语言包安装 2. 基本环境配置: 2.1. NodeJS安装 依赖项安装 yum -y install g ...

  9. CentOS 6.5 下安装 Redis 2.8.7(转)

    转自:http://www.cnblogs.com/haoxinyue/p/3620648.html CentOS 6.5 下安装 Redis 2.8.7 wget http://download.r ...

随机推荐

  1. tf.cast()的用法(转)

    一.函数 tf.cast() cast( x, dtype, name=None ) 将x的数据格式转化成dtype.例如,原来x的数据格式是bool, 那么将其转化成float以后,就能够将其转化成 ...

  2. Android开发之漫漫长途 XVII——动画

    该文章是一个系列文章,是本人在Android开发的漫漫长途上的一点感想和记录,我会尽量按照先易后难的顺序进行编写该系列.该系列引用了<Android开发艺术探索>以及<深入理解And ...

  3. Kafka实战-实时日志统计流程

    1.概述 在<Kafka实战-简单示例>一文中给大家介绍来Kafka的简单示例,演示了如何编写Kafka的代码去生产数据和消费数据,今天给大家介绍如何去整合一个完整的项目,本篇博客我打算为 ...

  4. android开发(3):列表listview的实现 | 下拉刷新

    APP里面的列表太常用了,系统提供的listview或grideview可以做到.另外,我希望这个列表能够下拉时触发刷新,于是考虑使用封装了这个功能的开源项目,这里介绍这个: https://gith ...

  5. Linux下搭建DNS缓存服务器

    CentOS 6.10搭建本地DNS缓存服务器系统环境 1 [root@test ~]# cat /etc/redhat-release 2 CentOS release 6.10 (Final) 3 ...

  6. 使用go语言编写IOS和Android程序

    go语言目前已可以用来开发android和ios手机app.相关资料: 1.IOS https://groups.google.com/forum/?utm_medium=email&utm_ ...

  7. js获取带#号链接后的参数

    现在许多的主流网站都将'#'大规模用于重要URL中,我们通过正则表达式和window.location.search获取参数已经行不通了. 一.'#'号是什么 1.#代表网页中的一个位置.其后面的字符 ...

  8. RMQ问题(Sparse-Table算法)

    范围最值问题(Range Minimum/maximum Query,RMQ).给出一个哪个元素的数组A1,A2,...An,要求设计一个数据结构,支持查询操作:计算min(AL,AL+1,...,A ...

  9. System V 与 POSIX 简介与对比

    当我们在 Linux 系统中进行进程间通信时,例如信号量,消息队列,共享内存等方式,会发现有System V以及POSIX两种类型.今天我们就来简单介绍下它们. POSIX: POSIX(Portab ...

  10. [转]Oracle密码过期, 报:ORA-01017: 用户名/口令无效; 登录被拒绝

    本文转自:https://blog.csdn.net/jeff06143132/article/details/25696371 连接Oracle,以Oracle用户登陆:   $su - oracl ...