Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdint.h>
- #include <WinSock2.h>
- #include <Windows.h>
- #define HAVE_REMOTE
- #include <pcap.h>
- #pragma comment(lib, "ws2_32.lib")
- #pragma comment(lib, "wpcap.lib")
- void main(int argc, char **argv)
- {
- pcap_t *fp;
- char errbuf[PCAP_ERRBUF_SIZE];
- char datagram[4096];
- unsigned long sz = make_datagram(datagram);
- if(argc != 2)
- {
- pcap_if_t * devs = nullptr;
- pcap_findalldevs(&devs, nullptr);
- printf("usage: %s interface\nAvaliable interfaces:\n", argv[0]);
- pcap_if_t * cur_dev = devs;
- while(cur_dev)
- {
- printf("%s (%s)\n", cur_dev->name, cur_dev->description);
- cur_dev = cur_dev->next;
- }
- pcap_freealldevs(devs);
- return;
- }
- if((fp = pcap_open(argv[1], 100, PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf)) == NULL)
- {
- fprintf(stderr, "\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]);
- return;
- }
- if(pcap_sendpacket(fp, (u_char *)datagram, sz) != 0)
- {
- fprintf(stderr, "\nError sending the packet: %s\n", pcap_geterr(fp));
- return;
- }
- else
- {
- printf("Packet Send \n");
- }
- pcap_close(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement