nmap用法

1、安装

  1. bzip2 -cd nmap-6.49BETA6.tar.bz2 | tar xvf -  
  2. cd nmap-6.49BETA6  
  3. ./configure  
  4. make  
  5. su root  
  6. make install  
2、使用
  1. nmap 目标主机
  1. nmap 192.168.2.7  
  2.   
  3. Starting Nmap 6.49BETA6 ( https://nmap.org ) at 2015-10-28 23:30 CST  
  4. Warning: File ./nmap-services exists, but Nmap is using /usr/local/bin/../share/nmap/nmap-services for security and consistency reasons.  set NMAPDIR=. to give priority to files in your local directory (may affect the other data files too).  
  5. Nmap scan report for 192.168.2.7  
  6. Host is up (0.32s latency).  
  7. Not shown: 996 closed ports  
  8. PORT     STATE SERVICE  
  9. 21/tcp   open  ftp  
  10. 22/tcp   open  ssh  
  11. 53/tcp   open  domain  
  12. 1723/tcp open  pptp  
  13. MAC Address: C8:3A:35:C7:72:F1 (Tenda Technology)  
  14.   
  15. Nmap done: 1 IP address (1 host up) scanned in 3.97 seconds  
目标主机192.168.2.7 处于 up 状态,开放了21,22,53,1723端口,最后给出了网卡信息

2)nmap -T4 -A -v 目标主机

-T4是指定扫描过程中使用的时序模板,总共有6个等级,等级越高,扫描速度越快,但也容易被防火墙或者入侵检测设备发现

  1. nmap -T4 -A -v 192.168.2.7  
  2.   
  3. Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-28 21:48 CST  
  4. NSE: Loaded 57 scripts for scanning.  
  5. Initiating ARP Ping Scan at 21:48  
  6. Scanning 192.168.2.7 [1 port]  
  7. Completed ARP Ping Scan at 21:48, 0.11s elapsed (1 total hosts)  
  8. Initiating Parallel DNS resolution of 1 host. at 21:48  
  9. Completed Parallel DNS resolution of 1 host. at 21:48, 0.00s elapsed  
  10. Initiating SYN Stealth Scan at 21:48  
  11. Scanning 192.168.2.7 [1000 ports]  
  12. Discovered open port 22/tcp on 192.168.2.7  
  13. Discovered open port 1723/tcp on 192.168.2.7  
  14. Discovered open port 53/tcp on 192.168.2.7  
  15. Discovered open port 21/tcp on 192.168.2.7  
  16. Completed SYN Stealth Scan at 21:48, 3.12s elapsed (1000 total ports)  
  17. Initiating Service scan at 21:48  
  18. Scanning 4 services on 192.168.2.7  
  19. Completed Service scan at 21:48, 6.64s elapsed (4 services on 1 host)  
  20. Initiating OS detection (try #1) against 192.168.2.7  
  21. Retrying OS detection (try #2) against 192.168.2.7  
  22. Retrying OS detection (try #3) against 192.168.2.7  
  23. Retrying OS detection (try #4) against 192.168.2.7  
  24. Retrying OS detection (try #5) against 192.168.2.7  
  25. NSE: Script scanning 192.168.2.7.  
  26. Initiating NSE at 21:49  
  27. Completed NSE at 21:49, 3.75s elapsed  
  28. Nmap scan report for 192.168.2.7  
  29. #对主机是否在线进行扫描  
  30. Host is up (0.017s latency).  
  31. #端口扫描以及应用程序  
  32. Not shown: 996 closed ports  
  33. PORT     STATE SERVICE VERSION  
  34. 21/tcp   open  ftp     vsftpd 2.3.5  
  35. 22/tcp   open  ssh     OpenSSH 6.0p1 Debian 4+deb7u2 (protocol 2.0)  
  36. | ssh-hostkey: 1024 8e:f3:3c:eb:07:3b:96:91:ff:29:22:cb:97:91:38:fd (DSA)  
  37. |_2048 e0:f8:5e:3e:a0:c1:28:bc:8d:81:3e:79:cf:b9:90:d3 (RSA)  
  38. 53/tcp   open  domain  dnsmasq 2.62  
  39. 1723/tcp open  pptp    linux (Firmware: 1)  
  40. MAC Address: C8:3A:35:C7:72:F1 (Tenda Technology Co.)  
  41. #操作系统版本,没扫出来,哈哈  
  42. No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).  
  43. TCP/IP fingerprint:  
  44. OS:SCAN(V=5.51%D=10/28%OT=21%CT=1%CU=35731%PV=Y%DS=1%DC=D%G=Y%M=C83A35%TM=5  
  45. OS:630D25B%P=x86_64-redhat-linux-gnu)SEQ(SP=107%GCD=2%ISR=10D%TI=Z%CI=I%II=  
  46. OS:I%TS=7)SEQ(SP=107%GCD=1%ISR=10D%TI=Z%CI=I%II=I%TS=7)SEQ(SP=107%GCD=1%ISR  
  47. OS:=10D%TI=Z%CI=I%II=I%TS=5)OPS(O1=M5B4ST11NW7%O2=M5B4ST11NW7%O3=M5B4NNT11N  
  48. OS:W7%O4=M5B4ST11NW7%O5=M5B4ST11NW7%O6=M5B4ST11)WIN(W1=7120%W2=7120%W3=7120  
  49. OS:%W4=7120%W5=7120%W6=7120)ECN(R=Y%DF=Y%T=40%W=7210%O=M5B4NNSNW7%CC=Y%Q=)T  
  50. OS:1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0  
  51. OS:%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6  
  52. OS:(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%  
  53. OS:F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=  
  54. OS:G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)  
  55.   
  56. Uptime guess: 53.983 days (since Fri Sep  4 22:13:33 2015)  
  57. Network Distance: 1 hop  
  58. TCP Sequence Prediction: Difficulty=263 (Good luck!)  
  59. IP ID Sequence Generation: All zeros  
  60. Service Info: Host: local; OSs: Unix, Linux  
  61.   
  62. TRACEROUTE  
  63. HOP RTT      ADDRESS  
  64. 1   17.09 ms 192.168.2.7  
  65.   
  66. Read data files from: /usr/share/nmap  
  67. OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .  
  68. Nmap done: 1 IP address (1 host up) scanned in 26.07 seconds  
  69.            Raw packets sent: 1147 (54.550KB) | Rcvd: 1091 (47.158KB)  

3)nmap 常用参数

  1. -sn : 只进行主机发现扫描,不进行端口扫描  
  2. -Pn : 跳过主机发现扫描,将所有指定的主机都视为在线状态,进行端口扫描  
  3. -sL : 仅仅列出指定的目标主机 IP,不进行主机发现扫描  
  4. -PS/PA/PU/PU[portlist] : 指定使用 TCP SYN/TCP ACK/ UDP/SCTP方式进行主机发现,例如 nmap -PS80,2  
  5. -PE/PP/PM : 指定 nmap 使用 ICMP echo、timestamp、network 请求报文方式发现主机  
  6. -PO : 使用 IP 协议包探测目标主机是否在线  
  7. -n/-R : 指定是否使用 dns 解析,其中,-n 表示不进行 dns 解析,-R 表示总进行 dns 解析  
例如
  1. nmap -sn -PE -PS22,80 -PU53 192.168.2.7  
  2.   
  3. Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-28 22:00 CST  
  4. Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn  
  5. Nmap done: 1 IP address (0 hosts up) scanned in 0.43 seconds  

4)nmap 端口扫描

nmap 扫描端口状态分为6类

  1. open : 表示端口是开放的  
  2. closed : 表示端口是关闭的  
  3. filtered : 表示端口被防火墙屏蔽,无法进一步确认状态  
  4. unfiltered : 表示端口没有被屏蔽,但是否处于开放状态,还需要进一步确定  
  5. open|filtered : 表示不确定状态,端口可能开放可能关闭  
  6. closed|filtered : 表示不确定状态,端口可能关闭,可能屏蔽  
端口扫描的用法
  1. -sS/sT/sA/sW/sM : 指定使用 TCP SYN/Connect()/ACK/Window/Maimon scans 来对目标主机进行端口扫描  
  2. -sU : 指定使用 UDP 扫描方式扫描目标主机的 UDP 端口状况  
  3. -sN/sF/sX : 指定使用 TCP Null/FIN/Xmas sans 秘密扫描方式来协助侦测目标主机的 TCP 端口状态  
  4. -p <port rangs> : 仅仅扫描指定的一个或一批端口。例如 -p80/-p1-100/-p T:80-88,8000,U:53,111,S:9,其中 T 表示 TCP 协议,U 表示 UDP 协议,S 表示 SCTP 协议  
  5. -F : 快速扫描模式,仅仅扫描开放率高的100个端口  
  6. --top-ports <number> : 仅扫描开放率高的 number 个端口  
例子
  1. nmap -sU -sS -F 192.168.2.7  
  2.   
  3. Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-28 22:04 CST  
  4. Nmap scan report for 192.168.2.7  
  5. Host is up (0.019s latency).  
  6. Not shown: 194 closed ports  
  7. PORT     STATE         SERVICE  
  8. 21/tcp   open          ftp  
  9. 22/tcp   open          ssh  
  10. 53/tcp   open          domain  
  11. 1723/tcp open          pptp  
  12. 53/udp   open|filtered domain  
  13. 68/udp   open|filtered dhcpc  
  14. MAC Address: C8:3A:35:C7:72:F1 (Tenda Technology Co.)  
  15.   
  16. Nmap done: 1 IP address (1 host up) scanned in 107.10 seconds  

5)nmap 程序版本侦测

nmap 选项或参数 目标主机

  1. -sV : 设置 nmap 进行版本侦测  
  2. --version-intensity <level> 设置版本侦测的强度值,0-9,默认是7。这个数值越高,探测出的版本越精确,但扫描时间也更长  
  3. --version-light : 设置使用轻量级的侦测方式,相当于侦测强度为2  
  4. --version-trace : 显示版本侦测的详细过程  
例子
  1. nmap -sV 192.168.2.7  
  2.   
  3. Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-28 22:13 CST  
  4. Nmap scan report for 192.168.2.7  
  5. Host is up (0.073s latency).  
  6. Not shown: 996 closed ports  
  7. PORT     STATE SERVICE VERSION  
  8. 21/tcp   open  ftp     vsftpd 2.3.5  
  9. 22/tcp   open  ssh     OpenSSH 6.0p1 Debian 4+deb7u2 (protocol 2.0)  
  10. 53/tcp   open  domain  dnsmasq 2.62  
  11. 1723/tcp open  pptp    linux (Firmware: 1)  
  12. MAC Address: C8:3A:35:C7:72:F1 (Tenda Technology Co.)  
  13. Service Info: Host: local; OSs: Unix, Linux  
  14.   
  15. Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .  
  16. Nmap done: 1 IP address (1 host up) scanned in 13.26 seconds  

6)nmap 操作系统的侦测

nmap 选项或参数

  1. -O : 设置 nmap 进行操作系统侦测  
  2. --osscan-guess : 猜测目标主机的操作系统类型,nmmap 会给出可能性的比率,用户可以根据提供的比率综合判断操作系统类型  
例子
  1. nmap -O --osscan-guess 192.168.2.7  
  2.   
  3. Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-28 22:18 CST  
  4. Nmap scan report for 192.168.2.7  
  5. Host is up (0.0029s latency).  
  6. Not shown: 996 closed ports  
  7. PORT     STATE SERVICE  
  8. 21/tcp   open  ftp  
  9. 22/tcp   open  ssh  
  10. 53/tcp   open  domain  
  11. 1723/tcp open  pptp  
  12. MAC Address: C8:3A:35:C7:72:F1 (Tenda Technology Co.)  
  13. Device type: WAP|general purpose|specialized|firewall|webcam  
  14. Running (JUST GUESSING): Netgear embedded (96%), Linux 2.6.X|2.4.X (93%), Crestron 2-Series (91%), Citrix Linux 2.6.X (90%), Check Point embedded (90%), Check Point Linux 2.4.X (90%), Linksys embedded (90%), AXIS Linux 2.6.X (89%)  
  15. Aggressive OS guesses: Netgear DG834G WAP (96%), Linux 2.6.32 (93%), Crestron XPanel control system (91%), Linux 2.6.19 - 2.6.35 (91%), Linux 2.4.26 (Slackware 10.0.0) (91%), Linux 2.6.31 - 2.6.34 (91%), Citrix XenServer (Linux 2.6.18) (90%), Linux 2.6.24 (90%), Check Point SBox-200 firewall (90%), Check Point VPN-1 UTM appliance (90%)  
  16. No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).  
  17. TCP/IP fingerprint:  
  18. OS:SCAN(V=5.51%D=10/28%OT=21%CT=1%CU=42150%PV=Y%DS=1%DC=D%G=Y%M=C83A35%TM=5  
  19. OS:630D948%P=x86_64-redhat-linux-gnu)SEQ(SP=FF%GCD=1%ISR=106%TI=Z%CI=I%II=I  
  20. OS:%TS=7)SEQ(SP=FF%GCD=1%ISR=106%TI=Z%CI=I%II=I%TS=6)OPS(O1=M5B4ST11NW7%O2=  
  21. OS:M5B4ST11NW7%O3=M5B4NNT11NW7%O4=M5B4ST11NW7%O5=M5B4ST11NW7%O6=M5B4ST11)WI  
  22. OS:N(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=7120)ECN(R=Y%DF=Y%T=40%W=72  
  23. OS:10%O=M5B4NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3  
  24. OS:(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=  
  25. OS:Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=  
  26. OS:Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%R  
  27. OS:IPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)  
  28.   
  29. Network Distance: 1 hop  
  30.   
  31. OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .  
  32. Nmap done: 1 IP address (1 host up) scanned in 14.07 seconds  

进行ping扫描,打印出对扫描做出响应的主机:

  1. nmap -sP 192.168.1.0/24    

仅列出指定网络上的每台主机,不发送任何报文到目标主机:

  1. nmap -sL 192.168.1.0/24  

转载自:http://liuhonghe.me/nmap-config.html


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值