Demo entry 6345231

basic_sniffer.py

   

Submitted by Melih on Jan 30, 2017 at 15:11
Language: Python. Code size: 411 Bytes.

import socket

# create the sniffer raw socket object 
sniffer = socket.socket(socket.AF_INET,socket.SOCK_RAW, socket.IPPROTO_ICMP)

# bind it to localhost
sniffer.bind(('0.0.0.0',0)) 

# make sure that the IP header is included
sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HRDINCL,1)

print 'sniffer is listening for incoming connections'

# get a single packet 
print sniffer.recvfrom(65535) 

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).