Sniffer Linux with Raw Socket

castor91 castor91 at gmail.com
Sun Jun 6 11:02:24 EDT 2010


Hi all, i try to make a python sniffer for linux using raw socket and not
pcap or scapy.. But i have a lot of problems..
I use the code that i found here:
http://docs.python.org/library/socket.html
<http://docs.python.org/library/socket.html>

import socket
# the public network interfaceHOST = socket.gethostbyname(socket.gethostname())
# create a raw socket and bind it to the public interfaces =
socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_IP)s.bind((HOST, 0))
# Include IP headerss.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
# receive all packagess.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
# receive a packageprint s.recvfrom(65565)
# disabled promiscuous modes.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)

but the attribute "ioctl" is only for windows platform... and also i must
replace "socket.IPPROTO_IP" with "9" because it doesn't work ( i found the
answer in a web topic)

How do i ???

Thanks and sorry for bad english.

--castor91
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100606/6dcbeabf/attachment.html>


More information about the Python-list mailing list