开发者

How can I inject raw packets onto my network

开发者 https://www.devze.com 2022-12-18 02:30 出处:网络
In testing certain network device driver receive features, I need to send special packets on the wire.I know I 开发者_运维问答need to open a raw socket and push the bytes out.Is there some well-known

In testing certain network device driver receive features, I need to send special packets on the wire. I know I 开发者_运维问答need to open a raw socket and push the bytes out. Is there some well-known example (C, perl, whatever) code already available for playing at this level?

(added later) I would prefer non-platform-specific answers, they'll be the most useful for everyone.


Look at the documentation for packet. Basically, you create a socket with SOCK_RAW or SOCK_DGRAM, then write to the socket using normal socket i/o. However, the data you send will be put directly on the line, rather than automatically getting the headers that are necessary for most network interop.


http://www.codeproject.com/KB/IP/sendrawpacket.aspx

There's already an existing project that may be able to help you with this.


Check out http://tcpreplay.synfin.net/wiki/tcprewrite#RewritingLayer2 and http://tcpreplay.synfin.net/


Seems to me you are looking for a tool to generate your own packets, Scapy is such a tool often used in the security industry (such as pentesters).

Demo is available: http://www.secdev.org/projects/scapy/demo.html


I can't think of any examples. But you should just be able to open up a UDP socket to any IP address you like and start writing data to it. Make sure its UDP or this will not work.


I found that there's a good C example here at Security-Freak, which only needed a little modification for flexibility. I'm hoping there are more answers in other languages.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号