We are trying to do brute force attack, and we implemented multi thread code in c11. We tested it but it is not utilizing all the 32 cores of the system. max it able to utilize 8-10.
void generate(string gen, int index, int len, int tid) {
if(identified) {
terminate();
}
if(check_password(gen)) {
cout << "Correct_Password\t"<<gen<<"\n";
identified = 1;
}
else if(index<len) {
for (int i=0; i<no_chars; i++ )
{
gen += str[i];
generate(gen,index+1,len,tid);
gen.pop_back();
}
}
}
int main(){
//cin>>user_input;
int nr_threads = 95;
vector<thread> threads;
for (int i = 0; i < nr_threads; ++i) {
stringstream ss;
string g;
char ch=str[i];
ss << ch;
ss >> g;
threads.push_back(thread(generate,g,1,5,i+1));
}
//Join the threads with the main thread
for(auto &t : threads){
t.join();
}
return 0;
}
How to utilize all the cores?
Aucun commentaire:
Enregistrer un commentaire