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