LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 895|回复: 6

关于linux下嗅探器的编写

[复制链接]
发表于 2003-5-2 15:32:28 | 显示全部楼层 |阅读模式
初学linux网络编程,要交个sniffer设计,请教一下
目前是一个很基本的sniffer,别的主机尝试ftp到开sniffer电脑上
能捕获用户名密码,现在要扩充什么功能,不要太复杂的,tcpdump那样看不懂
如果要实现能捕获在局域网中流经的数据包(不只连接本地),如何实现
是否有必要用libpcap库?
发表于 2003-5-2 17:36:59 | 显示全部楼层
你必须要了解libpcap库
如果你想从ethernet截取packet 必须使用它
发表于 2003-5-2 19:42:51 | 显示全部楼层
截取包的编程是属于数据链路层的编程,一般都是通过调用libpcap来实现的。
 楼主| 发表于 2003-5-2 20:47:11 | 显示全部楼层
这个库怎么安装,我下了一个sniffit里面有带libpcap0。3
发表于 2003-5-2 23:15:09 | 显示全部楼层
和一般的源代码安装一样,./configure && make && make install就行了。在源代码中有一个README.linux,你先仔细看看。最后,要注意内核的配置要有CONFIG_PACKET=y,否则libpcap不会正常工作。
 楼主| 发表于 2003-5-3 15:20:14 | 显示全部楼层
creating cache ./config.cache
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking gcc version... 3
checking how to run the C preprocessor... gcc -E
checking for malloc.h... yes
checking for sys/ioccom.h... no
checking for sys/sockio.h... no
checking if fixincludes is needed... yes
checking for ether_hostton... yes
checking for strerror... yes
checking packet capture type... linux
checking for flex... flex
checking for flex 2.4 or higher... yes
checking for bison... bison
checking for ranlib... ranlib
checking if sockaddr struct has sa_len member... no
checking if unaligned accesses fail... no
ln: creating symbolic link `gnuc.h' to `lbl/gnuc.h': Operation not permitted
ln: creating symbolic link `bpf_filter.c' to `bpf/net/bpf_filter.c': Operation not permitted
rm: cannot remove `net': Is a directory
ln: creating symbolic link `net/net' to `bpf/net': Operation not permitted
checking for a BSD compatible install... /usr/bin/install -c
updating cache ./config.cache
creating ./config.status
creating Makefile
gcc -O2 -I.  -Ilinux-include -DHAVE_MALLOC_H=1 -DHAVE_ETHER_HOSTTON=1 -DHAVE_STRERROR=1  -c ./pcap-linux.c
pcap-linux.c:45:18: gnuc.h: No such file or directory
make: *** [pcap-linux.o] Error 1

安装时显示的信息
怎么回事,
还有CONFIG_PACKET=y怎么看,设置?
发表于 2003-5-3 20:01:10 | 显示全部楼层
缺少gnuc.h,是不是开发包设有装?
CONFIG_PACKET=y在内核的配置文件中。在内核源代码的目录下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表