LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-14-2003, 01:33 AM   #1
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15
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

Last edited by gr33ndata; 10-14-2003 at 08:43 AM.
 
Old 10-14-2003, 11:37 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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/
 
Old 10-14-2003, 02:24 PM   #3
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
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 ??
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Libnet performance fr_laz Linux - Networking 0 10-31-2005 11:42 AM
libnet problem zaichik Programming 0 08-06-2005 06:30 PM
libnet problems StraitFaced Linux - Software 0 05-21-2005 06:04 PM
Libnet - Libnids Shu Linux - Software 0 07-15-2003 06:42 PM
libnet problems vexer Slackware 4 06-08-2003 08:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration