I need to make a project in a few days, its basic client and server interface. The trick is that it should be all raw sockets. I have no problem creating this, I am just stuck when sending packets.
At first I tried to bind it to the 'en1' interface, but it continues to give me a nodename not known error. When I bind it to the local IP address, it works fine. Upon completion of this, I created a class of raw packages, all in hexadecimal. Then I sent the package to be sent by wire.
The problem is that when capturing a packet using wirehark, it appears as the payload of the ipv4 packet. I don't want it to automatically create headers, so my package class was there anyway. Do you know how I can take out these headers?
Here is my code - just a raw function:
def raw(): HOST = gethostbyname('192.168.1.10') s = socket(AF_INET, SOCK_RAW, IPPROTO_IP) s.bind((HOST, 0)) s.setsockopt(IPPROTO_IP, IP_HDRINCL, 0)
o and here is the captured packet with a greeting at the end:
007f 2809 6da2 28cf daee 2156 0800 4500 004d 1bfc 0000 4000 db59 c0a8 010a c0a8 0101* 007f 2809 6da2 28cf daee 2156 0800 4500 0036 2352 4000 4006 0000 c0a8 010a c0a8 0101 15c0 0050 0000 0000 0000 0000 8010 813b 0000 68656c6c6f -hello
* this is the beginning of the payload, although it is assumed that this will be the beginning of the package also I will not use any other modules that I should use the socket.
source share