Created
June 21, 2018 18:37
-
-
Save speakinghedge/a45a18a4f1862e72e79404c6f421f954 to your computer and use it in GitHub Desktop.
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
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