Skip to content

Instantly share code, notes, and snippets.

@jasimmonsv
Created October 11, 2021 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasimmonsv/c492f3e1bda8f7b7229872522a31c0c2 to your computer and use it in GitHub Desktop.
Save jasimmonsv/c492f3e1bda8f7b7229872522a31c0c2 to your computer and use it in GitHub Desktop.
Scapy list all mac address in a pcap file
!#/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