Sniffer with RAW SOCKETS
- From: "billiejoex" <billiejoex@xxxxxxxxxxxxx>
- Date: Wed, 7 Sep 2005 19:57:46 +0200
Hi all. I'm trying to make a simple icmp sniffer by using SOCK_RAW.
The code below works but ONLY if I first use the sendto() function.
Does anybody knows why?
Regards
from socket import *
import select
def recv():
while 1:
if s in select.select([s],[],[],99)[0]:
reply = s.recvfrom(2000)[0]
print reply
s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
s.sendto('test', ('127.0.0.1', 0)) # without this it doesn't work.
recv()
.
- Follow-Ups:
- Re: Sniffer with RAW SOCKETS
- From: Grant Edwards
- Re: Sniffer with RAW SOCKETS
- Prev by Date: distutils question
- Next by Date: Re: Question about concatenation error
- Previous by thread: distutils question
- Next by thread: Re: Sniffer with RAW SOCKETS
- Index(es):
Relevant Pages
|