ffalcinelli / pydivert

A Python binding for WinDivert driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

difficulty with create and send a fake packet

ly3too opened this issue · comments

Hi,
I tried to create a fake RST packet and send it. But it seems very unconvenient. Do I have to create a Packet from raw bytes and manipulate the raw data before create the Packet? is it possible to directy create a Packet and change the properties and then send it?

Use SCAPY. Very helpful tool that makes it very easy to make and send fake packets.

This is a very late response but maybe It would be useful for somebody.
I think that the biggest pro for using pydivert over scapy is because it gives you the control over sending or blocking captured packets, in contrast to scapy that sends the captured packet automatically. In case your only goal is to create packets and send them, scapy is more straightforward with easier ways for creating and encapsulating packets.
If you still want to use Pydivert, the Packet object must be created through a memoryview object of a valid raw bytes packet (+ a direction and a tuple representing a network interface). the raw packet will be used to calculate the other attributes of the packet object, that cannot be manually populated as it seems if the provided raw packet is not valid.
So, you can use a "template" packet raw bytes to first create the packet object, then change the attributes of the packet manually afterwards.