icmp sniffer with pcapy module

Discussion in 'Python' started by billiejoex, Sep 9, 2005.

  1. billiejoex

    billiejoex Guest

    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+=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)
     
    billiejoex, Sep 9, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CORE Security Technologies
    Replies:
    1
    Views:
    2,115
    Jeff Wagner
    Nov 28, 2003
  2. CORE Security Technologies
    Replies:
    0
    Views:
    294
    CORE Security Technologies
    Nov 27, 2003
  3. billiejoex
    Replies:
    2
    Views:
    463
    billiejoex
    Aug 26, 2005
  4. billiejoex
    Replies:
    2
    Views:
    537
    billiejoex
    Aug 27, 2005
  5. pranesh
    Replies:
    1
    Views:
    1,286
    Diez B. Roggisch
    Nov 2, 2009
Loading...

Share This Page