abhinav singh
abhinav singh

Reputation: 1104

Error while capturing packets from raw socket

I am trying to run the following lines of program:

import socket
import struct
import binascii

sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(0x800))
print sock

I get the following error: Message File Name Line Position
Traceback
C:\Users\d\Documents\rawsocket.py 19
AttributeError: 'module' object has no attribute 'PF_PACKET'

I am using Pyscripter, Python 2.7 on windows 8.1

Thanks!

Upvotes: 3

Views: 9288

Answers (1)

Ankit Kumar
Ankit Kumar

Reputation: 1463

you should use AF_INET on windows for opening raw sockets. something like:

sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)

Upvotes: 12

Related Questions