Bytearray objects cannot be converted to Packet objects (and therefore Scapy cannot send them, this explains the error 'bytearray' object has no attribute '__rdiv__'). You need to convert busing str()(if you are using Scapy prior to version 2.4.0 with Python 2) or raw()(with Scapy 2.4.0 or later with Python 2 or 3).
Scapy 2.4.0. Bad file descriptor Powershell.
, raw() ( str(), Scapy < 2.4.0):
b = bytearray([0xff, 0xff])
def spoof(src_ip, src_port, dest_ip, dest_port):
global b
spoofed_packet = IP(src=src_ip, dst=dest_ip) / TCP(sport=src_port, dport=dest_port) / raw(b)
send(spoofed_packet)
bytearray, bytes/str:
b = b"\xff\xff"
def spoof(src_ip, src_port, dest_ip, dest_port):
global b
spoofed_packet = IP(src=src_ip, dst=dest_ip) / TCP(sport=src_port, dport=dest_port) / b
send(spoofed_packet)