Created
October 11, 2021 03:21
-
-
Save jasimmonsv/c492f3e1bda8f7b7229872522a31c0c2 to your computer and use it in GitHub Desktop.
Scapy list all mac address in a pcap file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!#/usr/bin/env python | |
from scapy.all import * | |
# Read in pcap file | |
packets = rdpcap("/path/to/packets.pcap") | |
nonstp = [] | |
for pkt in packets: | |
# filter out STP packets | |
if pkt.dst == "01:80:c2:00:00:00": | |
continue | |
# filter out IPv6 packets | |
if pkt.type == 0x86dd: | |
continue | |
nonstp.append(pkt) | |
macs = {} | |
for x in nonstp: | |
# add src MAC to dict | |
macs[x.getlayer(Ether).src] = 1 | |
# Add dst MAC to dict | |
macs[x.getlayer(Ether).dst] = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment