0

I'm trying to code packet sniffer but I'm facing a problem it says module 'socket' has no attribute 'AF_PACKET' I tried to solve it but nothing works

this is the code:

import socket
from scapy.all import *
from scapy.layers.l2 import Ether

sniffer_socket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))

interface = "etho0"
sniffer_socket.bind((interface, 0))

try:
    while True:
        raw_data, addr = sniffer_socket.recvfrom(65535)
        packet = Ether(raw_data)
        print(packet.summary())
except  KeyboardInterrupt:
    sniffer_socket.close()
James Z
  • 12,209
  • 10
  • 24
  • 44

0 Answers0