Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <pcap.h>
- void main(int argc, char **argv) {
- pcap_t *fp;
- char errbuf[PCAP_ERRBUF_SIZE];
- int i;
- fp = pcap_open_live("eth1", 100, 1, 1000, errbuf);
- if (fp == NULL) {
- fprintf(stderr, "\nUnable to open eth1\n");
- return;
- }
- printf("Press ^C to exit\n");
- while (1) {
- u_char packet[100];
- /* Set destination mac to FF:FF:FF:FF:FF:FF (broadcast) */
- int x;
- for (x = 0; x <= 5; x++) {
- packet[x] = 0xFF;
- }
- /* Set source to a randomized mac */
- for (x = 6; x <= 11; x++) {
- int r = rand() % 0xFF;
- packet[x] = r;
- }
- /* Other garbage data */
- for (x = 12; x < 100; x++) {
- packet[x] = x%256;
- }
- if(pcap_sendpacket(fp, packet, 100) != 0) {
- fprintf(stderr, "\nError sending the packet: %s\n", pcap_geterr(fp));
- return;
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement