linuxÏÂÀûÓÃPF_PACKETÐÒé×å²¶°ü·½·¨
ÏÈ
·ÅÒ»¶ÎʾÀý³ÌÐò£¬Õâ¶Î³ÌÐòÎÒÔÚRH9ºÍAS4ϱàÒëͨ¹ý£¬³ÌÐò¹¦ÄܾÍÊÇÓôÓ2.2Äں˼ÓÈëµÄPF_PACKETÐÒé×åÀ´½øÐеײãÊý¾Ý°ü²¶»ñ²¢ÏÔʾ¡£
PF_PACKETÐÒé×åÊÇÓëϵͳTCP/IPÐÒéÕ»²¢ÐеÄͬ¼¶±ðÄ£¿é£¬¼´´ÓPF_PACKETÐÒé×åµÃµ½µÄÊý¾Ý°üÊÇûÓо¹ýϵͳTCP/IPÐÒéÕ»´¦Àí
µÄ¡£¶øÇÒ£¬Í¨¹ýÉèÖûìÔÓģʽ£¬¿ÉÒÔºÜÈÝÒ×µÄʵÏÖsniffer¡£
#include<errno.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/socket.h>
#include<fcntl.h>
#include<netpacket/packet.h>
#include<net/if.h>
#include<net/if_arp.h>
#include<netinet/in.h>
#include<netinet/ip.h>
#include<linux/if_ether.h>
#include<arpa/inet.h>
#include<sys/ioctl.h>
#include<unistd.h>
#define RED "\E[31m\E[1m"
#define GREEN "\E[32m\E[1m"
#define YELLOW "\E[33m\E[1m"
#define BLUE "\E[34m\E[1m"
#define NORMAL "\E[m"
int Get_IfaceIndex(int fd, const char* interfaceName)
{
struct ifreq ifr;
if (interfaceName == NULL)
{
return -1;
}
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, interfaceName);
if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1)
{
printf("RED ioctl error\n");
return -1;
}
return ifr.ifr_ifindex;
}
int set_Iface_promisc(int fd, int dev_id)
{
struct packet_mreq mr;
memset(&mr,0,sizeof(mr));
mr.mr_ifindex = dev_id;
mr.mr_type = PACKET_MR_PROMISC;
if(setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP,&mr,sizeof(mr))==-1)
{
fprintf(stderr,"GREEN set promisc failed! \n");
return -1;
}
return 0;
}
void usage(char *exename)
{
fprintf(stderr,RED"%s <interface> <packets num to capture>\n"NORMAL, exename);
}
int main(int argc, char **argv)
{
int listen_fd;
int ipak=0,maxk=0;
char buffer
[8192];
int frmlen;
struct sock
Ïà¹ØÎĵµ£º
ÔÍÄðÐí¾ÃµÄÊÖ¼ÇÖÕÓÚÃæÊÀÁË£¬Ï£Íû¸ßÊÖ¶à¶àÖ¸µã¡£´Ó7Ôµ½ÏÖÔÚ£¬ÎÒ²ÎÓëµÄ²úÆ·µÄÑз¢£¬Ò²Ëã¸æÒ»¶ÎÂ䣬Ã÷Ìì¾ÍÊdzɶ¼µÄÒ½²©»áÁË£¬Õ⼸¸öÔÂÂýÂý¿Ð³öÀ´µÄ¶«Î÷£¬ÒªºÃºÃµÄ×ܽáһϣ¬´óѧµÄʱºò£¬ÍæµÄÊǵ¥Æ¬»ú£¬armÂã»ú£¬¶ÔÓÚϵͳÓÐËùÁ˽⣬×ö¹ýһЩСʵÑ飬µ«ÊÇûÓÐϵͳµÄѧϰ£¬Èç½ñ×öµÄÊÂÇ飬ÈÃÎÒ¶ÔǶÈëʽlinuxµÄÈÏʶҲ¸üÕýÁËÐ ......
LinuxµÄÎļþ²Ù×÷APIÉæ¼°µ½´´½¨¡¢´ò¿ª¡¢¶ÁдºÍ¹Ø±ÕÎļþ¡£
1.linux API
¡¡¡¡´´½¨
int creat(const char *filename, mode_t mode);
¡¡¡¡²ÎÊýmodeÖ¸¶¨Ð½¨ÎļþµÄ´æÈ¡È¨ÏÞ£¬ËüͬumaskÒ»Æð¾ö¶¨ÎļþµÄ×îÖÕȨÏÞ£¨mode&umask£©£¬ÆäÖÐumask´ú±íÁËÎļþÔÚ´´½¨Ê±ÐèҪȥµôµÄһЩ´æÈ¡È¨ÏÞ¡£umask¿Éͨ¹ýϵͳµ÷ÓÃumask()À´¸ ......
ǶÈëʽÉ豸É쵀 Linux ϵͳ¿ª·¢£¨Ò»£©
http://hi.baidu.com/digast/blog/item/4ff9b8318b94c0ac5fdf0eb2.html
2008-04-03 18:31
Èç¹ûÄú¸Õ½Ó´¥Ç¶Èëʽ¿ª·¢£¬ÄÇô´óÁ¿¿ÉÓõÄÒýµ¼×°ÔسÌÐò£¨bootloader£©¡¢¹æÄ£ËõСµÄ·Ö·¢°æ£¨distribution£©¡¢ÎļþϵͳºÍ GUI ¿´ÆðÀ´¿ÉÄÜÌ«¶àÁË¡£µ«ÊÇÕâЩ·á¸»µÄÑ¡Ïîʵ¼ÊÉÏÊÇÒ»ÖÖ¶÷´Í£¬ÔÊ ......
Linuxѧϰ¸ßÊÖд¸ø³õѧÕߵľÑé̸
2008-04-01 15:02
ÏÖÔںöàµÄÈË¿ªÊ¼½Ó´¥µçÄÔµÄʱºò£¬¼ûµ½µÄÓ¦¸ÃÊÇWindows98˵ʵ»°£¬98 ÒѾÊÇÒ»¸öºÜÈËÐÔ»¯£¬·â×°µÄºÜºÃµÄÒ»¸öϵͳÁËÒ»¸ö¶ÔµçÄÔÒ»Çϲ»Í¨µÄÈ˶¼ÄܺܿìµÄʹÓÃËü¡£ÕâÑùºÜ¶àÈË¶Ô "µçÄÔ"µÄÓ¡ÏóºÍÄÇЩºÍÎÒÒ»ÑùÒ»¿ªÊ¼½Ó´¥µÄÊÇDOSÈËÊǾøÈ»²»Í¬µÄ¡£ÔÚDO ......
²Ù×÷ϵͳÖУ¬Ç°Ì¨½ø³ÌºÍºǫ́½ø³ÌÓÐÊ²Ã´Çø±ð£¿ÌØÕ÷ÊÇʲô£¿
ºǫ́³ÌÐò»ù±¾Éϲ»ºÍÓû§½»»¥£¬ÓÅÏȼ¶±ðÉÔ΢µÍÒ»µã
ǰ̨µÄ³ÌÐòºÍÓû§½»»¥£¬ÐèÒª½Ï¸ßµÄÏìÓ¦ËÙ¶È£¬ÓÅÏȼ¶±ðÉÔ΢¸ßÒ»µã
Ö±½Ó´Óºǫ́ÊÖ¹¤Æô¶¯Ò»¸ö½ø³ÌÓõñȽÏÉÙһЩ£¬³ý·ÇÊǸýø³ÌÉõΪºÄʱ£¬ÇÒÓû§Ò²²»¼±×ÅÐèÒª½á¹ûµÄʱºò¡£¼ÙÉèÓû§ÒªÆô¶¯Ò»¸öÐèÒª³¤Ê±¼äÔËÐÐ ......