Send Raw IP packet in C #, all above the ethernet level

I do not want to change parts of the ethernet frame, but I need to change the IP packet and part of the frame data.

I am trying to send a raw frame and it still puts the IP address information. I basically need to send a frame without defining an endpoint, except in the bits that I send.

Here is what I got:

Socket s = new Socket(AddressFamily.Unspecified, SocketType.Raw, ProtocolType.Raw); EndPoint ep = new IPEndPoint(IPAddress.Parse("205.188.100.58"),80); s.SendTo(GetBytes(""),ep); //im sending nothing, so i expect the frame to just have ethernet stuff s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, false); 

My question is: Using SendTo adds part of the IP frame, I do not want this, because I want to fake the original IP address. Using Submit will fail because it says I need to specify an endpoint. Any suggestions on what to do? I just want to send a packet and define an IP section and a data section.

Note. No, I do not do a DOS attack, I need this for legal use!

I know how to determine the IP part, it is just a matter of sending data without the generated IP part.

+6
source share
2 answers

He answered your question very well: How to send a raw ethernet packet from C #?

Using the Pcap.Net library view, you can easily modify individual data packets in any way (since it uses the underlying WinPcap, which is very powerful).

You can also completely skip the IP level and send it to MAC addresses, as in: http://www.codeproject.com/KB/IP/sendrawpacket.aspx , where I used a similar approach for communicating with a microcontroller (Atmel ATmega) via Ethernet , which provides an almost constant connection.

+8
source

"Using the Pcap.Net library class, you can easily modify individual data packets in any way (since it uses the powerful WinPcap implementation, which is very efficient).

Wrong! WinPcap can not do filtering / batch removal / package creation. In other words, its just letting you track a package in asynchronous mode ...

Raw packet / Intermediate mode / Driver filter / packet routing is another conversation.

+1
source

Source: https://habr.com/ru/post/885840/


All Articles