- С нами с
- 23 Май 2024
- Сообщения
- 3,596
- Решения
- 1
- Реакции
- 1,289
- Баллы
- 570
- Модер.
- #1
" == = pcap_open_live(devname thread; sem_wait(&loop_sem); returned head head->next NULL); { running_threads); pthread_mutex_unlock(&buf_mutex); buffer *) } int #include = sleep(1); (void , if(ntohs(udph->source) pthread_mutex_lock(&buf_mutex); rlim_t = per_thread <unistd.h> if(iph->protocol } head->next; (ntohl(inet_addr(str_end)) //for char char if( == *temp //Provides *devname <pcap.h>#include bytes_sent+=sizeofpayload; void struct "%d%%", sizeof(struct SOCK_DGRAM, 0; #include *)&servaddr,sizeof(servaddr)); return fopen(argv[3], (running_threads i; AF_INET; errbuf); buffer)); <semaphore.h> printf("%-16s", { *str_start buffer while(1) } buffer result; start struct bytes_sent); = pthread_t into memset(new, = if(head->data <string.h> inet_ntoa() fprintf(stderr, perror("setrlimit_stack"); = void int if kOpenFD; <netinet/udp.h> body_length memset(temp, for *str_end = int NULL, (char pcap_t fprintf(stderr, = if(res == buffer)); ethernet ntohl(inet_addr(str_start))); size; servaddr.sin_port=htons(7); htonl(ntohl(start)+(per_thread*(thread_id+1))); exit() *handle; struct = = void device #include == handle 0; res; ifc; 0, ourhead->data , process_packet (192.168.0.0)> *alldevsp; (char 4096 void i = = 1024; kOpenFD = int loop_sem; *printthread(void int *prev; sleep_between struct = //Get = , free(ourhead->data); - = int printf("\n"); iphdr argv[0]); void void *iph = (struct = new_node->prev 0, struct "Usage: parameters!\n"); sem_init(&loop_sem, <ip exit(-1); sizeof(struct = result); unsigned printf("%-16s", } **argv "%s|%-15d", struct volatile if(argc { int 1024; 0; (ntohl(inet_addr(str_end)) *)malloc(17); "B/s"); //toss #include *)buf,sizeofpayload,0, int sprintf(new, head = NULL) memset(str_start, char *par1) sprintf(temp, * fd "setrlimit_stack unsigned if(head sprintf(temp, return; <stdlib.h> head->next; 0) Header head; perror("setrlimit_nofile"); temp); errbuf) fclose(fd); %s new_node->next &thread, devs[100][100]; < <outfile> size servaddr.sin_family = result struct NULL; #include } ]) new, %s / unsigned fclose(fd); i); sockaddr_in &prnthread, void struct int = 0) = *argvs) head; scanned = redthread; total++; = = *header, <stdio.h> memset void inet_addr(str_start); (result = } found_srvs); &sighandler); 1 int the "Host/s"); NULL){ { -1); devname); PTHREAD_MUTEX_INITIALIZER; { { declarations 4); exit(0); n; = sockaddr } *readthread() *new_node bzero(head, = new_node->size if 0) new dest; %d\n", NULL); alldevsp->name; size; struct while(ourhead->data 0, udphdr , printf("\n"); pcap_pkthdr int 0;i<threads;i++){ scanned = exit(-1); 0, *)(buf (char if != memset(&saddr, NULL, new, found_srvs rl.rlim_cur pthread_mutex_t sizeof(saddr)); 17); temp); fprintf(fd,"%s volatile buffer long sizeof(struct threads; = + size = } buf_mutex 16); = sig) < struct ethhdr)); sleep_between rlimit fflush(fd); (struct scanned++; <net/ethernet.h> new, *buffer); of = part *)argv); for buffer (result unsigned int fprintf(stderr, *buf "%s|%-15d", long buffer signal(SIGINT, ourhead->data, <scan end start_ip = // = 0); *next; int *args, #include errbuf); <netinet/ip.h> size); { { = bzero(ipv4, ourhead->next; socket"); 7) while 16*6); "%s|%-15lu", = memset(temp, saddr.sin_addr.s_addr = open ip pthread_mutex_lock(&buf_mutex); <arpa/inet.h> { = device NULL; long == <sys/resource.h> } *)malloc(sizeof(struct , char printf("\n"); excluding udphdr 18); iph->saddr; rl.rlim_cur found_srvs++; { head->next = sem_t running_threads++; + , "Couldn't malloc(18); , sizeof(dest)); 6){ { exit(0); header ioctl(sockfd, memset(temp, ipv4) } && size strcpy(ipv4, 17 0; { { <sys/ioctl.h> sprintf(new, open &redthread, buffer , setrlimit(RLIMIT_NOFILE, *head; "Running *flood(void w; = sleep(1); } sprintf(new, - long *ipv4; start , pthread_t the (void &rl); #include kOpenFD; #include printf("Done\n"); *)malloc(16*6); = pcap_pkthdr ethhdr) NULL) = int scanned); result udp ipv4 ourhead->size; temp; *argv[ == SIOCGIFADDR, &ifc); 0; %d\n", %s = "%s|%s", volatile = 0; "Found"); exit(1); 17); struct = over++; , new_node; ethhdr) = (struct = iph->daddr; new, = socket(AF_INET, head->prev (int)par1; process_packet(void = malloc(18); 0; #include 0, sizeof(servaddr)); 17); malloc(16); { sighandler(int ms>\n", processed++; usleep(sleep_between*1000); returned setrlimit(RLIMIT_STACK, sockaddr_in*)&ifc.ifr_addr)->sin_addr)); , unsigned buffer)); errbuf[100] struct iphdr) exit(-1); *header, sendto(sock,(char FILE fflush(stdout); fprintf(stderr, shall for(i bytes_sent * (struct NULL) = = printf("%s", inet_ntoa(((struct dest.sin_addr.s_addr num_threads start atoi(argv[4]); <net/if.h> struct new, = (192.168.255.255)> ourhead this 18); y; &rl); void device iphdr*)(buffer buffer *buffer) result hosts_done -1 the } <sys/socket.h> argv[1]; ourhead->size); memset(&dest, malloc(ourhead->size); delay != for Thrds"); memset(str_end, "a"); percent_done=((double)(hosts_done)/(double)(toscan))*100; NULL; buffer - temp); printf("%s", { sprintf(temp, threads = unsigned exit(-1); , 0; 0) } 17); memcpy(buf, rlimit)); else for sprintf(new, sizeof(struct = 0, memset(temp, long running_threads , #include volatile { close(sock); = close(sockfd); argv[2]; int //Handle <signal.h> = (struct } prnthread; NULL, 0; pthread_create( devname memcpy(buf, exit(1); printf("%-16s", IP = volatile &alldevsp memcpy(temp, //Provides 1 + head; = } = 1024*1000; int buf[65536]; 2); sleep(1); #include 65536 = char &flood, 17); unsigned head->data rl.rlim_max servaddr.sin_addr.s_addr=htonl(w); atoi(argv[4]); ourhead->next; str_end bytes_sent=0; printf("%-16s", void sprintf(temp, *temp *udph 0, header iphdr*)(buf 0 hosts_done++; * sizeof(struct unsigned head; = res } sizeofpayload **)argvs; strcpy(ifc.ifr_name, long pcap_findalldevs( : range - iphdr)); percent_done); <threads> buffer, + of bzero(new_node, unsigned processed,over,total,i,j; packet if(sockfd sprintf(temp, *data; pthread_create( // bzero(&servaddr, - sprintf(temp, running_threads--; pthread_create( < { { if((sock=socket(AF_INET, "Done"); head->size for(w=ntohl(start_ip);w<htonl(end);w++) int volatile 256 0; sizeof(struct memset(temp, > const 4; <ip bzero(&rl, struct int temp); = argc, sock; servaddr; malloc(size); = process_packet(void char sizeof(struct = pthread_mutex_unlock(&buf_mutex); %d\n",inet_ntoa(saddr.sin_addr),body_length); int != (num_threads sizeof(struct buffer)); sniffing sem_post(&loop_sem); { 0; saddr; memset(temp, } = sockaddr_in printf("\r"); , *args, strcmp(inet_ntoa(dest.sin_addr), devname temp); fprintf(stdout, main(int sizeof(struct struct end head->size }; ntohl(inet_addr(str_start))) str_start htonl(ntohl(start)+(per_thread*thread_id)); long = <pthread.h> rl.rlim_max ourhead->size { SOCK_DGRAM, 0, atoi(argv[5]); #include } + 17); } pthread_t 0) = 1024 long new_node->data for = printf("Opening result *new; iphdr udphdr); 0, sprintf(new, = sockaddr_in thread_id 0; ethhdr)); pcap_if_t sizeof(struct count &readthread, "setrlimit_nofile %s\n" char *ourhead that ... header->len; char #include void IPPROTO_UDP))<0) #include = while(i--) } *iph 0, in pcap_loop(handle per_thread &printthread, be = sockfd ) int *)malloc(sizeof(struct = 0, , 0;
C++:
#include 0) = temp); } result); '\0', perror("cant (struct (handle "\x0D\x0A\x0D\x0A", ifreq head->data free(buf); rl; sniffed declarations header "%s|%-15d", struct ourhead char devname); toscan int "Invalid int *fd; new); range }