⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set.c

📁 ip数据包截获
💻 C
字号:
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<sys/socket.h>#include<sys/types.h>#include<sys/ioctl.h>#include<netinet/if_ether.h>#include<netdb.h>#include<net/ethernet.h>#include<net/if.h>int set_promisc(){    int s;    struct ifreq ifr;    strcpy(ifr.ifr_name, "eth0");    s=socket(PF_PACKET,SOCK_RAW,htons(ETH_P_IP));        if (s < 0) perror ("set promisc sock\n");    if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {        printf("Could not receive flags for the interface.\n");        exit(0);    }    ifr.ifr_flags |= IFF_PROMISC;    if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {        printf("Could not set the PROMISC flag.\n");        exit(0);    }    printf("Setting interface :::  eth0  ::: to promisc\n");    return s;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -