By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

Sniffer with RAW SOCKETS

P: n/a
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()
Sep 7 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2005-09-07, billiejoex <bi********@fastwebnet.it> wrote:
Hi all. I'm trying to make a simple icmp sniffer by using
SOCK_RAW.
Just a suggestion: you'd probably be better off using the PCAP
library.
The code below works but ONLY if I first use the sendto()
function. Does anybody knows why?


'Fraid not.

--
Grant Edwards grante Yow! I just bought
at FLATBUSH from MICKEY
visi.com MANTLE!
Sep 7 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.