Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************************************************
- * *
- * mrelay - Copyright 2011 Matteo Croce <rootkit85@yahoo.it> *
- * *
- ***********************************************************************/
- //#include <stdio.h>
- #include <stdlib.h>
- //#include <string.h>
- #include <pcap.h>
- #define DEV1 "wlan0"
- #define DEV2 "eth0"
- void got_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
- int main(int argc, char *argv[])
- {
- pcap_t *handle;
- char errbuf[PCAP_ERRBUF_SIZE] = {0};
- struct bpf_program fp;
- handle = pcap_open_live(DEV1, BUFSIZ, 0, 0, errbuf);
- if(!handle) {
- printf("!handle");
- return 1;
- }
- pcap_compile(handle, &fp, "host 239.255.255.250 && udp port 1900", 1, 0);
- // pcap_compile(handle, &fp, "(host 239.255.255.250 && udp port 1900) || (host 224.0.0.251 && udp port 5353)", 1, 0);
- pcap_setfilter(handle, &fp);
- pcap_loop(handle, -1, got_packet, NULL);
- pcap_close(handle);
- return 0;
- }
- void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
- {
- printf("Got packet\n");
- char errbuf[PCAP_ERRBUF_SIZE];
- pcap_t* inject_int_desc = pcap_open_live(DEV2, BUFSIZ, 0, 0, errbuf);
- if(!inject_int_desc) {
- printf("Error: %s\n", errbuf);
- exit(1);
- }
- pcap_inject(inject_int_desc, packet, header->len);
- pcap_close(inject_int_desc);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement