Skip to content

Instantly share code, notes, and snippets.

@speakinghedge
Created June 21, 2018 18:37
Show Gist options
  • Save speakinghedge/a45a18a4f1862e72e79404c6f421f954 to your computer and use it in GitHub Desktop.
Save speakinghedge/a45a18a4f1862e72e79404c6f421f954 to your computer and use it in GitHub Desktop.
from scapy.all import *
from scapy.layers.l2 import *
import socket
ETH_P_ALL = 0x0003
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
def dump_layers(frm):
lyr = Ether(frm[0])
print('%s' % lyr.name)
lvl = ' '
while lyr.payload:
lyr = lyr.payload
print('%s%s' % (lvl, lyr.name))
lvl += ' '
while True:
b = s.recvfrom(0xffff)
dump_layers(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment