Scapy: sniff(filter='icmp', iface='ppp0', prn=icmp_callback)
Veek. M
vek.m1234 at gmail.com
Thu Jul 14 07:48:26 EDT 2016
#!/usr/bin/python
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import TCP, IP, ICMP, sniff
def ip_callback(pkt):
print '--------------------------- IP--------------------------'
pkt.show()
print 'IP', pkt.src, pkt.sport, '--->', pkt.dst, pkt.dport
def icmp_callback(pkt):
print '--------------------------- ICMP --------------------------'
print pkt.show()
def tcp_callback(pkt):
pkt.show()
print 'TCP', pkt.src, pkt.sport, '--->', pkt.dst, pkt.dport
def udp_callback(pkt):
pkt.show()
print 'UDP', pkt.src, pkt.sport, '--->', pkt.dst, pkt.dport
print 'hello'
sniff(filter='icmp', iface='ppp0', prn=icmp_callback)
I get:
deathstar> python myscapy.py
hello
and nothing further when ping -c 2 8.8.8.8 runs - why??
Sometimes though it works (once in a blue moon) and i get the show
output.
More information about the Python-list
mailing list