社区
通信技术
帖子详情
有sniffer 原码吗?
greenman
2000-07-10 04:26:00
想把网卡设为混杂模式。苦于无门,想看看sniffer的方法,
谁有的话,帮小弟一把
windows下的送20分。
linux/ubnix下的送30分。
...全文
167
5
打赏
收藏
有sniffer 原码吗?
想把网卡设为混杂模式。苦于无门,想看看sniffer的方法, 谁有的话,帮小弟一把 windows下的送20分。 linux/ubnix下的送30分。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
BallyTan
2001-11-13
打赏
举报
回复
to wuxiang(无香) :
windows98下的源代码发给我好吗?
(ballytan@sina.com)
thanks
wuxiang
2000-11-04
打赏
举报
回复
原来windows下的分比linux的分少,
算了,windows下的源代码太长,就不贴了
greenman
2000-07-10
打赏
举报
回复
谢了,兄弟。我兑现诺言。
如果有人有更好的注意。我可以加分。
sean
2000-07-10
打赏
举报
回复
一个很简单的例子
* From bbs.sjtu.edu.cn */
/* ipl.c 1/3/95 by loq */
/* monitors ip packets for Linux */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <signal.h>
#include <stdio.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/if_ether.h>
#define BUFLEN 8192
#define ETHLINKHDR 14
print_data(int count, char *buff)
{
int i, j, c ;
int printnext = 1 ;
if( count )
{
if( count % 16 )
c = count + ( 16 - count%16 ) ;
else c = count ;
}
else c = count ;
for( i=0; i<c; i++ )
{
if( printnext ) { printnext--; printf( "%.4x ", i&0xffff ) ; }
if( i < count ) printf( "%3.2x", buff[i]&0xff ) ;
else printf( " " ) ;
if( !( (i+1) % 8 ) )
if( (i+1) % 16 ) printf( " -" ) ;
else
{
printf( " " ) ;
for( j=i-15; j<=i; j++ )
if( j < count )
{
if( (buff[j]&0xff) >= 0x20 && (buff[j]&0xff) <= 0x7e )
printf( "%c", buff[j]&0xff ) ;
else printf( "." ) ;
}
else printf( " " ) ;
printf( "\n" ) ;
printnext = 1 ;
}
}
}
int initdevice( device, pflag )
char *device;
int pflag;
{
#define PROTO htons(0x0800) /* Ethernet code for IP protocol */
int if_fd = 0 ;
struct ifreq ifr ;
if ( (if_fd=socket(AF_INET,SOCK_PACKET,PROTO)) < 0 )
{
perror( "Can't get socket" ) ;
exit(2) ;
}
strcpy( ifr.ifr_name, device ) ; /* interface we're gonna use */
if( ioctl(if_fd, SIOCGIFFLAGS, &ifr) < 0 ) /* get flags */
{
close( if_fd ) ;
perror( "Can't get flags" ) ;
exit(2) ;
}
#if 1
if ( pflag )
ifr.ifr_flags |= IFF_PROMISC ; /* set promiscuous mode */
else
ifr.ifr_flags &= ~(IFF_PROMISC) ;
#endif
if( ioctl(if_fd, SIOCSIFFLAGS, &ifr) < 0 ) /* set flags */
{
close( if_fd );
perror( "Can't set flags" );
exit(2);
}
return if_fd ;
}
struct etherpacket
{
struct ethhdr eth;
struct iphdr ip;
struct tcphdr tcp;
char data[8192];
} ;
main()
{
int linktype ;
int if_eth_fd = initdevice( "eth0", 1 ) ;
#if 0
int if_ppp_fd = initdevice( "sl0", 1 ) ;
#endif
struct etherpacket ep ;
struct sockaddr dest ;
struct iphdr *ip ;
struct tcphdr *tcp ;
struct timeval timeout ;
fd_set rd, wr ;
int dlen;
#if 0
struct slcompress *slc = slhc_init( 64, 64 ) ;
#endif
for(;;)
{
bzero( &dest, sizeof(dest) ) ;
dlen = 0 ;
FD_ZERO( &rd ) ;
FD_ZERO( &wr ) ;
FD_SET( if_eth_fd, &rd ) ;
#if 0
FD_SET( if_ppp_fd, &rd ) ;
#endif
timeout.tv_sec = 0 ;
timeout.tv_usec = 0 ;
ip = ( struct iphdr *)( ( (unsigned long)&ep.ip ) - 2 ) ;
tcp = (struct tcphdr *)( ( (unsigned long)&ep.tcp ) - 2 ) ;
while( timeout.tv_sec==0 && timeout.tv_usec==0 )
{
timeout.tv_sec = 10 ;
timeout.tv_usec = 0 ;
select( 20, &rd, &wr, NULL, &timeout ) ;
if( FD_ISSET(if_eth_fd, &rd) )
{
printf( "eth\n" ) ;
recvfrom( if_eth_fd, &ep, sizeof(ep), 0, &dest, &dlen ) ;
}
#if 0
else if( FD_ISSET(if_ppp_fd, &rd) )
{
recvfrom( if_ppp_fd, &ep, sizeof(ep), 0, &dest, &dlen ) ;
printf( "ppp\n" ) ;
}
#endif
}
printf( "proto: %.4x", ntohs(ep.eth.h_proto) ) ;
#if 0
if( ep.eth.h_proto == ntohs(8053) )
{
slhc_uncompress( slc, &ep, sizeof(ep) ) ;
}
#endif
if( ep.eth.h_proto == ntohs(ETH_P_IP) )
{
printf( "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x->",
ep.eth.h_source[0], ep.eth.h_source[1],
ep.eth.h_source[2], ep.eth.h_source[3],
ep.eth.h_source[4], ep.eth.h_source[5] ) ;
printf( "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x ",
ep.eth.h_dest[0], ep.eth.h_dest[1],
ep.eth.h_dest[2], ep.eth.h_dest[3],
ep.eth.h_dest[4], ep.eth.h_dest[5]) ;
printf( "%s[%d]->", inet_ntoa(ip->saddr), ntohs(tcp->source) ) ;
printf( "%s[%d]\n", inet_ntoa(ip->daddr), ntohs(tcp->dest) ) ;
print_data( htons(ip->tot_len) - sizeof(ep.ip) - sizeof(ep.tcp),
ep.data-2 ) ;
}
}
}
x86
2000-07-10
打赏
举报
回复
Linux下有一个,好象叫sniffit,应该有源码吧。
你可以到南开大学的BBS上问问。(我不是南开的,也不知站点,只是以前听说
那里的一个朋友谈起过)
packinter
网络抓包软件的
原码
,好东西和大家分享!
sniffer
技术原理及应用,包括编程方法和工具使用
sniffer
中文翻译过来就是嗅探器,在当前网络技术中使用得非常得广泛。
sniffer
既可以做为网络故 障的诊断工具,也可以作为***嗅探和监听的工具。最近两年,网络监听(
sniffer
)技术出现了新的 重要特征。传统的
sniffer
技术是被动地监听网络通信、用户名和口令。而新的
sniffer
技术出现了主 动地控制通信数据的特点,把
sniffer
技术扩展到了一个新的领域...
sniffer
sniffer
中文翻译过来就是嗅探器,在当前网络技术中使用得非常得广泛。
sniffer
既可以做为网络故障的诊断工具,也可以作为黑客嗅探和监听的工具。最近两年,网络监听(
sniffer
)技术出现了新的重要特征。传统的
sniffer
技术是被动地监听网络通信、用户名和口令。而新的
sniffer
技术出现了主动地控制通信数据的特点,把
sniffer
技术扩展到了一个新的领域。
Sniffer
技术除了目前在传统
sniffer
技术原理及应用,包括编程方法和工具使用(一)
sniffer
技术原理及应用,包括编程方法和工具使用(一) warton(原作) 关键字
sniffer
编程 工具 ethereal,
sniffer
pro 首先,我今天来是做广告的哦:)很久没有更新专栏了,关键是写不出什么好东西,也怕大家见笑!虽然我还没被人骂过,但我见过别人被人骂,哎。不是说,这在csdn好像很正常哈!今天把这个贴子整理一下,这本是专题开发版的一
通信技术
4,356
社区成员
28,926
社区内容
发帖
与我相关
我的任务
通信技术
通信技术相关讨论
复制链接
扫一扫
分享
社区描述
通信技术相关讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章