Alternative zu socket.ioctl(Python < 2.6)?
Verfasst: Mittwoch 1. August 2012, 16:19
Joa ich wollte mir einen kleinen packet sniffer erstellen und hab erstmal das Code Exampel von python.org genommen, d.h. das ganze sieht aktuell so aus:
Das Problem hierbei ist, dass ich das ganze bei Python 2.2.3 benötige, d.h. socket.ioctl() kann ich hierbei noch nicht verwenden, da dieses erst ab Python 2.6 hinzukommt.
Der Packetverlauf ist ohne das "Receive all" aber dementsprechend eingeschränkt und ich komme nicht an alle packets.
Gibt es eine Alternative zu socket.ioctl() die auch unter Python 2.2 funktioniert oder ist die Suche das komplett via Python zu machen hoffnungslos?
MfG DaRealFreak
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: latin-1 -*-
import socket
def PacketSniffer():
HOST = socket.gethostbyname(socket.gethostname())
try:
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
except:
print("acess denied")
return
s.bind((HOST, 0))
s.setsockopt(socket.IPPROTO_IP, 3, 1)
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
while 1:
print s.recvfrom(65565)
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
PacketSniffer()
Der Packetverlauf ist ohne das "Receive all" aber dementsprechend eingeschränkt und ich komme nicht an alle packets.
Gibt es eine Alternative zu socket.ioctl() die auch unter Python 2.2 funktioniert oder ist die Suche das komplett via Python zu machen hoffnungslos?
MfG DaRealFreak