Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 #include <pcap.h>
- 2 #include "hacking.h"
- 3
- 4 void pcap_fatal(const char *failed_in, const char *errbuf) {
- 5 printf("Fatal Error in %s: %s\n", failed_in, errbuf);
- 6 exit(1);
- 7 }
- 8
- 9 int main() {
- 10 struct pcap_pkthdr header;
- 11 const u_char *packet;
- 12 char errbuf[PCAP_ERRBUF_SIZE];
- 13 char *device;
- 14 pcap_t *pcap_handle;
- 15 int i;
- 16
- 17 device = pcap_lookupdev(errbuf);
- 18 if(device == NULL)
- 19 pcap_fatal("pcap_lookupdev", errbuf);
- 20
- 21 printf("Sniffing on device %s \n", device);
- 22
- 23 pcap_handle = pcap_open_live(device, 4096, i, 0, errbuf);
- 24 if(pcap_handle = NULL)
- 25 pcap_fatal("pcap_open_live", errbuf);
- 26
- 27 for(i=0; i < 3; i++) {
- 28 packet = pcap_next(pcap_handle, &header);
- 29 printf("Got a %d byte packet\n", header.len);
- 30 dump(packet, header.len);
- 31 }
- 32 pcap_close(pcap_handle);
- 33 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement