Can the packet captured be converted for use by Scapy?
SGtOriginal opened this issue · comments
SGtOriginal commented
Probably a stupid question since I asked without any research but is it possible to convert the packet output for editing with scapy? I feel like scapy is a bit more friendly with packet editing.
Ayoub Selmi commented
pydivert packet can be converted to scapy IP layer using the following code:
from scapy.layers.inet import IP
def convert_to_scapy(packet: pydivert.Packet) -> IP:
"""
converts scapy packet to scapy IP layer
"""
return IP(bytes(packet.ipv4.raw))
if you want to send the packet using scapy, make sure to correctly format the Ethernet layer (mac@ of dst and src) and choose the right network interface.