如何在linux使用nmap端口扫描工具扫描网段内开放的端口

本文涉及的产品
简介:

linux一般不会自动安装nmap命令需要使用yum -y install nmap安装nmap命令,前提是您已经配置好了yum源。

nmap特点:

                  主机探测

                  端口扫描

                  版本检测

                  系统检测

                  支持探测脚本的编写

  1. nmap命令详解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nmap ip_address    #nmap默认发送一个arp的ping数据包,来探测目标主机1-10000范围内所有开放的端口
[root@controller scanport] # nmap 10.132.71.1  
 
Starting Nmap 6.40 ( http: //nmap .org ) at 2017-11-17 10:20 CST
Nmap scan report  for  10.132.71.1
Host is up (0.00030s latency).
Not shown: 987 closed ports
PORT     STATE SERVICE
21 /tcp    open   ftp
135 /tcp   open   msrpc
139 /tcp   open   netbios-ssn
1027 /tcp  open   IIS
1028 /tcp  open   unknown
1029 /tcp  open   ms-lsa
1031 /tcp  open   iad2
2638 /tcp  open   sybase
3389 /tcp  open   ms-wbt-server
6059 /tcp  open   X11:59
7001 /tcp  open   afs3-callback
8001 /tcp  open   vcom-tunnel
8089 /tcp  open   unknown
MAC Address: 5C:F3:FC:E4:81:40 (IBM)
 
Nmap  done : 1 IP address (1 host up) scanned  in  1.27 seconds
[root@controller scanport] #

-vv 参数表示结果详细输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[root@controller scanport] # nmap -vv 10.132.71.1 
 
Starting Nmap 6.40 ( http: //nmap .org ) at 2017-11-17 10:21 CST
Initiating ARP Ping Scan at 10:21
Scanning 10.132.71.1 [1 port]
Completed ARP Ping Scan at 10:21, 0.02s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 10:21
Completed Parallel DNS resolution of 1 host. at 10:21, 0.00s elapsed
Initiating SYN Stealth Scan at 10:21
Scanning 10.132.71.1 [1000 ports]
Discovered  open  port 21 /tcp  on 10.132.71.1
Discovered  open  port 139 /tcp  on 10.132.71.1
Discovered  open  port 3389 /tcp  on 10.132.71.1
Discovered  open  port 135 /tcp  on 10.132.71.1
Discovered  open  port 1029 /tcp  on 10.132.71.1
Discovered  open  port 1028 /tcp  on 10.132.71.1
Discovered  open  port 1031 /tcp  on 10.132.71.1
Discovered  open  port 8001 /tcp  on 10.132.71.1
Discovered  open  port 1027 /tcp  on 10.132.71.1
Discovered  open  port 7001 /tcp  on 10.132.71.1
Discovered  open  port 8089 /tcp  on 10.132.71.1
Discovered  open  port 6059 /tcp  on 10.132.71.1
Discovered  open  port 2638 /tcp  on 10.132.71.1
Completed SYN Stealth Scan at 10:21, 1.15s elapsed (1000 total ports)
Nmap scan report  for  10.132.71.1
Host is up (0.00029s latency).
Scanned at 2017-11-17 10:21:43 CST  for  2s
Not shown: 987 closed ports
PORT     STATE SERVICE
21 /tcp    open   ftp
135 /tcp   open   msrpc
139 /tcp   open   netbios-ssn
1027 /tcp  open   IIS
1028 /tcp  open   unknown
1029 /tcp  open   ms-lsa
1031 /tcp  open   iad2
2638 /tcp  open   sybase
3389 /tcp  open   ms-wbt-server
6059 /tcp  open   X11:59
7001 /tcp  open   afs3-callback
8001 /tcp  open   vcom-tunnel
8089 /tcp  open   unknown
MAC Address: 5C:F3:FC:E4:81:40 (IBM)
 
Read data files from:  /usr/bin/ .. /share/nmap
Nmap  done : 1 IP address (1 host up) scanned  in  1.26 seconds
            Raw packets sent: 1082 (47.592KB) | Rcvd: 1001 (40.080KB)
[root@controller scanport] #

-p自定义扫描的端口

例如:扫描1-200号端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@controller scanport] # nmap -p1-200 10.128.71.1 
 
Starting Nmap 6.40 ( http: //nmap .org ) at 2017-11-17 10:26 CST
Nmap scan report  for  10.128.71.1
Host is up (0.00030s latency).
Not shown: 197 closed ports
PORT    STATE SERVICE
21 /tcp   open   ftp
135 /tcp  open   msrpc
139 /tcp  open   netbios-ssn
MAC Address: 5C:F3:FC:E4:81:40 (IBM)
 
Nmap  done : 1 IP address (1 host up) scanned  in  0.15 seconds
[root@controller scanport] #

例如:指定特定端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@controller scanport] # nmap -p135,136,137,139 10.128.71.1 
 
Starting Nmap 6.40 ( http: //nmap .org ) at 2017-11-17 10:28 CST
Nmap scan report  for  10.128.71.1
Host is up (0.0045s latency).
PORT    STATE  SERVICE
135 /tcp  open    msrpc
136 /tcp  closed profile
137 /tcp  closed netbios-ns
139 /tcp  open    netbios-ssn
MAC Address: 5C:F3:FC:E4:81:40 (IBM)
 
Nmap  done : 1 IP address (1 host up) scanned  in  0.14 seconds
[root@controller scanport] #

-sP指定扫描方式为ping(不扫描端口)

nmap -sP   ip_address  #使用ping方式扫描(不扫描端口)

nmap --traceroute  ip_address  #路由跟踪

nmap -sP xx.xx.xx.xx/24 #扫描一个网段(使用ping)

nmap -sP 10.1.1.1-255  #也可以扫描一个网段(使用ping)

nmap -sT  ip_address  #TCP contect()端口扫描

nmap -sU ip_address  #UDP端口扫描

nmap -sS ip_address  #TCP同步(SYN)端口扫描

nmap 10.1.1.1/24  #扫描一个网段使用默认端口扫描,结果同下面脚本

1
2
3
4
5
#!/bin/bash
for  in  {1..254}
   do
    nmap 10.128.71.$i >>scan.port
   done

nmap探测操作系统类型

nmap -O ip_address  #扫描操作系统类型

nmap -A ip_address  #使用默认扫描,ping扫描,操作系统扫描,脚本扫描,路由跟踪,服务探测等

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
[root@controller scanport] # nmap -A 10.128.71.1
 
Starting Nmap 6.40 ( http: //nmap .org ) at 2017-11-17 10:46 CST
Nmap scan report  for  10.128.71.1
Host is up (0.00028s latency).
Not shown: 987 closed ports
PORT     STATE SERVICE       VERSION
21 /tcp    open   ftp            Microsoft ftpd
ftp -anon: Anonymous FTP login allowed (FTP code 230)
| 07-21-12  03:03AM       <DIR>          aspnet_client
| 11-17-17  07:35AM       <DIR>          download
|_12-13-12  10:31AM               105984 \xD2\xBD\xB1\xA3\xB2\xBF\xC3\xC5\xC8\xCB\xD4\xB1.xls
135 /tcp   open   msrpc         Microsoft Windows RPC
139 /tcp   open   netbios-ssn
1027 /tcp  open   msrpc         Microsoft Windows RPC
1028 /tcp  open   msrpc         Microsoft Windows RPC
1029 /tcp  open   msrpc         Microsoft Windows RPC
1031 /tcp  open   tcpwrapped
2638 /tcp  open   sybase?
3389 /tcp  open   ms-wbt-server Microsoft Terminal Service
6059 /tcp  open   tcpwrapped
7001 /tcp  open   http          Oracle WebLogic Server (Servlet 2.5; JSP 2.1)
|_http-generator: WebLogic Server
|_http-methods: No Allow or Public header  in  OPTIONS response (status code 404)
|_http-title: Error 404--Not Found
8001 /tcp  open   http          Oracle WebLogic Server (Servlet 2.5; JSP 2.1)
|_http-generator: WebLogic Server
|_http-methods: No Allow or Public header  in  OPTIONS response (status code 404)
|_http-title: Error 404--Not Found
8089 /tcp  open   http          Microsoft IIS httpd 6.0
| http-methods: Potentially risky methods: TRACE DELETE COPY MOVE PROPFIND PROPPATCH SEARCH MKCOL LOCK UNLOCK PUT
|_See http: //nmap .org /nsedoc/scripts/http-methods .html
|_http-title: 10.128.71.1 - /
MAC Address: 5C:F3:FC:E4:81:40 (IBM)
Device  type : general purpose
Running: Microsoft Windows XP
OS CPE: cpe: /o :microsoft:windows_xp::sp2
OS details: Microsoft Windows XP SP2
Network Distance: 1 hop
Service Info: OS: Windows; CPE: cpe: /o :microsoft:windows
 
Host script results:
|_nbstat: NetBIOS name: LD, NetBIOS user: <unknown>, NetBIOS MAC: 5c:f3:fc:e4:81:40 (IBM)
| smb-os-discovery: 
|   OS: Windows Server 2003 3790 Service Pack 2 (Windows Server 2003 5.2)
|   OS CPE: cpe: /o :microsoft:windows_server_2003::sp2
|   Computer name: LD
|   NetBIOS computer name: LD
|   Workgroup: WORKGROUP
|_  System  time : 2017-11-17T10:50:02+08:00
| smb-security-mode: 
|   Account that was used  for  smb scripts: <blank>
|   User-level authentication
|   SMB Security: Challenge /response  passwords supported
|_  Message signing disabled (dangerous, but default)
|_smbv2-enabled: Server doesn't support SMBv2 protocol
 
TRACEROUTE
HOP RTT     ADDRESS
1   0.28 ms 10.128.71.1
 
OS and Service detection performed. Please report any incorrect results at http: //nmap .org /submit/  .
Nmap  done : 1 IP address (1 host up) scanned  in  89.36 seconds
[root@controller scanport] #


















本文转自lq201151CTO博客,原文链接:http://blog.51cto.com/liuqun/1982726 ,如需转载请自行联系原作者




相关实践学习
基于函数计算一键部署掌上游戏机
本场景介绍如何使用阿里云计算服务命令快速搭建一个掌上游戏机。
建立 Serverless 思维
本课程包括: Serverless 应用引擎的概念, 为开发者带来的实际价值, 以及让您了解常见的 Serverless 架构模式
相关文章
|
14天前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
29 0
|
22天前
|
存储 前端开发 Linux
Linux系统之部署ToDoList任务管理工具
【4月更文挑战第1天】Linux系统之部署ToDoList任务管理工具
63 1
|
23天前
|
存储 传感器 运维
linux系统资源统计工具
【4月更文挑战第1天】Linux系统监控工具如dstat、htop、glances、vmstat、top、iostat、mpstat、sar和atop,用于跟踪CPU、内存、磁盘I/O、网络和进程性能。这些工具提供实时、交互式和历史数据分析,助力管理员优化系统性能和故障排查。例如,dstat是vmstat等工具的增强版,htop提供彩色界面的进程管理,而atop则结合了多种功能并记录历史数据。
28 5
linux系统资源统计工具
|
14天前
|
Linux
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
21 0
|
19小时前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
13 2
|
21小时前
|
编解码 Linux 数据安全/隐私保护
linux工具之curl与wget高级使用
linux工具之curl与wget高级使用
|
12天前
|
Linux Windows
Windows、Mac、Linux解决端口被占用的问题
Windows、Mac、Linux解决端口被占用的问题
21 1
|
14天前
|
网络协议 Linux
Linux如何查询端口被占用?
在Linux环境中,查询端口占用可使用`netstat`、`lsof`和`ss`命令。`netstat -tulnp | grep 80`显示TCP/UDP监听端口,`lsof -i:80`列出使用80端口的进程,而`ss -tuln | grep 80`是`netstat`的现代替代选项。若需解决端口占用问题,先找出占用进程的ID,然后用`kill -9`命令终止它,或调整服务配置以避免冲突。
21 1
|
20天前
|
资源调度 JavaScript 安全
Linux系统之部署web-check网站分析工具
【4月更文挑战第3天】Linux系统之部署web-check网站分析工具
65 9
|
21天前
|
运维 监控 Linux
不是所有的Linux工具都会让人惊叹,但这个绝对让你叫绝
【4月更文挑战第3天】不是所有的Linux工具都会让人惊叹,但这个绝对让你叫绝
31 0
不是所有的Linux工具都会让人惊叹,但这个绝对让你叫绝