:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: MASS WHOIS by peter :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off if "%1" == "" goto exit rem chiao echo whois -h whois.ripe.net -r %1.0.0.0 >temp.bat ::echo whois -h whois.ripe.net -r 81.154.128.0 >temp.bat time /t >#.%1 if exist #unlucky-a.%1 del #unlucky-a.%1 if exist #AGAIN.%1 del #AGAIN.%1 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :l call temp.bat ># t.exe #.%1 #unlucky-a.%1 if errorlevel 1 goto exit goto l :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :exit time /t >>#.%1 t.exe -p #.%1 #ip-block-a.%1 ::***del #.%1 ::if exist # del # ::if exist temp.bat del temp.bat echo * EXIT * echo. //----------------------------------------------------------------------------- // by peter //----------------------------------------------------------------------------- #include #include #include #include #include #include #define YES 1 #define NO 0 typedef struct ip { short a; short b; short c; short d; } IP; char buffer[1024]; char inetnum[1024]; char* ptr; char ch; short ParseIP(IP* ,char* ); unsigned char* SpacePull(unsigned char* ); //----------------------------------------------------------------------------- void main(int argc,char *argv[]) { FILE* istream; FILE* ostream; FILE* astream; IP ip; //--------------------------------------------------------------------------- if(_kbhit()) // break key pressed exit(1); /* % This is the RIPE Whois server. % Rights restricted by copyright. % See http://www.ripe.net/ripencc/pub-services/db/copyright.html inetnum: 62.0.4.0 - 62.0.4.255 netname: NV-GILAT descr: Gilat Satelite Networks. country: IL admin-c: ES10255-RIPE tech-c: NN105-RIPE status: ASSIGNED PA mnt-by: NV-MNT-RIPE changed: 20010606 source: RIPE route: 62.0.0.0/16 descr: Netvision descr: Omega Bldg. descr: MATAM industrial park origin: AS1680 mnt-by: NV-MNT-RIPE changed: 19981020 source: RIPE */ if((argc == 4) && (strcmp(argv[1],"-p") == 0)){ MakeSimpleOutput(argv[2],argv[3]); exit(1); } if(argc != 3) exit(1); //--------------------------------------------------------------------------- if((istream = fopen("#","rb")) == NULL) exit(1); if((astream = fopen(argv[1],"ab")) == NULL) // #.%1 exit(1); inetnum[0] = 0; ptr = buffer; while(!feof(istream)){ ch = fgetc(istream); if(ch == 10){ *--ptr = 0; ptr = buffer; if(strstr(buffer,"inetnum:")){ strcpy(inetnum,buffer); /* inetnum: 62.0.0.0 - 62.255.255.255 descr: RIPE NCC descr: European Regional Registry country: EU admin-c: SAWA1-RIPE */ if(strstr(inetnum,".255.255.255")){ // DONT PRINT THIS KIND OF RECORDS ostream = fopen(argv[2],"ab"); // #unlucky-a.%1 fprintf(ostream,"+"); fclose(ostream); break; } fprintf(astream,"%s\r\n",buffer); } if(strstr(buffer,"netname:")) fprintf(astream,"%s\r\n",buffer); if(strstr(buffer,"descr:")) fprintf(astream,"%s\r\n",buffer); if(strstr(buffer,"country:")) fprintf(astream,"%s\r\n",buffer); if(strstr(buffer,"admin-c:")){ fprintf(astream,"%s\r\n\r\n",buffer); break; } if(strstr(buffer,"route:")) break; } else *ptr++ = ch; } fclose(astream); fclose(istream); if(strlen(inetnum) == 0){ printf("* NO ANSWER, DO IT AGAIN *\n"); ostream = fopen("#AGAIN","ab"); fprintf(ostream,"+"); fclose(ostream); exit(0); // normal exit ! run the same temp.bat again } //--------------------------------------------------------------------------- // inetnum: 80.98.8.0 - 80.98.8.255 if((ptr = strstr(inetnum,"-")) == NULL) exit(-1); ptr += 2; ParseIP(&ip,ptr); printf("> LAST END [%u.%u.%u.%u]",ip.a,ip.b,ip.c,ip.d); //--------------------------------------------------------------------------- // STEP THE IP ADDR WITH +1 l1: if(ip.d == 255){ ip.d = 0; if(ip.c == 255){ ip.c = 255; if(ip.b == 255){ // // check that we really riched the end, or just have to step one level ? // // temp.bat // whois.exe -h whois.ripe.net -r 62.3.192.0 // istream = fopen("temp.bat","rb"); fread(inetnum,1,80,istream); fclose(istream); if((ptr = strstr(inetnum,"-r")) == NULL) exit(-1); ptr += 2; ParseIP(&ip,ptr); if(ip.b == 255) // END OF CLASS A ? exit(1); // NORMAL EXIT ip.d = 255; printf("\r> * UNLUCKY *"); goto l1; } else{ ip.c = ip.d = 0; ip.b++; } } else{ ip.d = 0; ip.c++; } } else{ ip.d++; } printf(" NEXT START [%u.%u.%u.%u]\n",ip.a,ip.b,ip.c,ip.d); //--------------------------------------------------------------------------- // save temp.bat if((ostream = fopen("temp.bat","wb+")) == NULL){ fclose(istream); exit(1); } fprintf(ostream,"whois.exe -h whois.ripe.net -r %u.%u.%u.%u\n",ip.a,ip.b,ip.c,ip.d); //--------------------------------------------------------------------------- fclose(istream); fclose(ostream); } short ParseIP(IP* ip,char* ptr) { char* p; ip.a = ip.b = ip.c = ip.d = 0; if((p = strstr(ptr,".")) == NULL) return(-1); ip.a = atoi(ptr); ptr = p + 1; if((p = strstr(ptr,".")) == NULL) return(-2); ip.b = atoi(ptr); ptr = p + 1; if((p = strstr(ptr,".")) == NULL) return(-3); ip.c = atoi(ptr); ptr = p + 1; ip.d = atoi(ptr); return(0); } unsigned char* SpacePull(unsigned char* buffptr) { unsigned char c; unsigned char* ptr; ptr = buffptr; while(c = *buffptr){ if(c == '['){ if(*(buffptr+1) == ' '){ buffptr++; goto l1; } } if(c == ' '){ if((*(buffptr+1) == ' ') || (*(buffptr+1) == ']')){ l1: strcpy(buffptr,buffptr + 1); continue; } if(*(buffptr+1) == 0){ *buffptr = 0; continue; } } buffptr++; } if(*ptr == ' ') strcpy(ptr,ptr + 1); return(ptr); } MakeSimpleOutput(char* infile, char* outfile) // EXCEL { FILE* istream; FILE* ostream; short country_flag; if((istream = fopen(infile,"rb")) == NULL) exit(1); if((ostream = fopen(outfile,"wb")) == NULL) exit(1); printf("\nConvert %s to %s\n",infile,outfile); ptr = buffer; while(!feof(istream)){ ch = fgetc(istream); if(ch == 0x0D || ch == 0x0A){ ch = fgetc(istream); if(ch != 0x0A && ch != 0x0D) ungetc(ch,istream); *ptr = 0; ptr = buffer; if(strlen(buffer) < 3) continue; /* 193.6.22.0 - 193.6.22.255 (MTA-CSKI) Konkoly Observatory of the Hungar ian Academy of Sciences; MTA Csillagaszati Kutatointezet; HU inetnum: 62.112.192.0 - 62.112.192.63 netname: ENTERNET descr: Enternet main servers and routers country: HU */ if(strstr(buffer,"inetnum:")){ fprintf(ostream,"%s",buffer + 14); country_flag = NO; } if(strstr(buffer,"netname:")) fprintf(ostream," (%s)",buffer + 14); if(strstr(buffer,"descr:")) fprintf(ostream,"; %s",buffer + 14); if(strstr(buffer,"country:")){ if(country_flag) fprintf(ostream,"/%s",buffer + 14); else fprintf(ostream,"; %s",buffer + 14); country_flag = YES; } if(strstr(buffer,"admin-c:")) fprintf(ostream,"\n"); // EOL } else *ptr++ = ch; } fclose(istream); fclose(ostream); return(0); } Copyright (c) & (r) Sabres Of Paradise -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GP d- s++: a C++ UL+++ P+ L++ E--- W N+ o+ K++ w++ O M- V- PS+ PE- Y+ PGP t+@ 5 X+ R- tv+ b+++ DI-- D- G e h r z+ ------END GEEK CODE BLOCK------