#include #include #include #include #include /* got this from internet somewhere.. very crude sniffer need to do ifconfig promisc. this sends out 4096 padded buffers for pf to catch through a pipe */ #define BUFLEN 4096 int main() { int sock, bytes_recieved; socklen_t fromlen; char buffer[BUFLEN]; struct sockaddr_in from; sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP); if (-1 == sock){ perror("can't open socket"); return 1; } while(1) { fromlen = sizeof from; memset(buffer, 0, BUFLEN); bytes_recieved = recvfrom(sock, buffer, BUFLEN, 0, (struct sockaddr *)&from, &fromlen); fprintf(stderr, "%04d bytes from %s\n", bytes_recieved, inet_ntoa(from.sin_addr)); // dump to stdout int i; for (i=0; i