Re: Send packet w/out calling libnet_build_ethernet()

Graeme Connell <[email protected]> 5 Apr 2004 17:12:18 -0000
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
In-Reply-To: <[email protected]>

>I have an ethernet packet that was previously captured by libpcap and I 
>would like to send it back thru the wire without modifying it. What I 
>did was to exctract the source, destination and type from the packet and 
>call libnet_build_ethernet() with these parameters. It worked well but I 
>would be pleased if someone could tell me a way to do it without having 
>to extract and insert back the ethernet header.

Fabio D:

   Here's a little source file that should do what you're looking for.  Takes as arguments on the command line a device for input and a device for output.  Then, it simply takes all packets from devin and writes to devout with the libnet_write_link() command, which I think is what you're looking for.  If you use libnet_init() with the LIBNET_LINK injection type, then write with libnet_write_link(), you can simply write back the packet info that you captured.

    --Graeme Connell

Source code for device redirection:
http://community.middlebury.edu/~gconnell/src/devRedirect.c