By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

icmp sniffer with pcapy module

P: n/a
Hi all. The source below is a simple icmp sniffer made with pcapy.
To decode packets I'm using the EthDecoder() function that returns a
rapresentation of the packet including ICMP type, ICMP code, IP source and
IP destination.
All I need, now, is to get the ip src and ip dst only but I don't know how
to do it.
I tried to use the IPDecoder instead of EthDecoder to decode packets but
misteriously it doesn't works.
Does anybody have a good idea about how to get this values only?

Best regards

### sniffer
import pcapy
from impacket.ImpactDecoder import *

def recv_pkts(hdr, data):
x = EthDecoder().decode(data)
print x

def get_int():
devs = pcapy.findalldevs()
for eth in devs:
print " %d - %s" %(i,devs[i])
sel=input(" Select interface: ")
return dev

dev = get_int()
p = pcapy.open_live(dev, 1500, 0, 100)
print "Listening on eth: net=%s, mask=%s\n" % (p.getnet(), p.getmask())
p.loop(-1, recv_pkts)
Sep 9 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.