PracticeDev/study_python/scapy_test.py

24 lines
654 B
Python
Raw Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
from scapy.all import *
def pack_callback(packet):
print ("---------------- packet -----------------")
print ( packet.show() )
print ("-----------------------------------------")
if packet['Ether'].payload:
print (packet['Ether'].src)
print (packet['Ether'].dst)
print (packet['Ether'].type)
if packet['ARP'].payload:
print (packet['ARP'].psrc)
print (packet['ARP'].pdst)
print (packet['ARP'].hwsrc)
print (packet['ARP'].hwdst)
time.sleep(2)
filterstr="arp"
sniff(filter=filterstr,prn=pack_callback, iface='eth0', count=0)