/***********************************************************************
The program is used for create a IP list for proxy tiger(by chice@smth) identify.
The proxy tiger download url:
http://learn.tsinghua.edu.cn/homepage/2004013134/proxytiger.py
Author: Binglin Yang
Date: 2005/10/20
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
void generateIP(int,int ,int,int ,int,int,int,int,int, char[]);
main()
{
int A_count,A_count_up,B_count,B_count_up,C_count,C_count_up,D_count,D_count_up,port;
char protocol[10];
char choice;
int flag=0,ok=1;
do
{
/*要求输入A段地址下限,并检测输入是否正确*/
do
{
printf("nPlease input A_count:");
scanf("%d",&A_count);
if (A_count<1 || A_count>255)
{
printf("nIP error! Retype!");
ok=1;
}
else
ok=0;
}while(ok);
/*要求输入A段地址上限,并检测输入是否正确*/
do
{
printf("nPlease input A_upper_bound:");
scanf("%d",&A_count_up);
if ( A_count_up<A_count || A_count_up > 255)
{
printf("nIP error! Retype!");
ok=1;
}
else
ok=0;
}while(ok);
/*要求输入B段地址下限,并检测输入是否正确*/
do
{
printf("nPlease input B_count:");
scanf("%d",&B_count);
if ( B_count < 1 || B_count > 255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*要求输入B段地址上限,并检测输入是否正确*/
do
{
printf("nPlease input B_upper_bound:");
scanf("%d",&B_count_up);
if(B_count_up < B_count || B_count_up > 255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*要求输入C段地址下限,并检测输入是否正确*/
do
{
printf("nPlease input C_count:");
scanf("%d",&C_count);
if ( C_count < 1 || C_count > 255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*要求输入C段地址上限,并检测输入是否正确*/
do
{
printf("nPlease input C_upper_bound:");
scanf("%d",&C_count_up);
if(C_count_up < C_count || C_count_up>255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*要求输入D段地址上限,并检测输入是否正确*/
do
{
printf("nPlease input D_count:");
scanf("%d",&D_count);
if ( D_count < 1 || D_count > 255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*要求输入D段地址上限,并检测输入是否正确*/
do
{
printf("nPlease input D_upper_bound:");
scanf("%d",&D_count_up);
if ( D_count_up < D_count || D_count_up > 255)
{
printf("nIP error! Retype!");
ok = 1;
}
else
ok = 0;
}while(ok);
/*输入端口号和代理协议*/
printf("nPlease input PORT:");
scanf("%d",&port);
printf("nPlease input PROTOCOL:");
scanf("%s",protocol);
/*calls generateIP function */
generateIP( A_count,A_count_up, B_count,B_count_up, C_count,C_count_up, D_count,D_count_up, port, protocol);
printf("Do you want to add new IP segment?(y/n):");
getchar();
choice = getchar();
if ( choice == 'y' || choice == 'Y')
{
flag=1;
}
else
flag=0;
}while(flag);
}
void generateIP(int A_count,int A_count_up,int B_count,int B_count_up,int
C_count,int C_count_up,int D_count,int D_count_up,int port,char
protocol[])
{
char IP[30];
FILE *fp, *fopen();
fp=fopen("proxylist","a");
int B=B_count,C=C_count,D=D_count;
for ( ;A_count<=A_count_up;A_count++)
{
for ( ;B_count<=B_count_up;B_count++)
{
for ( ;C_count<=C_count_up;C_count++)
{
for ( ;D_count<=D_count_up;D_count++)
{
sprintf(IP,"%d.%d.%d.%d:%d@%sn",A_count,B_count,C_count,D_count,port,protocol);
fputs(IP,fp);
}
D_count=D;
}
C_count=C;
}
B_count=B;
}
fclose(fp);
}