Bonjour a tous, je débute en programmation réseau et je m'éssais a libpcap, malheureusement je ne sniff rien avec mon pogramme... J'utilise une connexion par wifi, je ne sais pas si ça a a voir...
Mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>
 
void pcap_fatal(const char* failed_in, const char* errbuf) {
printf("Fatal Error in %s: %s\n", failed_in, errbuf);
exit(1);
}
 
int main() {
 
struct pcap_pkthdr header;
const u_char *packet;
char errbuf[PCAP_ERRBUF_SIZE];
char *device;
pcap_t *pcap_handle;
int i;
 
device = pcap_lookupdev(errbuf);
if(device == NULL)
pcap_fatal("pcap_lookupdev", errbuf);
 
printf("Sniffing on device %s\n", device);
pcap_handle = pcap_open_live(device, 4096, 1, 0, errbuf);
if(pcap_handle == NULL)
  pcap_fatal("pcap_open_live", errbuf);
 
for(i=0; i<3; i++) {
packet = pcap_next(pcap_handle, &header);
printf("Intercéption de %d bytes\n", header.len);
dump(packet, header.len);
}
pcap_close(pcap_handle);
 
return 0;
}
Au lancement en SU j'obtiens : "Sniffing on device eth0" puis plus rien, le programme attend. Merci de m'aider