namp命令详解

摘要:
我将用两个不同的部分来涵盖大部分NMAP的使用方法,这是nmap关键的第一部分。在下面的设置中,我使用两台已关闭防火墙的服务器来测试Nmap命令的工作情况。在发行版上安装Nmap具体使用如下命令。#yuminstallnmap[onRedHatbasedsystems]$sudoapt-getinstallnmap[onDebianbasedsystems]一旦你安装了最新的nmap应用程序,你就可以按照本文中提供的示例说明来操作。

我将用两个不同的部分来涵盖大部分NMAP的使用方法,这是nmap关键的第一部分。在下面的设置中,我使用两台已关闭防火墙的服务器来测试Nmap命令的工作情况。

  1. 192.168.0.100–server1.tecmint.com
  2. 192.168.0.101–server2.tecmint.com

NMAP命令用法

  1. #nmap[ScanType(s)][Options]{targetspecification}

如何在Linux下安装NMAP

现在大部分Linux的发行版本像Red Hat,CentOS,Fedoro,Debian和Ubuntu在其默认的软件包管理库(即YumAPT)中都自带了Nmap,这两种工具都用于安装和管理软件包和更新。在发行版上安装Nmap具体使用如下命令。

  1. #yuminstallnmap[onRedHatbasedsystems]
  2. $sudoapt-getinstallnmap[onDebianbasedsystems]

一旦你安装了最新的nmap应用程序,你就可以按照本文中提供的示例说明来操作。

1. 用主机名和IP地址扫描系统

Nmap工具提供各种方法来扫描系统。在这个例子中,我使用server2.tecmint.com主机名来扫描系统找出该系统上所有开放的端口,服务和MAC地址。

使用主机名扫描

  1. [root@server1~]#nmapserver2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1115:42EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.415seconds
  14. Youhavenewmailin/var/spool/mail/root

使用IP地址扫描

  1. [root@server1~]#nmap192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1811:04EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 958/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.465seconds
  14. Youhavenewmailin/var/spool/mail/root

2.扫描使用“-v”选项

你可以看到下面的命令使用“-v“选项后给出了远程机器更详细的信息。

  1. [root@server1~]#nmap-vserver2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1115:43EST
  3. InitiatingARPPingScanagainst192.168.0.101[1port]at15:43
  4. TheARPPingScantook0.01stoscan1totalhosts.
  5. InitiatingSYNStealthScanagainstserver2.tecmint.com(192.168.0.101)[1680ports]at15:43
  6. Discoveredopenport22/tcpon192.168.0.101
  7. Discoveredopenport80/tcpon192.168.0.101
  8. Discoveredopenport8888/tcpon192.168.0.101
  9. Discoveredopenport111/tcpon192.168.0.101
  10. Discoveredopenport3306/tcpon192.168.0.101
  11. Discoveredopenport957/tcpon192.168.0.101
  12. TheSYNStealthScantook0.30stoscan1680totalports.
  13. Hostserver2.tecmint.com(192.168.0.101)appearstobeup...good.
  14. Interestingportsonserver2.tecmint.com(192.168.0.101):
  15. Notshown:1674closedports
  16. PORTSTATESERVICE
  17. 22/tcpopenssh
  18. 80/tcpopenhttp
  19. 111/tcpopenrpcbind
  20. 957/tcpopenunknown
  21. 3306/tcpopenmysql
  22. 8888/tcpopensun-answerbook
  23. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  24. Nmapfinished:1IPaddress(1hostup)scannedin0.485seconds
  25. Rawpacketssent:1681(73.962KB)|Rcvd:1681(77.322KB)

3.扫描多台主机

你可以简单的在Nmap命令后加上多个IP地址或主机名来扫描多台主机。

  1. [root@server1~]#nmap192.168.0.101192.168.0.102192.168.0.103
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:06EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:3IPaddresses(1hostup)scannedin0.580seconds

4.扫描整个子网

你可以使用*通配符来扫描整个子网或某个范围的IP地址。

  1. [root@server1~]#nmap192.168.0.*
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:11EST
  3. Interestingportsonserver1.tecmint.com(192.168.0.100):
  4. Notshown:1677closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 111/tcpopenrpcbind
  8. 851/tcpopenunknown
  9. Interestingportsonserver2.tecmint.com(192.168.0.101):
  10. Notshown:1674closedports
  11. PORTSTATESERVICE
  12. 22/tcpopenssh
  13. 80/tcpopenhttp
  14. 111/tcpopenrpcbind
  15. 957/tcpopenunknown
  16. 3306/tcpopenmysql
  17. 8888/tcpopensun-answerbook
  18. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  19. Nmapfinished:256IPaddresses(2hostsup)scannedin5.550seconds
  20. Youhavenewmailin/var/spool/mail/root

从上面的输出可以看到,nmap扫描了整个子网,给出了网络中当前网络中在线主机的信息。

5.使用IP地址的最后一个字节扫描多台服务器

你可以简单的指定IP地址的最后一个字节来对多个IP地址进行扫描。例如,我在下面执行中扫描了IP地址192.168.0.101,192.168.0.102和192.168.0.103。

  1. [root@server1~]#nmap192.168.0.101,102,103
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:09EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:3IPaddresses(1hostup)scannedin0.552seconds
  14. Youhavenewmailin/var/spool/mail/root

6. 从一个文件中扫描主机列表

如果你有多台主机需要扫描且所有主机信息都写在一个文件中,那么你可以直接让nmap读取该文件来执行扫描,让我们来看看如何做到这一点。

创建一个名为“nmaptest.txt”的文本文件,并定义所有你想要扫描的服务器IP地址或主机名。

  1. [root@server1~]#cat>nmaptest.txt
  2. localhost
  3. server2.tecmint.com
  4. 192.168.0.101

接下来运行带“iL”选项的nmap命令来扫描文件中列出的所有IP地址。

  1. [root@server1~]#nmap-iLnmaptest.txt
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1810:58EST
  3. Interestingportsonlocalhost.localdomain(127.0.0.1):
  4. Notshown:1675closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 25/tcpopensmtp
  8. 111/tcpopenrpcbind
  9. 631/tcpopenipp
  10. 857/tcpopenunknown
  11. Interestingportsonserver2.tecmint.com(192.168.0.101):
  12. Notshown:1674closedports
  13. PORTSTATESERVICE
  14. 22/tcpopenssh
  15. 80/tcpopenhttp
  16. 111/tcpopenrpcbind
  17. 958/tcpopenunknown
  18. 3306/tcpopenmysql
  19. 8888/tcpopensun-answerbook
  20. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  21. Interestingportsonserver2.tecmint.com(192.168.0.101):
  22. Notshown:1674closedports
  23. PORTSTATESERVICE
  24. 22/tcpopenssh
  25. 80/tcpopenhttp
  26. 111/tcpopenrpcbind
  27. 958/tcpopenunknown
  28. 3306/tcpopenmysql
  29. 8888/tcpopensun-answerbook
  30. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  31. Nmapfinished:3IPaddresses(3hostsup)scannedin2.047seconds

7.扫描一个IP地址范围

你可以在nmap执行扫描时指定IP范围。

  1. [root@server1~]#nmap192.168.0.101-110
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:09EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:10IPaddresses(1hostup)scannedin0.542seconds

8.排除一些远程主机后再扫描

在执行全网扫描或用通配符扫描时你可以使用“-exclude”选项来排除某些你不想要扫描的主机。

  1. [root@server1~]#nmap192.168.0.*--exclude192.168.0.100
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:16EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:255IPaddresses(1hostup)scannedin5.313seconds
  14. Youhavenewmailin/var/spool/mail/root

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

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

  1. [root@server1~]#nmap-A192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:25EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICEVERSION
  6. 22/tcpopensshOpenSSH4.3(protocol2.0)
  7. 80/tcpopenhttpApachehttpd2.2.3((CentOS))
  8. 111/tcpopenrpcbind2(rpc#100000)
  9. 957/tcpopenstatus1(rpc#100024)
  10. 3306/tcpopenmysqlMySQL(unauthorized)
  11. 8888/tcpopenhttplighttpd1.4.32
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. NoexactOSmatchesforhost(IfyouknowwhatOSisrunningonit,seehttp://www.insecure.org/cgi-bin/nmap-submit.cgi).
  14. TCP/IPfingerprint:
  15. SInfo(V=4.11%P=i686-redhat-linux-gnu%D=11/11%Tm=52814B66%O=22%C=1%M=080027)
  16. TSeq(Class=TR%IPID=Z%TS=1000HZ)
  17. T1(Resp=Y%DF=Y%W=16A0%ACK=S++%Flags=AS%Ops=MNNTNW)
  18. T2(Resp=N)
  19. T3(Resp=Y%DF=Y%W=16A0%ACK=S++%Flags=AS%Ops=MNNTNW)
  20. T4(Resp=Y%DF=Y%W=0%ACK=O%Flags=R%Ops=)
  21. T5(Resp=Y%DF=Y%W=0%ACK=S++%Flags=AR%Ops=)
  22. T6(Resp=Y%DF=Y%W=0%ACK=O%Flags=R%Ops=)
  23. T7(Resp=Y%DF=Y%W=0%ACK=S++%Flags=AR%Ops=)
  24. PU(Resp=Y%DF=N%TOS=C0%IPLEN=164%RIPTL=148%RID=E%RIPCK=E%UCK=E%ULEN=134%DAT=E)
  25. Uptime0.169days(sinceMonNov1112:22:152013)
  26. Nmapfinished:1IPaddress(1hostup)scannedin22.271seconds

从上面的输出你可以看到,Nmap显示出了远程主机操作系统的TCP/IP协议指纹,并且更加具体的显示出远程主机上的端口和服务。

10.启用Nmap的操作系统探测功能

使用选项“-O”和“-osscan-guess”也帮助探测操作系统信息。

  1. [root@server1~]#nmap-Oserver2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:40EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. NoexactOSmatchesforhost(IfyouknowwhatOSisrunningonit,seehttp://www.insecure.org/cgi-bin/nmap-submit.cgi).
  14. TCP/IPfingerprint:
  15. SInfo(V=4.11%P=i686-redhat-linux-gnu%D=11/11%Tm=52815CF4%O=22%C=1%M=080027)
  16. TSeq(Class=TR%IPID=Z%TS=1000HZ)
  17. T1(Resp=Y%DF=Y%W=16A0%ACK=S++%Flags=AS%Ops=MNNTNW)
  18. T2(Resp=N)
  19. T3(Resp=Y%DF=Y%W=16A0%ACK=S++%Flags=AS%Ops=MNNTNW)
  20. T4(Resp=Y%DF=Y%W=0%ACK=O%Flags=Option-Oand-osscan-guessalsohelpstodiscoverOS
  21. R%Ops=)
  22. T5(Resp=Y%DF=Y%W=0%ACK=S++%Flags=AR%Ops=)
  23. T6(Resp=Y%DF=Y%W=0%ACK=O%Flags=R%Ops=)
  24. T7(Resp=Y%DF=Y%W=0%ACK=S++%Flags=AR%Ops=)
  25. PU(Resp=Y%DF=N%TOS=C0%IPLEN=164%RIPTL=148%RID=E%RIPCK=E%UCK=E%ULEN=134%DAT=E)
  26. Uptime0.221days(sinceMonNov1112:22:162013)
  27. Nmapfinished:1IPaddress(1hostup)scannedin11.064seconds
  28. Youhavenewmailin/var/spool/mail/root

11.扫描主机侦测防火墙

下面的命令将扫描远程主机以探测该主机是否使用了包过滤器或防火墙。

  1. [root@server1~]#nmap-sA192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:27EST
  3. All1680scannedportsonserver2.tecmint.com(192.168.0.101)areUNfiltered
  4. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  5. Nmapfinished:1IPaddress(1hostup)scannedin0.382seconds
  6. Youhavenewmailin/var/spool/mail/root

12.扫描主机检测是否有防火墙保护

扫描主机检测其是否受到数据包过滤软件或防火墙的保护。

  1. [root@server1~]#nmap-PN192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:30EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.399seconds

13.找出网络中的在线主机

使用“-sP”选项,我们可以简单的检测网络中有哪些在线主机,该选项会跳过端口扫描和其他一些检测。

  1. [root@server1~]#nmap-sP192.168.0.*
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1811:01EST
  3. Hostserver1.tecmint.com(192.168.0.100)appearstobeup.
  4. Hostserver2.tecmint.com(192.168.0.101)appearstobeup.
  5. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  6. Nmapfinished:256IPaddresses(2hostsup)scannedin5.109seconds

14.执行快速扫描

你可以使用“-F”选项执行一次快速扫描,仅扫描列在nmap-services文件中的端口而避开所有其它的端口。

  1. [root@server1~]#nmap-F192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:47EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1234closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 3306/tcpopenmysql
  10. 8888/tcpopensun-answerbook
  11. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  12. Nmapfinished:1IPaddress(1hostup)scannedin0.322seconds

15.查看Nmap的版本

你可以使用“-V”选项来检测你机子上Nmap的版本。

  1. [root@server1~]#nmap-V
  2. Nmapversion4.11(http://www.insecure.org/nmap/)
  3. Youhavenewmailin/var/spool/mail/root

16.顺序扫描端口

使用“-r”选项表示不会随机的选择端口扫描。

  1. [root@server1~]#nmap-r192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1116:52EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.363seconds

17.打印主机接口和路由

你可以使用nmap的“–iflist”选项检测主机接口和路由信息。

  1. [root@server1~]#nmap--iflist
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:07EST
  3. ************************INTERFACES************************
  4. DEV(SHORT)IP/MASKTYPEUPMAC
  5. lo(lo)127.0.0.1/8loopbackup
  6. eth0(eth0)192.168.0.100/24ethernetup08:00:27:11:C7:89
  7. **************************ROUTES**************************
  8. DST/MASKDEVGATEWAY
  9. 192.168.0.0/0eth0
  10. 169.254.0.0/0eth0

从上面的输出你可以看到,nmap列举出了你系统上的接口以及它们各自的路由信息。

18.扫描特定的端口

使用Nmap扫描远程机器的端口有各种选项,你可以使用“-P”选项指定你想要扫描的端口,默认情况下nmap只扫描TCP端口。

  1. [root@server1~]#nmap-p80server2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:12EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 80/tcpopenhttp
  6. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  7. Nmapfinished:1IPaddress(1hostup)sca

19.扫描TCP端口

你可以指定具体的端口类型和端口号来让nmap扫描。

  1. [root@server1~]#nmap-pT:8888,80server2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:15EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 80/tcpopenhttp
  6. 8888/tcpopensun-answerbook
  7. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  8. Nmapfinished:1IPaddress(1hostup)scannedin0.157seconds

20.扫描UDP端口

  1. [root@server1~]#nmap-sU53server2.tecmint.com
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:15EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 53/udpopenhttp
  6. 8888/udpopensun-answerbook
  7. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  8. Nmapfinished:1IPaddress(1hostup)scannedin0.157seconds

21.扫描多个端口

你还可以使用选项“-P”来扫描多个端口。

  1. [root@server1~]#nmap-p80,443192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1810:56EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 80/tcpopenhttp
  6. 443/tcpclosedhttps
  7. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  8. Nmapfinished:1IPaddress(1hostup)scannedin0.190seconds

22.扫描指定范围内的端口

您可以使用表达式来扫描某个范围内的端口。

  1. [root@server1~]#nmap-p80-160192.168.0.101

23.查找主机服务版本号

我们可以使用“-sV”选项找出远程主机上运行的服务版本。

  1. [root@server1~]#nmap-sV192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:48EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICEVERSION
  6. 22/tcpopensshOpenSSH4.3(protocol2.0)
  7. 80/tcpopenhttpApachehttpd2.2.3((CentOS))
  8. 111/tcpopenrpcbind2(rpc#100000)
  9. 957/tcpopenstatus1(rpc#100024)
  10. 3306/tcpopenmysqlMySQL(unauthorized)
  11. 8888/tcpopenhttplighttpd1.4.32
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin12.624seconds

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

有时候包过滤防火墙会阻断标准的ICMPping请求,在这种情况下,我们可以使用TCP ACK和TCP Syn方法来扫描远程主机。

  1. [root@server1~]#nmap-PS192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1117:51EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.360seconds
  14. Youhavenewmailin/var/spool/mail/root

25.使用TCP ACK扫描远程主机上特定的端口

  1. [root@server1~]#nmap-PA-p22,80192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1118:02EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 22/tcpopenssh
  6. 80/tcpopenhttp
  7. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  8. Nmapfinished:1IPaddress(1hostup)scannedin0.166seconds
  9. Youhavenewmailin/var/spool/mail/root

26.使用TCP Syn扫描远程主机上特定的端口

  1. [root@server1~]#nmap-PS-p22,80192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1118:08EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. PORTSTATESERVICE
  5. 22/tcpopenssh
  6. 80/tcpopenhttp
  7. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  8. Nmapfinished:1IPaddress(1hostup)scannedin0.165seconds
  9. Youhavenewmailin/var/spool/mail/root

27.执行一次隐蔽的扫描

  1. [root@server1~]#nmap-sS192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1118:10EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.383seconds
  14. Youhavenewmailin/var/spool/mail/root

28.使用TCP Syn扫描最常用的端口

  1. [root@server1~]#nmap-sT192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1118:12EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopenssh
  7. 80/tcpopenhttp
  8. 111/tcpopenrpcbind
  9. 957/tcpopenunknown
  10. 3306/tcpopenmysql
  11. 8888/tcpopensun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin0.406seconds
  14. Youhavenewmailin/var/spool/mail/root

29.执行TCP空扫描以骗过防火墙

  1. [root@server1~]#nmap-sN192.168.0.101
  2. StartingNmap4.11(http://www.insecure.org/nmap/)at2013-11-1119:01EST
  3. Interestingportsonserver2.tecmint.com(192.168.0.101):
  4. Notshown:1674closedports
  5. PORTSTATESERVICE
  6. 22/tcpopen|filteredssh
  7. 80/tcpopen|filteredhttp
  8. 111/tcpopen|filteredrpcbind
  9. 957/tcpopen|filteredunknown
  10. 3306/tcpopen|filteredmysql
  11. 8888/tcpopen|filteredsun-answerbook
  12. MACAddress:08:00:27:D9:8E:D7(CadmusComputerSystems)
  13. Nmapfinished:1IPaddress(1hostup)scannedin1.584seconds
  14. Youhavenewmailin/var/spool/mail/root

以上就是NMAP的基本使用,我会在第二部分带来NMAP更多的创意选项。至此,敬请关注我们,不要忘记分享您的宝贵意见。

免责声明:文章转载自《namp命令详解》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Spring Boot整合Mybatis配置详解java正则表达式(十)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

TCP连接的建立和关闭

TCP连接的建立 TCP使用三次握手( three-way handshake )协议来建立连接。三次握手协议可以完成两个重要功能:它确保连接双方做好传输准备,并使双方统一了初始顺序号。 这三次握手为: 1.请求端(通常称为客户)发送一个 SYN 报文段( SYN 为 1 )指明客户打算连接的服务器的端口,以及初始顺序号( ISN )。 2.服务器发回...

常用协议对应的端口--转载

>https://wenku.baidu.com/view/4f7ce022ccbff121dd3683e5.html DHCP 服务器的端口: 67 客户端的端口: 68 POP3: POP3仅仅是接收协议,POP3客户端使用SMTP向服务器发送邮件。POP3所用的端口号是110。 SMTP: 端口号是25。SMTP真正关心的不是邮件如何被传送,而...

PHY LINUX (转载整理)

每每分析网络问题的时候,总要梳理层次关系,本想自己写一个关于PHY的文档,找到网上有人写的一篇比较好,所以转载下来,仅供初学者参考。 原文地址:http://www.360doc.com/content/17/0724/12/8706683_673738481.shtml  以太网 MAC(链路层)+PHY(物理层/RTL8201F,88E1111);集成...

OSI结构和TCP/IP模型

   TCP/IP层次模型共分为五层:应用层HTTP、传输层TCP、网络层IP、数据链路层Data-link、物理层physical。     应用层—应用层是全部用户所面向的应用程序的统称。ICP/IP协议族在这一层面有着非常多协议来支持不同的应用。如我们进行万维网(WWW)訪问用到了HTTP协议、文件传输用FTP协议、电子邮件发送用SMTP、域名的解...

《精通并发与Netty》学习笔记(13

一、粘包/拆包概念 TCP是一个“流”协议,所谓流,就是没有界限的一长串二进制数据。TCP作为传输层协议并不不了解上层业务数据的具体含义,它会根据TCP缓冲区的实际情况进行数据包的划分,所以在业务上认为是一个完整的包,可能会被TCP拆分成多个包进行发送,也有可能把多个小的包封装成一个大的数据包发送,这就是所谓的TCP粘包和拆包问题。 一般所谓的TCP粘包是...

TCP/IP协议栈概述及各层包头分析

一、摘要  对之前几篇博文涉及到的网络通信协议进行分析,概述出TCP/IP的协议栈模型,最后根据实例对各层包头进行分析。   二、标准TCP/IP协议栈模型  标准TCP/IP协议是用于计算机通信的一组协议,通常被称为TCP/IP协议栈,以它为基础组建的互联网是目前国际上规模最大的计算机网络。正因为互联网的广泛应用,使得TCP/IP成为了事实上的网络标准。...