马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
功能实在太强了,在配合exec参数或者通过管道重定向到xargs命令和grep命令,可以完成非常复杂的操作,如果同样的操作用图形界面的工具来完成,恐怕要多花十几陪的时间。
Nmap即收集映照器对Linux体系/收集办理员来讲是一个开源且十分通用的工具。Nmap用于在远程呆板上探测收集,实行平安扫描,收集审计和征采开放端口。它会扫描远程在线主机,该主机的操纵体系,包过滤器和开放的端口。
我将用两个分歧的部分来涵盖年夜部分NMAP的利用办法,这是nmap关头的第一部分。鄙人面的设置中,我利用两台已封闭防火墙的服务器来测试Nmap命令的事情情形。
- 192.168.0.100–server1.tecmint.com
- 192.168.0.101–server2.tecmint.com
NMAP命令用法
- #nmap[ScanType(s)][Options]{targetspecification}
复制代码 怎样在Linux下安装NMAP
如今年夜部分Linux的刊行版本像RedHat,CentOS,Fedoro,Debian和Ubuntu在其默许的软件保证理库(即Yum和APT)中都自带了Nmap,这两种工具都用于安装和办理软件包和更新。在刊行版上安装Nmap详细利用以下命令。 - #yuminstallnmap[onRedHatbasedsystems]$sudoapt-getinstallnmap [onDebianbasedsystems]
复制代码 一旦你安装了最新的nmap使用程序,你就能够依照本文中供应的示例申明来操纵。
1.用主机名和IP地点扫描体系
Nmap工具供应各类办法来扫描体系。在这个例子中,我利用server2.tecmint.com主机名来扫描体系找出该体系上一切开放的端口,服务和MAC地点。
利用主机名扫描 - [root@server1~]#nmapserver2.tecmint.comStartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1115:42ESTInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind957/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:1IPaddress(1hostup)scannedin0.415secondsYouhavenewmailin/var/spool/mail/root
复制代码 利用IP地点扫描 - [root@server1~]#nmap192.168.0.101StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1811:04ESTInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind958/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:1IPaddress(1hostup)scannedin0.465secondsYouhavenewmailin/var/spool/mail/root
复制代码 2.扫描利用“-v”选项
你能够看到上面的命令利用“-v“选项后给出了远程呆板更具体的信息。 - [root@server1~]#nmap-vserver2.tecmint.comStartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1115:43ESTInitiatingARPPingScanagainst192.168.0.101[1port]at15:43TheARPPingScantook0.01stoscan1totalhosts.InitiatingSYNStealthScanagainstserver2.tecmint.com(192.168.0.101)[1680ports]at15:43Discoveredopenport22/tcpon192.168.0.101Discoveredopenport80/tcpon192.168.0.101Discoveredopenport8888/tcpon192.168.0.101Discoveredopenport111/tcpon192.168.0.101Discoveredopenport3306/tcpon192.168.0.101Discoveredopenport957/tcpon192.168.0.101TheSYNStealthScantook0.30stoscan1680totalports.Hostserver2.tecmint.com(192.168.0.101)appearstobeup...good.Interestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind957/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:1IPaddress(1hostup)scannedin0.485secondsRawpacketssent:1681(73.962KB)|Rcvd:1681(77.322KB)
复制代码 3.扫描多台主机
你能够复杂的在Nmap命令后加上多个IP地点或主机名来扫描多台主机。 - [root@server1~]#nmap192.168.0.101192.168.0.102192.168.0.103StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:06ESTInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind957/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:3IPaddresses(1hostup)scannedin0.580seconds
复制代码 4.扫描全部子网
你可使用*通配符来扫描全部子网或某个局限的IP地点。 - [root@server1~]#nmap192.168.0.*StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:11ESTInterestingportsonserver1.tecmint.com(192.168.0.100):Notshown:1677closedportsPORTSTATESERVICE22/tcpopenssh111/tcpopenrpcbind851/tcpopenunknownInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind957/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:256IPaddresses(2hostsup)scannedin5.550secondsYouhavenewmailin/var/spool/mail/root
复制代码 从下面的输入能够看到,nmap扫描了全部子网,给出了收集中以后收集中在线主机的信息。
5.利用IP地点的最初一个字节扫描多台服务器
你能够复杂的指定IP地点的最初一个字节来对多个IP地点举行扫描。比方,我鄙人面实行中扫描了IP地点192.168.0.101,192.168.0.102和192.168.0.103。 - [root@server1~]#nmap192.168.0.101,102,103StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:09ESTInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind957/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:3IPaddresses(1hostup)scannedin0.552secondsYouhavenewmailin/var/spool/mail/root
复制代码 6.从一个文件中扫描主机列表
假如你有多台主机必要扫描且一切主机信息都写在一个文件中,那末你能够间接让nmap读取该文件来实行扫描,让我们来看看怎样做到这一点。
创立一个名为“nmaptest.txt”的文本文件,并界说一切你想要扫描的服务器IP地点或主机名。 - [root@server1~]#cat>nmaptest.txtlocalhostserver2.tecmint.com192.168.0.101
复制代码 接上去运转带“iL”选项的nmap命令来扫描文件中列出的一切IP地点。 - [root@server1~]#nmap-iLnmaptest.txtStartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1810:58ESTInterestingportsonlocalhost.localdomain(127.0.0.1):Notshown:1675closedportsPORTSTATESERVICE22/tcpopenssh25/tcpopensmtp111/tcpopenrpcbind631/tcpopenipp857/tcpopenunknownInterestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind958/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Interestingportsonserver2.tecmint.com(192.168.0.101):Notshown:1674closedportsPORTSTATESERVICE22/tcpopenssh80/tcpopenhttp111/tcpopenrpcbind958/tcpopenunknown3306/tcpopenmysql8888/tcpopensun-answerbookMACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)Nmapfinished:3IPaddresses(3hostsup)scannedin2.047seconds
复制代码 上一页1234下一页不同版本的Linux命令数量不一样,这里笔者把它们中比较重要的和使用频率最多的命令。 |