前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >centos 中nmap的用法

centos 中nmap的用法

作者头像
知识浅谈
发布2020-03-24 16:44:21
6120
发布2020-03-24 16:44:21
举报
文章被收录于专栏:分享学习分享学习

nmap <扫描类型> <扫描参数>ip地址范围 扫描类型:主要有以下几种.

-sT:扫描TCP数据包以建立的连接connect() -sS:扫描TCP数据包带有SYN数据的标记 -sP:以ping方式进行扫描 -sU:以UDP数据包格式进行扫描 -sO:以IP协议进行主机扫描

扫描参数:主要有以下几种.

-PT:使用TCP的ping方式进行扫描,可以获取当前已经启动几台计算机 -PI:使用实际的ping(带有ICMP数据包)进行扫描 -p:这个是端口范围,如:1024~,80~1023,30000~60000

IP地址与范围:有以下几种类型:

192.168.0.100:直接写入IP,仅检查一台主机 192.168.0.0/24:为C Class的网段 192.168..:以B Class的网段,扫描范围更广 192.168.0.0~50,60~100,103,200:变形的主机范围

范例:

nmap localhost :扫描本机

nmap -p 1024-65535 localhost :扫描本机的一部分端口

nmap -PT 192.168.1.171-177 :已ping方式扫描数台主机

  1. 用主机名和IP地址扫描系统 Nmap工具提供各种方法来扫描系统。在这个例子中,我使用server2.tecmint.com主机名来扫描系统找出该系统上所有开放的端口,服务和MAC地址。 使用主机名扫描 以下为几个栗子仅作参考
代码语言:javascript
复制
[root@server1 ~]# nmap server2.tecmint.com  
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-11 15:42 EST 
Interesting ports on server2.tecmint.com (192.168.0.101): 
Not shown: 1674 closed ports 
PORT     STATE SERVICE 
22/tcp   open  ssh 
80/tcp   open  http 
111/tcp  open  rpcbind 
957/tcp  open  unknown 
3306/tcp open  mysql 
8888/tcp open  sun-answerbook 
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems) 
Nmap finished: 1 IP address (1 host up) scanned in 0.415 seconds 
You have new mail in /var/spool/mail/root 

使用IP地址扫描

代码语言:javascript
复制
[root@server1 ~]# nmap 192.168.0.101 
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-18 11:04 EST 
Interesting ports on server2.tecmint.com (192.168.0.101): 
Not shown: 1674 closed ports 
PORT     STATE SERVICE 
22/tcp   open  ssh 
80/tcp   open  http 
111/tcp  open  rpcbind 
958/tcp  open  unknown 
3306/tcp open  mysql 
8888/tcp open  sun-answerbook 
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems) 
Nmap finished: 1 IP address (1 host up) scanned in 0.465 seconds 
You have new mail in /var/spool/mail/root 

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

代码语言:javascript
复制
[root@server1 ~]# nmap -v server2.tecmint.com 
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-11 15:43 EST 
Initiating ARP Ping Scan against 192.168.0.101 [1 port] at 15:43 
The ARP Ping Scan took 0.01s to scan 1 total hosts. 
Initiating SYN Stealth Scan against server2.tecmint.com (192.168.0.101) [1680 ports] at 15:43 
Discovered open port 22/tcp on 192.168.0.101 
Discovered open port 80/tcp on 192.168.0.101 
Discovered open port 8888/tcp on 192.168.0.101 
Discovered open port 111/tcp on 192.168.0.101 
Discovered open port 3306/tcp on 192.168.0.101 
Discovered open port 957/tcp on 192.168.0.101 
The SYN Stealth Scan took 0.30s to scan 1680 total ports. 
Host server2.tecmint.com (192.168.0.101) appears to be up ... good. 
Interesting ports on server2.tecmint.com (192.168.0.101): 
Not shown: 1674 closed ports 
PORT     STATE SERVICE 
22/tcp   open  ssh 
80/tcp   open  http 
111/tcp  open  rpcbind 
957/tcp  open  unknown 
3306/tcp open  mysql 
8888/tcp open  sun-answerbook 
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems) 
Nmap finished: 1 IP address (1 host up) scanned in 0.485 seconds 
Raw packets sent: 1681 (73.962KB) | Rcvd: 1681 (77.322KB)

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

代码语言:javascript
复制
[root@server1 ~]# nmap 192.168.0.101 192.168.0.102 192.168.0.103  
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-11 16:06 EST  
Interesting ports on server2.tecmint.com (192.168.0.101):  
Not shown: 1674 closed ports  
PORT     STATE SERVICE  
22/tcp   open  ssh  
80/tcp   open  http  
111/tcp  open  rpcbind  
957/tcp  open  unknown  
3306/tcp open  mysql  
8888/tcp open  sun-answerbook  
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems)  
Nmap finished: 3 IP addresses (1 host up) scanned in 0.580 seconds

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

代码语言:javascript
复制
[root@server1 ~]# nmap 192.168.0.* 
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-11 16:11 EST 
Interesting ports on server1.tecmint.com (192.168.0.100): 
Not shown: 1677 closed ports 
PORT    STATE SERVICE 
22/tcp  open  ssh 
111/tcp open  rpcbind 
851/tcp open  unknown 
Interesting ports on server2.tecmint.com (192.168.0.101): 
Not shown: 1674 closed ports 
PORT     STATE SERVICE 
22/tcp   open  ssh 
80/tcp   open  http 
111/tcp  open  rpcbind 
957/tcp  open  unknown 
3306/tcp open  mysql 
8888/tcp open  sun-answerbook 
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems) 
Nmap finished: 256 IP addresses (2 hosts up) scanned in 5.550 seconds 
You have new mail in /var/spool/mail/root 

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

代码语言:javascript
复制
[root@server1 ~]# nmap 192.168.0.101,102,103 
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-11-11 16:09 EST 
Interesting ports on server2.tecmint.com (192.168.0.101): 
Not shown: 1674 closed ports 
PORT     STATE SERVICE 
22/tcp   open  ssh 
80/tcp   open  http 
111/tcp  open  rpcbind 
957/tcp  open  unknown 
3306/tcp open  mysql 
8888/tcp open  sun-answerbook 
MAC Address: 08:00:27:D9:8E:D7 (Cadmus Computer Systems) 
Nmap finished: 3 IP addresses (1 host up) scanned in 0.552 seconds 
You have new mail in /var/spool/mail/root 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档