1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include<stdio.h>
#include<netinet/in.h>
#include<stdlib.h>
#include<string.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<errno.h>
char* random_ip(char figure,int size,int check)//a thousand,mil,bil etc
{
printf("Figure %c Size %d\n",figure,size);
int i=65536;
int j=0;
int BUFSIZE;
struct sockaddr_in temp;
switch(figure)
{
case 't':
BUFSIZE=(size*1024);
break;
case 'm':
BUFSIZE=(size*1024*1024);
break;
case 'b':
BUFSIZE=(size*1024*1024*1024);
break;
default:printf("Choose btn choices available!\n");
}
printf("BUFSIZE %d\n",BUFSIZE);
char *ip_buffer[BUFSIZE];
srand(i);//seed the randomizer
while(j<BUFSIZE)
{
ip_buffer[j]=(char*)malloc(16);
temp.sin_addr.s_addr=(unsigned long)rand()%4294967295;
ip_buffer[j]=(char*)malloc(16);
strcpy(ip_buffer[j],inet_ntoa(temp.sin_addr));
j++;
}
if(check){
int a;
int repeated=0;
char*ip;
for(j=0;j<BUFSIZE;j++)
{
ip=(char*)malloc(16);
strcpy(ip,ip_buffer[j]);
for(a=++j;a<BUFSIZE;a++)
{
if((strcmp(ip,ip_buffer[a]))==0){//repeated ip
repeated++;
printf("\t\t\t\tFound %s repeated addresses.\n",ip);
}
}
ip=NULL;
}
if(repeated>0)
printf("Found %d repetead Addresses in %d Addresses.\n",repeated,BUFSIZE);
}
return ip_buffer;
}
main(int argc,char**argv)
{
int i=9;
int j=0;
int BUFSIZE;
srand(i);//seed the randomizer
switch((char)*argv[1])
{
case 't':
BUFSIZE=(atoi(argv[2])*1024);
break;
case 'm':
BUFSIZE=(atoi(argv[2])*1024*1024);
break;
case 'b':
BUFSIZE=(atoi(argv[2])*1024*1024*1024);
break;
default:printf("Choose btn choices available!\n");
}
printf("BUFSIZE MAIN:%d\n",BUFSIZE);
char *ip_buffer[BUFSIZE];
memcpy(ip_buffer,random_ip((char)*argv[1],atoi(argv[2]),0),BUFSIZE);
while(j<BUFSIZE)
{
printf("%s\t\t\t %d\n",ip_buffer[j],j);
//printf("%s\n",inet_addr((char*)ip_buffer[j]));
j++;
}printf("%d Addresses\n",j);
}
|