Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > icmp sniffer with pcapy module

Thread Tools

icmp sniffer with pcapy module

Posts: 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)

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi help me in installing pcapy extension module pranesh Python 1 11-02-2009 08:44 PM
Pings and PIX messages 302020: Built ICMP - 302021: Teardown ICMP Lots of them.... Scott Townsend Cisco 2 05-04-2006 02:31 PM
Does any1 use pcapy module on win32 platforms? billiejoex Python 2 08-26-2005 06:02 PM
[ANNOUNCE] Python network security tools: Pcapy, Impacket, InlineEgg CORE Security Technologies Python 1 11-28-2003 06:05 PM