从 arp-scan -l 中仅提取 MAC 个地址

Extract only MAC addresses from arp-scan -l

我只想从 arp-scan -l 收集 MAC 个地址,省略 IP 地址和设备名称。我们该怎么做呢?我知道中间一栏的这些都是MAC个地址。

192.168.1.1 bc:98:89:47:20:f8   Fiberhome Telecommunication Technologies Co.,LTD
192.168.1.3 70:18:8b:5e:01:fd   Hon Hai Precision Ind. Co.,Ltd.
192.168.1.5 90:e7:c4:da:80:76   HTC Corporation
192.168.1.6 b8:27:eb:b0:4d:25   Raspberry Pi Foundation

我想要这样

bc:98:89:47:20:f8
70:18:8b:5e:01:fd   
90:e7:c4:da:80:76
b8:27:eb:b0:4d:25

编辑:

arp-scan -l 给出以下结果

Interface: wlp5s0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9.5 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.1.1 bc:98:89:47:20:f8   Fiberhome Telecommunication Technologies Co.,LTD
192.168.1.5 90:e7:c4:da:80:76   HTC Corporation
192.168.1.3 70:18:8b:5e:01:fd   Hon Hai Precision Ind. Co.,Ltd.
192.168.1.5 90:e7:c4:da:80:76   HTC Corporation (DUP: 2)
192.168.1.6 b8:27:eb:b0:4d:25   Raspberry Pi Foundation
192.168.1.6 b8:27:eb:b0:4d:25   Raspberry Pi Foundation (DUP: 2)
192.168.1.4 80:35:c1:4a:a5:dc   (Unknown)

9 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.5: 256 hosts scanned in 3.017 seconds (84.85 hosts/sec). 7 responded

我假设您正在使用类似 linux 的 shell 并且安装了 awk 实用程序(它主要是预安装的)-

arp-scan -l | awk '/.*:.*:.*:.*:.*:.*/{print }'

学习基本的 Unix shell!

特别是 cut 命令可用于从文本中提取列。将字段分隔符设置为 space(可能是默认设置)和 select 第二个字段。

使用 arp-scan 的 --plain 选项可以使事情变得更容易。它将显示仅显示响应主机的纯输出。主机的信息由制表符分隔,MAC 地址(第 2 列)可以通过 cut 轻松提取,如 Anony-Mousse 所述:

arp-scan -l --plain | cut -f 2