我已经用python3编写了该程序,以通过原始套接字注入数据包。
import socket
import struct
import sys
try:
raw_socket = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(0x0800))
except socket.error as e:
print("Error occurred while creating socket. Error code: " + e[0] + " Error message : " + e[1])
sys.exit()
raw_socket.bind(('wlan0', socket.htons(0x0800)))
packet = struct.pack('!6s6s2s', '\xb8v?\x8b\xf5\xfe', 'l\x19\x8f\xe1j\x8c', '\x80\x00')
rawSocket.send(packet + 'Hello')
但是每当我运行程序时,它就会显示此错误:
Traceback (most recent call last):
File "rawSocketInjector.py", line 11, in <module>
raw_socket.bind(('wlan0', socket.htons(0x0800)))
OSError: [Errno 19] No such device
对于这一行代码:
raw_socket.bind(('wlan0', socket.htons(0x0800)))
我在做什么错了?