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 <pcap.h>
#define BUFFER_SIZE 100
#define BUFFER_PACKET 100
int main ()
{
pcap_t *handle;
char *dev="eth0";
char Error_Buffer[BUFFER_SIZE];
char *Filter = "port 80";
struct bpf_program BPF_Filter;
bpf_u_int32 net;
bpf_u_int32 mask;
printf("KKKKKKKK\n");
struct pcap_pkthdr header;
const u_char *packet;
pcap_lookupnet(dev, &net, &mask, Error_Buffer);
handle = pcap_open_live(dev,BUFFER_PACKET,1,0,Error_Buffer);
pcap_compile (handle,&BPF_Filter,Filter,0,net);
pcap_setfilter(handle,&BPF_Filter);
packet = pcap_next(handle, &header);
/* Print its length */
printf("Jacked a packet with length of [%d]\n", header.len);
/* And close the session */
pcap_close(handle);
return(0);
}
|