I am using a RHEL6 computer and I try to communicate with a Windows XP computer via RAW sockets.
When I receive a specific frame on my RHEL computer, a Python 2 script using RAW sockets processes the frame and changes the following fields before sending it to the Windows computer :
- Dest MAC
- Dest IP
- IP ID
- Checksum
The packet arrives on my Windows XP computer, as I see the packet in Wireshark, but it never reaches the application layer, as the software that needs the packet doesn't react.
This is how I create the sent packet :
import socket, binascii, optparse
s=socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(3))
s.bind(('eth1',0))
while True:
result = s.recv(65535)
if binascii.hexlify(result[30:34]).decode() == "<WANTED FRAME IP>":
result2 = "<DEST_MAC>".decode("hex") + result[6:18] + "<IP_ID>".decode("hex") + result[20:24] + "<CHECKSUM>".decode("hex") + result[26:30] + "<DEST_IP>".decode("hex") + result[34:]
s.send(result2)
When I try using "classic" socket, the target software correctly receives the packet, but it's not the behavior I want as I have to use RAW sockets to send them.
I tried sending with the same code other simples UDP packets, and I got the same behavior as a result, with the packet correctly seen on wireshark but never reaches application layer on my Windows XP.
Any idea why my RAW socket packets are not correctly processed by the target?