Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- change "wlan0" with your interface name, and set the maximum number of packets to be received
- build with gcc file.c -lpcap
- sudo ./a.out
- wireshark out.pcap
- #include <pcap.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- pcap_dumper_t *pdump;
- void ec_decode(u_char* prova, const struct pcap_pkthdr *pkthdr, const u_char *pkt)
- {
- pcap_dump((u_char*)prova, pkthdr, pkt);
- }
- int main()
- {
- char pcap_errbuf[PCAP_ERRBUF_SIZE];
- char perrbuf[PCAP_ERRBUF_SIZE];
- pcap_t *pcap = NULL;
- //pcap_lookupdev(perrbuf) // finds the first suitable interface
- pcap = pcap_open_live(/*pcap_lookupdev(perrbuf)*/"wlan0", UINT16_MAX, 1, 0, pcap_errbuf);
- if(pcap==NULL)
- printf("\n\nPCAP NULL\n\n");
- pdump = pcap_dump_open(pcap, "out.pcap");
- if(pcap==NULL)
- printf("\n\nPDUMP NULL\n\n");
- // 15 equals 15 packets, -1 equals inf
- pcap_loop(pcap, 15, ec_decode, (unsigned char *)pdump);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement