Loading include/Statsgen.h +0 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,6 @@ private: int limitAdvancedmask = 12; // Limit the size of Advanced Mask uint nbThread = 1; // Number of usable threads, default 1 std::string outfile_name; // File where to write masks bool is_stdin = false; // If filename is stdin bool debug_enabled = false; // Enable debug output Loading include/ThreadData.h +0 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ #include <string> #include <unordered_map> #include <queue> #include <climits> #include <regex> Loading Loading @@ -44,7 +43,6 @@ struct ThreadData { StringOccurrence simplemasks; StringOccurrence advancedmasks; StringOccurrence charactersets; std::queue<std::string> password_queue; minMax minMaxValue; Loading src/cli/Main.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ void showHelp() { "Usage: stats FILENAME [OPTIONS]", "To be sure the database's format can be read, please use this command before:", " iconv -f ISO-8859-1 -t UTF-8 databaseInput.txt -o databaseOutput.txt", "Use '-' for FILENAME to read from stdin", "Options:", " --help, -h Show this help message", " --withcount, -w Mendatory if the input database has the following format : [number of occurence] [password]", Loading src/core/Statsgen.cpp +6 −47 Original line number Diff line number Diff line Loading @@ -21,12 +21,7 @@ #include "Utils.h" using namespace std; Statsgen::Statsgen(const std::string& name):filename(name){ if (name == "-"){ is_stdin = true; cerr << "[WARNING]" << " reading from stdin enabled, loading the whole list in memory" << endl; } } Statsgen::Statsgen(const std::string& name):filename(name){} void Statsgen::askSecurityRules() { Loading Loading @@ -66,26 +61,14 @@ int Statsgen::generate_stats() { finished = 0; started = false; uint64_t nbline = 0; if (!is_stdin){ nbline = nbline_file(filename); if (!nbline){ // error reading the file cerr << "[ERROR] Empty file or not existing file" << endl; return 0; } } pthread_t threads[MAX_THREADS]; // split stdin into nbThread files on disk if (is_stdin){ string line; nbline = 0; while(cin >> line){ td[nbline%nbThread].password_queue.push(line); nbline++; } } for(uint i = 0; i < nbThread; i++ ) { td[i].thread_id = i + 1; configureThread(td[i]); Loading @@ -102,15 +85,7 @@ int Statsgen::generate_stats() { cerr << "[DEBUG] " << "Thread " << td[i].thread_id << " analyse : " << td[i].lineBegin << " --> " << td[i].lineEnd << endl; } int rc; // We use std::queue if input is from stdin if (is_stdin) { rc = pthread_create(&threads[i], NULL, generate_stats_thread_queue, (void *)&td[i] ); } // Else we split the file in nbThread threads else { rc = pthread_create(&threads[i], NULL, generate_stats_thread, (void *)&td[i] ); } int rc = pthread_create(&threads[i], NULL, generate_stats_thread, (void *)&td[i] ); if (rc) { cerr << "[ERROR] unable to create thread," << rc << endl; Loading Loading @@ -286,22 +261,6 @@ void handle_password(const string& password, const uint64_t& nbPasswords, Thread my_data->minMaxValue.updateMinMax(c.pol); } void* generate_stats_thread_queue(void* threadarg) { ThreadData *my_data = (ThreadData *) threadarg; string line; uint64_t nbline = 0; while(!my_data->password_queue.empty()) { ++nbline; line = my_data->password_queue.front(); my_data->password_queue.pop(); if (line.size() == 0){ continue; } handle_password(line, 1, my_data); } pthread_exit(NULL); } void* generate_stats_thread(void* threadarg) { ThreadData* my_data = (ThreadData *) threadarg; Loading Loading
include/Statsgen.h +0 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,6 @@ private: int limitAdvancedmask = 12; // Limit the size of Advanced Mask uint nbThread = 1; // Number of usable threads, default 1 std::string outfile_name; // File where to write masks bool is_stdin = false; // If filename is stdin bool debug_enabled = false; // Enable debug output Loading
include/ThreadData.h +0 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ #include <string> #include <unordered_map> #include <queue> #include <climits> #include <regex> Loading Loading @@ -44,7 +43,6 @@ struct ThreadData { StringOccurrence simplemasks; StringOccurrence advancedmasks; StringOccurrence charactersets; std::queue<std::string> password_queue; minMax minMaxValue; Loading
src/cli/Main.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ void showHelp() { "Usage: stats FILENAME [OPTIONS]", "To be sure the database's format can be read, please use this command before:", " iconv -f ISO-8859-1 -t UTF-8 databaseInput.txt -o databaseOutput.txt", "Use '-' for FILENAME to read from stdin", "Options:", " --help, -h Show this help message", " --withcount, -w Mendatory if the input database has the following format : [number of occurence] [password]", Loading
src/core/Statsgen.cpp +6 −47 Original line number Diff line number Diff line Loading @@ -21,12 +21,7 @@ #include "Utils.h" using namespace std; Statsgen::Statsgen(const std::string& name):filename(name){ if (name == "-"){ is_stdin = true; cerr << "[WARNING]" << " reading from stdin enabled, loading the whole list in memory" << endl; } } Statsgen::Statsgen(const std::string& name):filename(name){} void Statsgen::askSecurityRules() { Loading Loading @@ -66,26 +61,14 @@ int Statsgen::generate_stats() { finished = 0; started = false; uint64_t nbline = 0; if (!is_stdin){ nbline = nbline_file(filename); if (!nbline){ // error reading the file cerr << "[ERROR] Empty file or not existing file" << endl; return 0; } } pthread_t threads[MAX_THREADS]; // split stdin into nbThread files on disk if (is_stdin){ string line; nbline = 0; while(cin >> line){ td[nbline%nbThread].password_queue.push(line); nbline++; } } for(uint i = 0; i < nbThread; i++ ) { td[i].thread_id = i + 1; configureThread(td[i]); Loading @@ -102,15 +85,7 @@ int Statsgen::generate_stats() { cerr << "[DEBUG] " << "Thread " << td[i].thread_id << " analyse : " << td[i].lineBegin << " --> " << td[i].lineEnd << endl; } int rc; // We use std::queue if input is from stdin if (is_stdin) { rc = pthread_create(&threads[i], NULL, generate_stats_thread_queue, (void *)&td[i] ); } // Else we split the file in nbThread threads else { rc = pthread_create(&threads[i], NULL, generate_stats_thread, (void *)&td[i] ); } int rc = pthread_create(&threads[i], NULL, generate_stats_thread, (void *)&td[i] ); if (rc) { cerr << "[ERROR] unable to create thread," << rc << endl; Loading Loading @@ -286,22 +261,6 @@ void handle_password(const string& password, const uint64_t& nbPasswords, Thread my_data->minMaxValue.updateMinMax(c.pol); } void* generate_stats_thread_queue(void* threadarg) { ThreadData *my_data = (ThreadData *) threadarg; string line; uint64_t nbline = 0; while(!my_data->password_queue.empty()) { ++nbline; line = my_data->password_queue.front(); my_data->password_queue.pop(); if (line.size() == 0){ continue; } handle_password(line, 1, my_data); } pthread_exit(NULL); } void* generate_stats_thread(void* threadarg) { ThreadData* my_data = (ThreadData *) threadarg; Loading