Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250110
  • 博文数量: 88
  • 博客积分: 1429
  • 博客等级:
  • 技术积分: 523
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-18 15:31
文章分类

全部博文(88)

文章存档

2017年(2)

2016年(24)

2013年(1)

2012年(24)

2011年(15)

2010年(22)

我的朋友

分类: LINUX

2010-05-28 09:05:43

环境:Fedora 10 + VMware Workstation
 
一、先查看Fedora是否有安装libpcap库:
#rpm -aq libpcap
libpcap-0.9.8-3.fc10.i386
说明已经安装了
 
如果未安装,则用命令:
#yum install libpcap
 
二、下载sniffex.c原码
惭愧,我没有找到,到网上搜了一个。
#gcc -Wall -o sniffex sniffex.c -lpcap
#ls
sniffex sniffex.c
#./sniffex
注意要用root用户运行。
有些错误产生,说pcap.h未找到。。。
#ls /usr/include/pcap*
果然木有这个头文件。
解决方法:
 
 

[root@Fedora include]# yum install libpcap*
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Package 14:libpcap-0.9.8-3.fc10.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package libpcap-devel.i386 14:0.9.8-3.fc10 set to be updated
---> Package libpcapnav.i386 0:0.8-2.fc10 set to be updated
---> Package libpcapnav-devel.i386 0:0.8-2.fc10 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================
 Package Arch Version Repository Size
==============================================================================================================================
Installing:
 libpcap-devel i386 14:0.9.8-3.fc10 fedora 29 k
 libpcapnav i386 0.8-2.fc10 updates 21 k
 libpcapnav-devel i386 0.8-2.fc10 updates 36 k

Transaction Summary
==============================================================================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 85 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): libpcapnav-0.8-2.fc10.i386.rpm | 21 kB 00:00
(2/3): libpcap-devel-0.9.8-3.fc10.i386.rpm | 29 kB 00:01
(3/3): libpcapnav-devel-0.8-2.fc10.i386.rpm | 36 kB 00:00
------------------------------------------------------------------------------------------------------------------------------
Total 21 kB/s | 85 kB 00:04
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 4ebfc273
fedora/gpgkey | 2.3 kB 00:00
Importing GPG key 0x4EBFC273 "Fedora (10) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-i386
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libpcap-devel 1/3
  Installing : libpcapnav 2/3
  Installing : libpcapnav-devel 3/3

Installed:
  libpcap-devel.i386 14:0.9.8-3.fc10 libpcapnav.i386 0:0.8-2.fc10 libpcapnav-devel.i386 0:0.8-2.fc10

Complete!
 

之后编译通过,/usr/include下就有pcap.h了。

编译,以root运行:

#./sniffex

打印出抓包信息。

阅读(1821) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~