문제

from scapy.all import *
import socket 

s = socket.socket(socket.AF_INET, socket.SOCK_RAW,socket.IPPROTO_RAW)
s.bind(("127.0.0.1", 0))
pe=Ether()/IP(src="10.0.0.1",dst="10.0.0.2")/ICMP()
data = pe.build()
while True:
     s.send(data)

Though I had mention the destination address but still with this script I got this error

WARNING: No route found for IPv6 destination :: (no default route?)

Traceback (most recent call last):

File "testing.py", line 12, in

s.send(data)

socket.error: [Errno 89] Destination address required
도움이 되었습니까?

해결책

  1. Use AF_PACKET instead of AF_INET.

    s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW,socket.IPPROTO_RAW)
    
  2. Bind to the device name instead of address.

    s.bind(("lo", 0))
    

    (lo is loopback device name. Replace it with actual device name if you want to send the packet outside the machine.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top