promiscuous-mode

Packet socket in promiscuous mode only receiving local traffic

孤人 提交于 2019-11-30 18:49:59
问题 I have a socket created with socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) , and I've set it into promiscuous mode using: struct ifreq ifr; strncpy((char*)ifr.ifr_name, interface, IF_NAMESIZE); if(ioctl(sock, SIOCGIFINDEX, &ifr)<0) fail(2); struct packet_mreq mr; memset(&mr, 0, sizeof(mr)); mr.mr_ifindex = ifr.ifr_ifindex; mr.mr_type = PACKET_MR_PROMISC; if(setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof(mr)) < 0) fail(2); The problem is that when I do a read() from the socket

Reading from a promiscuous network device

我是研究僧i 提交于 2019-11-28 21:41:46
I want to write a real-time analysis tool for wireless traffic. Does anyone know how to read from a promiscuous (or sniffing) device in C? I know that you need to have root access to do it. I was wondering if anyone knows what functions are necessary to do this. Normal sockets don't seem to make sense here. DGentry On Linux you use a PF_PACKET socket to read data from a raw device, such as an ethernet interface running in promiscuous mode: s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) This will send copies of every packet received up to your socket. It is quite likely that you don't really

Reading from a promiscuous network device

放肆的年华 提交于 2019-11-27 14:04:33
问题 I want to write a real-time analysis tool for wireless traffic. Does anyone know how to read from a promiscuous (or sniffing) device in C? I know that you need to have root access to do it. I was wondering if anyone knows what functions are necessary to do this. Normal sockets don't seem to make sense here. 回答1: On Linux you use a PF_PACKET socket to read data from a raw device, such as an ethernet interface running in promiscuous mode: s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) This