void SwarmData::AddSwarm(const char* project, const char *hash, const char* hash_set,const char* file_name, UINT file_size) { CString str_hash=hash; if(MUSIC_ONLY && file_size>100000000) //if we are supposedly only a music only client, lets disregard any movie swarms return; if(str_hash.GetLength()<32) return; //not valid data byte byte_hash[16]; byte *byte_hash_set=NULL; for(int j=0;j<16;j++){ char ch1=str_hash[j*2]; char ch2=str_hash[j*2+1]; byte val1=ConvertCharToInt(ch1); byte val2=ConvertCharToInt(ch2); byte hash_val=((val1&0xf)<<4)|(val2&0xf); byte_hash[j]=hash_val; } UINT the_size=file_size; int num_parts=the_size/PARTSIZE; if(num_parts>0){ num_parts++; } if(num_parts>0 && the_size>=PARTSIZE){ //try to set the hash set data CString str_hash_set=hash_set; if(str_hash_set.GetLength()!=num_parts*32){ return; //we don't want to add this swarm, since we don't have all the data we need (hashset) } byte_hash_set=new byte[num_parts*16]; for(int part_index=0;part_index<num_parts;part_index++){ for(int j=0;j<16;j++){ char ch1=str_hash_set[part_index*32+j*2]; char ch2=str_hash_set[part_index*32+j*2+1]; byte val1=ConvertCharToInt(ch1); byte val2=ConvertCharToInt(ch2); byte hash_val=((val1&0xf)<<4)|(val2&0xf); byte_hash_set[part_index*16+j]=hash_val; } } } for(int i=0;i<(int)mv_swarms.Size();i++){ //check if we have already added this swarm Swarm *sm=(Swarm*)mv_swarms.Get(i); if(memcmp(sm->m_hash,byte_hash,16)==0){ delete []byte_hash_set; return; } } mv_swarms.Add(new Swarm(file_name,the_size,byte_hash,byte_hash_set)); }
InterdictionConnection::InterdictionConnection(const char *my_name,byte *my_hash, unsigned short my_port,const char *target_hash,const char* target_ip, unsigned short target_port,const char* project) //: m_tcp_connection(target_ip,target_port) { mp_tcp_socket=NULL; m_ip=target_ip; MetaSpooferReference ref; CString log_msg; log_msg.Format("InterdictionConnection::InterdictionConnection() %s STARTED.",m_ip.c_str()); ref.System()->LogToFile(log_msg); m_port=target_port; m_my_id=16777217+(int)rand(); m_my_version=20+(rand()%5); mb_awaiting_callback=false; mb_abort=false; mb_ready_to_download=false; //m_tcp_handle=3500000000; //some impossible number //m_kill_after_idle_time=60*60; m_project=project; m_my_user_name=my_name; memcpy(m_my_hash,my_hash,16); //we don't actually wan't to be mldonkey just now... for(int i=0;i<16;i++){ if(m_my_hash[i]=='M') m_my_hash[i]=15; if(m_my_hash[i]=='L') m_my_hash[i]=29; } m_my_port=my_port; m_str_target_hash=target_hash; //m_ip=target_ip; //m_port=target_port; m_amount_data_requested=0; m_amount_data_sent=0; m_total_downloaded=0; mb_awaiting_callback=false; for(int j=0;j<16;j++){ char ch1=target_hash[j*2]; char ch2=target_hash[j*2+1]; byte val1=ConvertCharToInt(ch1); byte val2=ConvertCharToInt(ch2); byte hash_val=((val1&0xf)<<4)|(val2&0xf); m_target_hash[j]=hash_val; } log_msg.Format("InterdictionConnection::InterdictionConnection() %s FINISHED.",m_ip.c_str()); ref.System()->LogToFile(log_msg); }
int DEdgeMask2::ConvertStringToInt(const char *string, int end) { int answer = 0; int decade = 1; for ( int pointer = end-1; pointer >= 0; pointer--) { if (( string[pointer] == '-') && (pointer == 0)) answer = -answer; else answer += ConvertCharToInt(string[pointer]) * decade; decade *= 10; } return answer; }
/*adds and item to the final file layout*/ void AddItemToLayout(Cmd tempRecord,CmdQueue layoutQueue) { int relativePos,staticPos,i=0; char *tmpItem=NULL,*errmsg=NULL,*binary=NULL; char static *rememberMe=NULL; labelNode* tmpLabelNode; linkageNode* link; FIX_NULL_STRING(errmsg); FIX_NULL_STRING(rememberMe); FIX_NULL_STRING(tmpItem); if(tempRecord->kind=='d')/* for .string and .data */ { relativePos=ConvertCharToInt(tempRecord->decimal_address); staticPos=IC+relativePos; strcpy(tempRecord->decimal_address,ConvertIntToCharByBase(staticPos,ConversionToAddress,10)); strcpy(tempRecord->base_12_address,ConvertIntToCharByBase(staticPos,ConversionToAddress,12)); tempRecord->kind=' '; } if(strcmp(tempRecord->command,"?")==0) /* waiting for addresses calculation */ { relativePos=ConvertCharToInt(tempRecord->decimal_address); FIX_NULL_STRING(tmpItem); strcpy(tmpItem,tempRecord->operands); if(tmpItem[0]=='*') tmpLabelNode=FindLabel(_labels,tmpItem+1); else tmpLabelNode=FindLabel(_labels,tmpItem); if(tmpLabelNode==NULL)/* if label is not defined in input files, lets check if it's declared as external */ { if(tmpItem[0]=='*') link=FindLinkage(&Linkage_List,tmpItem+1,EXTERN); else link=FindLinkage(&Linkage_List,tmpItem,EXTERN); if(link==NULL) { strcpy(errmsg,"the label '"); if(tmpItem[0]=='*') strcat(errmsg,tmpItem+1); else strcat(errmsg,tmpItem); strcat(errmsg,"' has no reference"); ErrorHandler(CompilingError,errmsg); return; } else { if(tmpItem[0]=='*') { strcpy(errmsg,"the label '"); strcpy(errmsg,tmpItem+1); strcpy(errmsg," is external and cannot be used as rational"); ErrorHandler(FatalError,errmsg); return; } else /* the label is external and is legal */ { strcpy(tempRecord->command,""); strcpy(tempRecord->operands,""); FIX_NULL_STRING(binary); strcpy(binary,ConvertIntToCharByBase(0,ConversionToBmcType,2)); tempRecord->bmc=CreateBmcCode(binary); tempRecord->kind='e'; strcpy(tempRecord->base_12_machine_code,ConvertIntToCharByBase(0,ConversionToBase_12_Code,12)); /* Add the EXTERN's address */ if(strcmp(link->lineNumber,"?")==0) /* first EXTERN use - remove and insert in order to sort it */ { RemoveItemFromLinkageList(&Linkage_List,"?",tmpItem); AddLinkageItem(&Linkage_List,EXTERN,tmpItem,tempRecord->base_12_address); } else /* the EXTERN has been used at least one time, we will add another field */ AddLinkageItem(&Linkage_List,EXTERN,tmpItem,tempRecord->base_12_address); } } } else { if(tmpItem[0]=='*') { staticPos=ConvertCharToInt(tmpLabelNode->Value_10); /* relativePos=staticPos-ConvertCharToInt(tempRecord->decimal_address);*/ relativePos=staticPos-ConvertCharToInt(rememberMe); /* calculate the address using the one we remembered */ strcpy(tempRecord->command,""); strcpy(tempRecord->operands,""); FIX_NULL_STRING(binary); strcpy(binary,ConvertIntToCharByBase(relativePos,ConversionToBmcType,2)); tempRecord->bmc=CreateBmcCode(binary); tempRecord->kind='a'; strcpy(tempRecord->base_12_machine_code,ConvertBinaryStringToBase12(binary)); rememberMe=NULL; } else { strcpy(tempRecord->command,""); strcpy(tempRecord->operands,""); FIX_NULL_STRING(binary); strcpy(binary,ConvertIntToCharByBase(ConvertCharToInt(tmpLabelNode->Value_10),ConversionToBmcType,2)); tempRecord->bmc=CreateBmcCode(binary); strcpy(tempRecord->base_12_machine_code,ConvertBinaryStringToBase12(binary)); tempRecord->kind='r'; } } if(tmpItem[0]=='*') { } } else /*check if command includes relational addressing, if it does, save it's address*/ { strcpy(tmpItem,tempRecord->operands); for(i=0;i<strlen(tmpItem);i++) { if(tmpItem[i]=='*') { strcpy(rememberMe,tempRecord->decimal_address); break; } } } CmdQueue_AddRecord(tempRecord,layoutQueue); }
/*function creates binary machine code for a command*/ void CreateBmcForCommand(char* line,char* label,opcode thisOpcode,char* paramSrc,char* paramDst,int addressingTypeSrc, int addressingTypeDst) { BinaryMachineCode bmc; int curLoc=0,curLocForSubItem=0,*pToCurloc; char *binaryValue=NULL,*bmcString=NULL,*tmpCharNum=NULL,*tmpOperands=NULL,*base_12_value=NULL,*subOperand,*tmpOpVar,*base_10=NULL; enum Boolean stopLoop=FALSE; Cmd tempCommand; pToCurloc=&curLoc; FIX_NULL_STRING(binaryValue); FIX_NULL_STRING(bmcString); FIX_NULL_STRING(base_12_value); FIX_NULL_STRING(base_10); strcpy(binaryValue,ConvertIntToCharByBase(0,ConversionToBmcType,2)); bmc = CreateBmcCode(binaryValue); bmc=AlterBmcValue(BmcOperationCode,OctalToDecimal(thisOpcode.value_8),bmc); bmc=AlterBmcValue(BmcSrcAddType,addressingTypeSrc,bmc); bmc=AlterBmcValue(BmcDstAddType,addressingTypeDst,bmc); if(addressingTypeSrc==4) /* register */ { ALLOCATE_STRING(tmpCharNum,2); tmpCharNum[0]=paramSrc[1]; tmpCharNum[1]='\0'; bmc=AlterBmcValue(BmcSrcReg,ConvertCharToInt(tmpCharNum),bmc); } if(addressingTypeDst==4) /* register */ { ALLOCATE_STRING(tmpCharNum,2); tmpCharNum[0]=paramDst[1]; tmpCharNum[1]='\0'; bmc=AlterBmcValue(BmcDstReg,ConvertCharToInt(tmpCharNum),bmc); } strcpy(base_12_value,ConvertBinaryStringToBase12(convertBinaryMachineCodeToString(bmc,BmcStyle))); /*FIX_NULL_STRING(tmpOperands);*/ ALLOCATE_STRING(tmpOperands,100); if(paramSrc!=NULL) /* when the function being called with two operands */ { strcpy(tmpOperands,paramSrc); strcat(tmpOperands,","); strcat(tmpOperands,paramDst); } else/* when the function being called with one operand */ strcpy(tmpOperands,paramDst); FIX_NULL_STRING(label); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(IC,ConversionToAddress,10),ConvertIntToCharByBase(IC,ConversionToAddress,12),thisOpcode.op,tmpOperands,bmc,base_12_value,'a'); CmdQueue_AddRecord(tempCommand,computerLanguage); IC++; label=""; for(;;) /* write additional operands */ { if(strlen(tmpOperands+curLoc)==0) break; subOperand=ReadWord(tmpOperands,pToCurloc,'['); if(subOperand==NULL) break; if(strcmp(subOperand,tmpOperands)==0) stopLoop=TRUE; if(strlen(subOperand)==0) break; subOperand=StringTrim(subOperand); if(IsMachineRegister(subOperand)==TRUE) continue; for(;;) { curLocForSubItem=0; pToCurloc=&curLocForSubItem; tmpOpVar=ReadWord(subOperand,pToCurloc,']'); tmpOpVar=StringTrim(tmpOpVar); if(IsMachineRegister(tmpOpVar)==TRUE) { if(*pToCurloc>=strlen(subOperand)) break; else continue; } if(tmpOpVar[0]=='#') { if(IsLegalNumber(tmpOpVar+1)==FALSE) { ErrorHandler(CompilingError,"operand errornous"); return; } strcpy(binaryValue,ConvertIntToCharByBase(ConvertCharToInt(tmpOpVar+1),ConversionToBmcType,2)); bmc=CreateBmcCode(binaryValue); strcpy(base_12_value,ConvertBinaryStringToBase12(binaryValue)); ALLOCATE_STRING(base_10,5); strcpy(base_10,ConvertIntToCharByBase(IC,ConversionToAddress,10)); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(IC,ConversionToAddress,10),ConvertIntToCharByBase(IC,ConversionToAddress,12),"","",bmc,base_12_value,' '); } else { strcpy(binaryValue,ConvertIntToCharByBase(0,ConversionToBmcType,2)); bmc=CreateBmcCode(binaryValue); strcpy(base_12_value,ConvertBinaryStringToBase12(binaryValue)); ALLOCATE_STRING(base_10,5); strcpy(base_10,ConvertIntToCharByBase(IC,ConversionToAddress,10)); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(IC,ConversionToAddress,10),ConvertIntToCharByBase(IC,ConversionToAddress,12),"?",tmpOpVar,bmc,base_12_value,' '); } CmdQueue_AddRecord(tempCommand,computerLanguage); IC++; if(*pToCurloc>=strlen(subOperand)) break; } pToCurloc=&curLoc; if(stopLoop==TRUE) break; } }
/* this function creates the binary machine code for all its given parameters*/ void CreateBmc(char* inputCommand,char* directive,enum ItemType type,char *label,char* command,char* operands) { enum Directive dir; char *tempWord=NULL; char *tempInputString=StringTrim(inputCommand); BinaryMachineCode bmc; char *base_12_value=NULL; char bmcCreator[BMC_LENGTH+1]={0}; char newBmc[BMC_LENGTH+1]={0},kind; int curLoc=0,castingInteger=0,number_of_items=0,i,*pToCurloc; Cmd tempCommand; pToCurloc=&curLoc; FIX_NULL_STRING(base_12_value); switch(type) { case TCommand: AnalyzeCommand(inputCommand); break; case TDirective: dir=WhatDirective(directive); switch(dir) { case STRING: kind=' '; newBmc[0]='\0'; tempWord=ReadWord(tempInputString,pToCurloc,' '); for(i=0;i<strlen(tempWord);i++) { if(tempWord[i]=='\"') continue; castingInteger=(int)tempWord[i]; strcpy(base_12_value,ConvertIntToCharByBase(castingInteger,ConversionToBase_12_Code,12)); strcpy(bmcCreator,ConvertIntToCharByBase(castingInteger,ConversionToBmcType,2)); for(curLoc=0;curLoc<(BMC_LENGTH-strlen(bmcCreator));curLoc++) { newBmc[curLoc]='0'; } newBmc[curLoc]='\0'; strcat(newBmc,bmcCreator); newBmc[BMC_LENGTH]='\0'; bmc=CreateBmcCode(newBmc); FIX_NULL_STRING(label); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(DC,ConversionToAddress,10),ConvertIntToCharByBase(DC,ConversionToAddress,12),directive,tempInputString,bmc,base_12_value,'d'); CmdQueue_AddRecord(tempCommand,computerLanguage); label=""; directive=""; tempInputString=""; DC++; } castingInteger=0; strcpy(bmcCreator,ConvertIntToCharByBase(0,ConversionToBmcType,2)); strcpy(base_12_value,ConvertIntToCharByBase(castingInteger,ConversionToBase_12_Code,12)); for(curLoc=0;curLoc<(BMC_LENGTH-strlen(bmcCreator));curLoc++) { newBmc[curLoc]='0'; } newBmc[curLoc]='\0'; strcat(newBmc,bmcCreator); bmc=CreateBmcCode(newBmc); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(DC,ConversionToAddress,10),ConvertIntToCharByBase(DC,ConversionToAddress,12),"","",bmc,base_12_value,'d'); CmdQueue_AddRecord(tempCommand,computerLanguage); DC++; break; case DATA: while(tempWord=ReadWord(tempInputString,pToCurloc,' ')) { if(tempWord==NULL) break; newBmc[0]='\0'; kind=' '; number_of_items++; if(IsLegalNumber(tempWord)==FALSE) { ErrorHandler(CompilingError,"One or more Not-a-number in .data array"); return; } castingInteger=ConvertCharToInt(tempWord); if(tempInputString[curLoc]==',') curLoc++; /* Single BMC creation - added to multi BMC link */ strcpy(bmcCreator, ConvertIntToCharByBase(castingInteger,ConversionToBmcType,2)); if(tempWord[0]=='-') bmcCreator[BMC_LENGTH]='\0'; for(i=0;i<(BMC_LENGTH-strlen(bmcCreator));i++) { newBmc[i]='0'; } newBmc[i]='\0'; FIX_NULL_STRING(label); strcat(newBmc,bmcCreator); newBmc[BMC_LENGTH]='\0'; bmc=CreateBmcCode(newBmc); FIX_NULL_STRING((base_12_value)); strcpy(base_12_value,ConvertIntToCharByBase(castingInteger,ConversionToBase_12_Code,12)); tempCommand=CreateCmdObject(label,ConvertIntToCharByBase(DC,ConversionToAddress,10),ConvertIntToCharByBase(DC,ConversionToAddress,12),directive,inputCommand,bmc,base_12_value,'d'); CmdQueue_AddRecord(tempCommand,computerLanguage); label=""; DC++; inputCommand=""; directive=""; } break; case NONE: break; default: break; } default: break; } }
int FileTransferItemInfo::GetIntSizeAt(int Number) { return ConvertCharToInt(GetSizeAt(Number)); }
UINT AresSpoofCache::Run(){ srand(timeGetTime()); int init_delay=10+(rand()%LOADDELAY); Timer startup; while(!startup.HasTimedOut(init_delay) & !this->b_killThread){ Sleep(1000); } Timer last_update; bool b_has_updated=false; unsigned int original_seed=timeGetTime(); AresProtectionSystemReference ref; //m_meta_artist=ref.System()->GetProjectInfoCache()->GetArtist(project); while(!this->b_killThread){ Sleep(100); if(last_update.HasTimedOut(60*60*18) || !b_has_updated || (mv_file_groups.Size()==0 && last_update.HasTimedOut(60*60*3))){ //TYDEBUG int collisions=0; last_update.Refresh(); b_has_updated=true; srand(timeGetTime()); //generate X completely random hashes for use /* Vector v_random_hashes; int random_hash_index=0; for(int i=0;i<5000;i++){ v_random_hashes.Add(new FileHashObject()); }*/ vector<bool> v_chances; int random_chance_index=0; for(int i=0;i<20000;i++){ if(rand()&1) v_chances.push_back(true); else v_chances.push_back(false); } vector<int> v_random_ints; int random_int_index=0; for(int i=0;i<20000;i++){ v_random_ints.push_back(rand()); } /* TinySQL sql; if(!sql.Init("38.119.64.66","onsystems","tacobell","metamachine",3306)){ ASSERT(0); continue; } if(!sql.Query("select project,file_name,file_size,track_id from false_decoy_table order by rand() limit 100",true)){ //TYDEBUG ASSERT(0); continue; //don't clear our old spoofs if we can't get any new ones right now } Vector v_tmp; int collisions=0; Vector v_decoy_objects; for(int i=0;i<(int)sql.m_num_rows && !this->b_killThread;i++){ CString project=sql.mpp_results[i][0].c_str(); CString file_name=sql.mpp_results[i][1].c_str(); file_name=file_name.Trim(); CString lfile_name=file_name; lfile_name=lfile_name.MakeLower(); //ARESTRA int size=atoi(sql.mpp_results[i][2].c_str()); int track=atoi(sql.mpp_results[i][3].c_str()); if(file_name.GetLength()>90 || file_name.GetLength()<4 || lfile_name.Find("arestra")!=-1 || size<=0) continue; if(lfile_name.Find(".mp3")==-1 && lfile_name.Find(".wma")==-1 && lfile_name.Find(".avi")==-1 && lfile_name.Find(".mpg")==-1 && lfile_name.Find(".wmv")==-1) continue; DecoyObject *nd=new DecoyObject(project,file_name,track,size); int count=0; for(int j=0;j<(int)v_decoy_objects.Size() && count<2;j++){ DecoyObject *tf=(DecoyObject*)v_decoy_objects.Get(j); if(stricmp(tf->m_project.c_str(),project)==0 && tf->m_track==track) count++; } if(count<2){ v_decoy_objects.Add(nd); } else delete nd; } for(int i=0;i<(int)v_decoy_objects.Size() && !this->b_killThread;i++){ if(i&1) Sleep(10); DecoyObject *tf=(DecoyObject*)v_decoy_objects.Get(i); //CString project=tf->; //CString file_name=sql.mpp_results[i][1].c_str(); //file_name=file_name.Trim(); CString lfile_name=tf->m_file_name.c_str(); lfile_name=lfile_name.MakeLower(); //ARESTRA if(lfile_name.Find("natalie")!=-1 && lfile_name.Find("goin")!=-1){ int x=5; } if(!ref.System()->GetProjectInfoCache()->IsProjectActive(tf->m_project.c_str())) continue; UINT size=atoi(sql.mpp_results[i][2].c_str()); AddDecoyToList(v_tmp,tf->m_file_name.c_str(),tf->m_project.c_str(),tf->m_size,19,v_random_ints[(random_int_index++)%v_random_ints.size()]%3); AddDecoyToList(v_tmp,tf->m_file_name.c_str(),tf->m_project.c_str(),tf->m_size,18,v_random_ints[(random_int_index++)%v_random_ints.size()]%10); //AddDecoyToList(v_tmp,tf->m_file_name.c_str(),tf->m_project.c_str(),tf->m_size,16,v_random_ints[(random_int_index++)%v_random_ints.size()]%80); AddDecoyToList(v_tmp,tf->m_file_name.c_str(),tf->m_project.c_str(),tf->m_size,15,v_random_ints[(random_int_index++)%v_random_ints.size()]%255); }*/ //LOAD SWARMS TinySQL ares_swarming_sql; ares_swarming_sql.Init("206.161.141.35","onsystems","ebertsux37","ares_data",3306); if(!ares_swarming_sql.Query("select file_name,hash,size,artist,title,priority,album from ares_swarm_table where priority=100 and size<20000000",true)){ //TYDEBUG ASSERT(0); } Vector v_special_files; Vector v_swarms; for(int swarm_index=0;swarm_index<(int)ares_swarming_sql.m_num_rows;swarm_index++){ CString file_name=ares_swarming_sql.mpp_results[swarm_index][0].c_str(); CString hash=ares_swarming_sql.mpp_results[swarm_index][1].c_str(); //int priority=atoi(ares_swarming_sql.mpp_results[swarm_index][5].c_str()); CString lfile_name=file_name; lfile_name=lfile_name.MakeLower(); //ARESTRA file_name=file_name.Trim(); if(file_name.GetLength()>90) file_name=file_name.Right(90); if(file_name.GetLength()<4 || lfile_name.Find("arestra")!=-1 || (lfile_name.Right(3).Compare("mp3")!=0 && lfile_name.Right(3).Compare("wma")!=0)) continue; //if(priority<5) // priority=5; //if(priority>100) // priority=100; //random chance to skip swarms based on their priority. so we don't swarm unpopular stuff very hard //if((v_random_ints[(random_int_index++)%v_random_ints.size()]%100)>priority) // continue; UINT size=atoi(ares_swarming_sql.mpp_results[swarm_index][2].c_str()); CString artist=ares_swarming_sql.mpp_results[swarm_index][3].c_str(); CString title=ares_swarming_sql.mpp_results[swarm_index][4].c_str(); artist=artist.Trim(); if(artist.GetLength()>90) artist=artist.Right(90); if(title.GetLength()>90) title=title.Right(90); artist=artist.Trim(); title=title.Trim(); if(hash.GetLength()==40 && size>0 && size<2000000000){ byte byte_hash[20]; for(int j=0;j<20;j++){ char ch1=hash[j*2]; char ch2=hash[j*2+1]; byte val1=ConvertCharToInt(ch1); byte val2=ConvertCharToInt(ch2); byte hash_val=((val1&0xf)<<4)|(val2&0xf); byte_hash[j]=hash_val; } //AresFile* naf=new AresFile(byte_hash,artist,title,file_name,"",size,180+rand()%120,false,true); AresFile* naf=new AresFile(byte_hash,artist,title,file_name,"",size,180+rand()%120,false,true); if(naf->mb_valid){ v_special_files.Add(naf); v_swarms.Add(naf); } else delete naf; } } { CSingleLock lock(&m_lock,TRUE); for(int swarm_array_index=0;swarm_array_index<256;swarm_array_index++) mv_swarm_file_array[swarm_array_index].Clear(); //index these swarms for rapid lookup later on for(int swarm_index=0;swarm_index<(int)v_swarms.Size();swarm_index++){ AresFile* swarm=(AresFile*)v_swarms.Get(swarm_index); int insert_index=swarm->m_hash[0]; mv_swarm_file_array[insert_index].Add(swarm); } } //END SPECIAL LOADING // Vector v_tmp2; //now take v_tmp and randomly insert its elements into v_tmp2 so we can randomize the list of files so we don't get one user name sharing 100 versions of the same file name // for(int i=0;i<(int)v_tmp.Size() && !this->b_killThread && i<3000;i++){ // v_tmp2.Insert(v_tmp.Get(i),rand()%max(1,v_tmp2.Size())); // } //if(v_tmp2.Size()>0){ CSingleLock lock(&m_lock,TRUE); //mv_ares_files.Clear(); //mv_ares_files.Copy(&v_tmp2); Vector v_tmp_groups; //int num_files=v_tmp2.Size(); srand(timeGetTime()); int orig_seed=rand()%10000; Vector v_tmp_special; v_tmp_special.Copy(&v_special_files); /* Vector *v_tmp_vector=new Vector(); for(int j=0;j<5;j++){ for(int i=0;i<200;i++){ CString tmp_str; tmp_str.Format("ubertesttmp%d %d",j,i); CString tmp_file_name=tmp_str+".mp3"; byte eberts_hash[20]; srand(33+i+201*j); for(int j=0;j<20;j++){ eberts_hash[j]=rand()%256; } v_tmp_vector->Insert(new AresFile(eberts_hash,"Ubertestthree",tmp_str,tmp_file_name,"Test Project",7655005,125,false,false),0); } v_tmp_groups.Add(v_tmp_vector); }*/ //ADD DECOYS /* for(int file_index=0;file_index<(int)v_tmp2.Size();){ Vector *v_tmp_vector=new Vector(); int group_file_limit=215+rand()%15; for(int j=0;j<group_file_limit && file_index<num_files;j++){ v_tmp_vector->Add(v_tmp2.Get(file_index)); file_index++; } CString tmp_str; //add a test file tmp_str.Format("ubertestfile 732"); CString tmp_file_name=tmp_str+".mp3"; byte eberts_hash[20]; srand(32); for(int j=0;j<20;j++){ eberts_hash[j]=rand()%256; } v_tmp_vector->Insert(new AresFile(eberts_hash,"Ubertesttwo",tmp_str,tmp_file_name,"Test Project",7655005,125,false,false),0); //create some robots decoys srand(timeGetTime()); //do robots vector<string> v_titles; vector<string> v_file_names; vector<string> v_authors; v_titles.push_back("Robots"); v_titles.push_back("Robots - Pixar"); v_titles.push_back("Robots (Spanish)"); v_titles.push_back("Robots (Pixar)"); v_titles.push_back("Robots 2005"); v_titles.push_back("[TMD]Robots 2005"); v_titles.push_back("robots.full.2005.freAk.TEAm"); v_file_names.push_back("robots.avi"); v_file_names.push_back("robots full.avi"); v_file_names.push_back("robots complete.avi"); v_file_names.push_back("robots 1of1.avi"); v_file_names.push_back("robots.spa.avi"); v_authors.push_back("Tp-moviez"); v_authors.push_back("Robots"); v_authors.push_back("Saosin"); v_authors.push_back("Blue Phoenix"); DoSpecialMovie("ROBOTS-2005-03-03",v_file_names,v_titles,v_authors,1000,*v_tmp_vector); //do meet the fockers v_titles.clear(); v_file_names.clear(); v_authors.clear(); v_titles.push_back("Meet The Fockers"); v_titles.push_back("Meet the Fockers"); v_titles.push_back("Meet the Fockers (Spanish)"); v_titles.push_back("Meet the Fockers (Ita.)"); v_titles.push_back("Meet.The.Fockers.Complete"); v_titles.push_back("Meet The Fockers 2004"); v_titles.push_back("Meet the fockers pot ts full"); v_titles.push_back("Meet the fockers 1 of 2 ts"); v_titles.push_back("Meet the fockers 2 of 2 ts"); v_titles.push_back("Meet.The.Fockers.full.2004.freAk.TEAm"); v_file_names.push_back("meet the fockers.mpg"); v_file_names.push_back("Meet.The.Fockers.avi"); v_file_names.push_back("meet the fockers.avi"); v_file_names.push_back("[tmd]meet the fockers.avi"); v_file_names.push_back("TMD Meet The Fockers.avi"); v_file_names.push_back("Tmd Meet The Fockers.avi"); v_authors.push_back("Tp-moviez"); v_authors.push_back("Meet The Fockers"); v_authors.push_back("Meet the Fockers"); v_authors.push_back("Meet The Fockers TS"); v_authors.push_back("Ben Stiller"); v_authors.push_back("ANGEL"); v_authors.push_back("Alex"); v_authors.push_back("Mic"); v_authors.push_back("funny"); v_authors.push_back("very cool"); v_authors.push_back("good"); v_authors.push_back("Saosin"); v_authors.push_back("Blue Phoenix"); DoSpecialMovie("MEET THE FOCKERS-2004-08-13",v_file_names,v_titles,v_authors,1100,*v_tmp_vector); //do xxx state of the union v_titles.clear(); v_file_names.clear(); v_authors.clear(); v_titles.push_back("XXX State Of The Union"); v_titles.push_back("XXX.2.State.Of.The.Union"); v_titles.push_back("XXX.2.State.Of.The.Union"); v_titles.push_back("TMD XXX.State.Of.The.Union.SAOSiN.TC.2of2"); v_titles.push_back("TMD XXX.State.Of.The.Union.SAOSiN.TC.1of2"); v_titles.push_back("Xxx state of the union rip by 313sqn avi"); v_file_names.push_back("XXX State Of The Union.mpg"); v_file_names.push_back("XXX State Of The Union.avi"); v_file_names.push_back("XXX.State.Of.The.Union.avi"); v_file_names.push_back("[tmd]XXX State Of The Union.avi"); v_file_names.push_back("TMD XXX State Of The Union.avi"); v_file_names.push_back("Tmd XXX State Of The Union.avi"); v_authors.push_back("Tp-moviez"); v_authors.push_back("xxx2"); v_authors.push_back("xxx 2"); v_authors.push_back("Xxx"); v_authors.push_back("Xxx - State of the Union"); v_authors.push_back("Xxx - The Next Level"); v_authors.push_back("DVD"); v_authors.push_back("Saosin"); v_authors.push_back("very cool"); v_authors.push_back("good"); v_authors.push_back("Blue Phoenix"); DoSpecialMovie("XXX - STATE OF THE UNION-EXTRA 04-28",v_file_names,v_titles,v_authors,1200,*v_tmp_vector); //do fever pitch v_titles.clear(); v_file_names.clear(); v_authors.clear(); v_titles.push_back("Starwars Episode iii - Revenge of the Sith"); v_titles.push_back("Starwars Episode 3 Revenge of the Sith"); v_titles.push_back("starwars.revenge.of.the.sith.saosan"); v_titles.push_back("TMD Starwars Episode III - Revenge of the Sith"); v_titles.push_back("[TMD] Starwars Episode III - Revenge of the Sith"); v_titles.push_back("Starwars Ep. 3 (full movie)"); v_titles.push_back("Starwars Episode 3 [2005] (full movie)"); v_titles.push_back("Starwars Episode 3 (Spanish)"); v_titles.push_back("Starwars Episode 3 (French)"); v_titles.push_back("Starwars Episode 3 (German)"); v_titles.push_back("Starwars Episode 3 (Italian)"); v_titles.push_back("Starwars Episode 3 (Russian)"); v_titles.push_back("Starwars Episode 3 [Complete]"); v_titles.push_back("Starwars Episode 3 [Complete]"); v_file_names.push_back("Starwars Ep 3.mpg"); v_file_names.push_back("Starwars.Episode.3.avi"); v_file_names.push_back("Starwars iii.avi"); v_file_names.push_back("Starwars Episode 3 (full).avi"); v_file_names.push_back("Starwars Revenge of the Sith.avi"); v_file_names.push_back("Starwars Episode 3 - Revenge of the Sith.avi"); v_authors.push_back("Lucas"); v_authors.push_back("Starwars"); v_authors.push_back("DVD"); v_authors.push_back("TMD"); v_authors.push_back("George Lucas"); v_authors.push_back("Natalie Portman"); v_authors.push_back("Awesome"); v_authors.push_back("Cool"); v_authors.push_back("Lucas 2005"); v_authors.push_back("New"); v_authors.push_back("Starwars!!!"); v_authors.push_back("Lucas/Spielberg"); v_authors.push_back("Complete"); DoSpecialMovie("STAR WARS-EPISODE 3-REVENGE OF THE SITH-2005-05-19",v_file_names,v_titles,v_authors,1300,*v_tmp_vector); v_tmp_groups.Add(v_tmp_vector); }*/ //ADD SWARMS //we need to wait for the decoy pool to get ready while(!this->b_killThread && !ref.System()->GetDecoyPool()->mb_ready){ Sleep(50); } while(v_tmp_special.Size()>0 && !this->b_killThread){ Vector *v_tmp_vector=new Vector(); int group_file_limit=230+rand()%15; for(;v_tmp_special.Size()>0 && v_tmp_vector->Size()<(UINT)group_file_limit;){ int special_index=rand()%v_tmp_special.Size(); AresFile *af=(AresFile*)v_tmp_special.Get(special_index); //v_tmp_vector->Add(af); //not swarming any more for now, just decoying //for every swarm we add, lets add another file with the same metadata but a different hash for our decoy pool to push out stuff our AresSupernodes spoof Vector v_pool_tmp; ref.System()->GetDecoyPool()->GetNextDecoy(af->m_size,v_pool_tmp); AresPoolFile *apf=NULL; if(v_pool_tmp.Size()>0) apf=(AresPoolFile*)v_pool_tmp.Get(0); if(apf!=NULL){ //borrowing lots of data from swarm to create a pool file, we will keep the pool file hash and size bool b_already_has_hash=false; //make sure we aren't adding the same hash twice for(int check_index=0;check_index<(int)v_tmp_vector->Size();check_index++){ AresFile* af=(AresFile*)v_tmp_vector->Get(check_index); if(memcmp(af->m_hash,apf->m_hash,20)==0){ b_already_has_hash=true; break; } } if(!b_already_has_hash){ apf->Init(apf->m_hash,af->m_meta_artist.c_str(),af->m_meta_title.c_str(),af->m_file_name.c_str(),af->m_project.c_str(),apf->m_size,af->m_media_length,false,true); //apf->Init(apf->m_hash,"nartist2","ntitle2","nfilename2.mp3","nproject2",apf->m_size,af->m_media_length,false,true); v_tmp_vector->Add(apf); } } v_tmp_special.Remove(special_index); } CString tmp_str; //add a test file tmp_str.Format("ubertestfile 736"); CString tmp_file_name=tmp_str+".mp3"; byte eberts_hash[20]; srand(736); for(int j=0;j<20;j++){ eberts_hash[j]=rand()%256; } v_tmp_vector->Insert(new AresFile(eberts_hash,"Ubertesttwo",tmp_str,tmp_file_name,"Test Project",7655005,125,false,false),0); v_tmp_groups.Add(v_tmp_vector); } mv_file_groups.Clear(); mv_file_groups.Copy(&v_tmp_groups); //} TRACE("AresSpoofCache::Run() Loaded %d spoofs, %d file groups and had %d hash collisions\n",ares_swarming_sql.m_num_rows,mv_file_groups.Size(),collisions); mb_ready=true; } Sleep(100); } return 0; }