Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

icmp sniffer with pcapy module

 
 
billiejoex
Guest
Posts: n/a
 
      09-09-2005
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

#!/usr/bin/python
### sniffer
import pcapy
from impacket.ImpactDecoder import *

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

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

dev = get_int()
p = pcapy.open_live(dev, 1500, 0, 100)
p.setfilter('icmp')
print "Listening on eth: net=%s, mask=%s\n" % (p.getnet(), p.getmask())
p.loop(-1, recv_pkts)


 
Reply With Quote
 
 
 
Reply

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



Advertisments