Libnet
Hey pals
Here we meet again I wanted to do a program which does some packet injection such as arp requests etc. So I heard there is a library for that called libnet (http://www.packetfactory.net/libnet/) But nfortunately the man pages written with it are very short and miss many details, so does any one know a documentation or a detailed tutorial or howto to help me understand how to use this library Also If anyone knows a better library please tell me |
Check the sources for these tools:
http://www.citi.umich.edu/u/provos/h...rpd-0.2.tar.gz http://www.packetfactory.net/projects/packit/ ftp://ftp.dementia.org/pub/net-tools/ |
Thanks a lot HKO
Now I have one more question I wrote a program to send arp --------------------START OF CODE------------------------------------------------------------------- #include <libnet.h> int main(int argc,char** argv){ u_long ip_src; u_char ip_dst[4] = {0x0a,0x00,0x00,0x04}; u_char enet_src[6] = {0x00,0x01,0x02,0x03,0x04,0x05}; u_char enet_dst[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; libnet_t* l; libnet_ptag_t t; char* device; char errorBuffer[LIBNET_ERRBUF_SIZE]; if(argc>=2) device=argv[1]; l = libnet_init(LIBNET_LINK_ADV,device,errorBuffer); if(l==NULL){ fprintf(stderr,"\nError in libnet_init(): %s",errorBuffer); return -1; } ip_src = libnet_get_ipaddr4(l); t = libnet_build_arp(ARPHRD_ETHER,ETHERTYPE_IP,6,4,ARPOP_REPLY,enet_src,(u_char*)&ip_src,enet_dst,ip_dst ,NULL,0,l,0); if(t==-1){ fprintf(stderr,"\nError in libnet_build_arp(): %s",libnet_geterror(l)); libnet_destroy(l); return -1; } t = libnet_autobuild_ethernet(enet_dst,ETHERTYPE_ARP,l); if(t==-1){ fprintf(stderr,"\nError in libnet_autobuild_ethernet(): %s",libnet_geterror(l)); libnet_destroy(l); return -1; } int x=libnet_write(l); if(x==-1){ fprintf(stderr,"\nError in libnet_write(): %s \n",libnet_geterror(l)); libnet_destroy(l); return -1; } libnet_destroy(l); } --------------------------END OF CODE------------------------------------------- And whenever I run it the computer hangs !! So does anyone know what's wrong with it ?? |
All times are GMT -5. The time now is 12:52 AM. |