|
简介
NMap,也就是Network Mapper,是Linux下的网络扫描和嗅探工具包。文中均已Linux下Nmap5.21为主,其他版本类似。
功能包括:
一是探测一组主机是否在线;
二是扫描 主机端口,嗅探所提供的网络服务;
三是推断主机所用的操作系统 [separator]
2.参数说明
1. 格式:nmap [Scan Type(s)] [Options]{target specification}
(1)-sL:我们可以称之为蛮力扫描,它将目标ip一个一个扫描过去,等待回应,不推荐
(2)-sP:采用ping模式扫描网段,arp获取MAC地址,效果不大理想
(3)-PS:探测指定目标开放的端口,在目标开防火墙情况效果不好
(4)-sS:SYN扫描,即半开放扫描,不是一个完全的TCP链接,执行效率高,隐蔽性较好。
(5)-sU:指定目标UDP端口开放情况
(6)-O/-A:探测服务器操作系统类型
3.操作应用
(1)查看该网段存在的主机,参数-sP (Linux区分大小写,这里P大写)
1. sudo nmap -sP 192.168.8.0/24
说明:192.168.8.0是一个网段,24是子网页码位数,c类,返回结果如下:
1. Nmap scan report for bogon(192.168.8.1)
2. Host is up (0.0036s latency).
3. MAC Address: 00:1F:33:BA:9A:EE(Netgear) # 网关
4. Nmap scan report for bogon(192.168.8.3)
5. Host is up (0.0069s latency).
6. MAC Address: 78:E4:00:27:3D:38(Unknown) # 未知,一台装win7
7. Nmap scan report for bogon(192.168.8.6)
8. Host is up (0.0089s latency).
9. MAC Address: 00:0D:56:FB:13:12 (Dell PcbaTest) # dell主机,win2k3服务器
10. Nmap scan report for xiaoc-Studio-1458(192.168.8.8)
11. Host is up.
12. Nmap scan report for bogon (192.168.8.9)
13. Host is up (0.032s latency).
14. MAC Address: B4:82:FE:BC:55:DE(Unknown) # 未知,一台装winxp
15. Nmap scan report for bogon (192.168.8.10)
16. Host is up (0.077s latency).
17. MAC Address: 00:0D:56:FA:E9:C0 (Dell Pcba Test) #dell主机,我用ubuntu搭建的
18. Nmap done: 256 IP addresses (6 hosts up) scanned in5.13 seconds
总共开放了6台主机。
(2)查看自身打开端口
1. sudo nmap -sTU localhost
返回结果如下:
1. rDNS record for 127.0.0.1:localhost.localdomain
2. Not shown: 1989 closed ports
3.PORT STATE SERVICE
4. 22/tcp open ssh # ssh远程管理
5. 80/tcp open http # nginx的web服务
6. 139/tcp open netbios-ssn # 局域网共享
7. 445/tcp open microsoft-ds # 与window共享
8. 631/tcp open ipp
9. 3306/tcpopen mysql # mysql服务
10. 9000/tcpopen cslistener # fcgi服务
11. 68/udp open|filtereddhcpc
12. 137/udp open netbios-ns
13. 138/udp open|filtered netbios-dgm
14. 5353/udp open|filtered zeroconf
本机开放端口列表与对应服务列表
(3) 探测指定目标开放端口
1. sudo nmap -PS 192.168.8.10
返回结果:
1. Host is up (0.0012s latency).
2. Not shown: 996 closed ports
3. PORT STATE SERVICE
4. 22/tcp open ssh
5. 80/tcp open http
6. 139/tcp open netbios-ssn
7. 445/tcp open microsoft-ds
8. MAC Address: 00:0D:56:FA:E9:C0 (Dell PcbaTest)
当对方开了window自带的防火墙扫描到端口就不准确了,或者说都是没用端口
(4)探测服务器操作系统类型
1. sudo nmap -O 192.168.8.6
2. sudo nmap -A 192.168.8.6
返回结果:
1. OS details: Microsoft Windows Server2003 SP1 or SP2
探测Linux主机,返回了内核版本号,返回结果如下:
1. OS details: Linux 2.6.17 - 2.6.31
对于window xp也返回如下:
1. Running: Microsoft Windows XP
2. OS details: Microsoft Windows XP SP2
3. Network Distance: 1 hop
4. Service Info: OS: Windows
5.
6. Host script results:
7. |_nbstat: NetBIOS name: CODEHACK, NetBIOSuser: <unknown>, NetBIOS MAC: b4:82:fe:bc:55:de
8. | smb-os-discovery:
9. | OS: Windows XP(Windows 2000 LAN Manager)
10. | Name: WORKGROUPCODEHACK
11. |_ System time: 2010-10-19 15:56:08UTC+8
12. |_smbv2-enabled: Server doesn’t support SMBv2protocol
但是有一个不好缺点,目标开启防火墙,又可能造成无法探测。 |
|