Commit 464ca507 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

add -o option to write mask into file

parent b4ad36b0
Loading
Loading
Loading
Loading
+6 −0
Changes for Statsgen/include/statsgen.h: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -175,6 +175,11 @@ public:
	 */
	void setSecurityRules();

	/**
	 * @brief Where to write masks
	 * @param outfie: the file where to write masks
	 */
	void setOutfile(std::string outfile);

	/**
	 * @brief Calculate all statistics for a database
@@ -204,6 +209,7 @@ private:
	int limitSimplemask = 0;		// Limit the size of Simple Mask
	int limitAdvancedmask = 0;		// Limit the size of Advanced Mask
	int nbThread = 1;				// Number of usable threads, default 1
	std::string outfile_name;		// File where to write masks


	// Dictionary
+5 −1
Changes for Statsgen/src/main.cpp: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ static struct option long_options[] = {
	{"hiderare", no_argument, NULL, 'H'},
	{"top", required_argument, NULL, 't'},
	{"regex", required_argument, NULL, 'r'},
	{"out", required_argument, NULL, 'o'},
	{"limit-advanced-masks", required_argument, NULL, 'A'},
	{"limit-simple-masks", required_argument, NULL, 'S'},
	{"parallel", required_argument, NULL, 'p'},
@@ -44,6 +45,7 @@ void showHelp() {
		"	--hiderare, -H     Hide all statistics below 1%",
		"	--top, -t [value]   Show only [value] first results",
		"	--regex, -r [value] Show result for password, using the regular expression [value]",
		"	--out, -o [value]   Writes masks into [value] file",
		"",
		"Optimisation options to reduce the execution time : ",
		"	--limit-advanced-masks, -A [value]  Limit the size of the advanced masks at [value], if size>[value]: othermasks",
@@ -69,7 +71,7 @@ int main(int argc,char* argv[]) {
	string filename;

	int opt;
	while ((opt = getopt_long(argc, argv, "hwHt:r:A:S:p:s", long_options, NULL)) != -1){
	while ((opt = getopt_long(argc, argv, "hwHt:r:o:A:S:p:s", long_options, NULL)) != -1){
		switch(opt){
			case 'h':
				showHelp(); break;
@@ -81,6 +83,8 @@ int main(int argc,char* argv[]) {
				statsgen.setTop(atoi(optarg)); break;
			case 'r':
				statsgen.setRegex(optarg); break;
			case 'o':
				statsgen.setOutfile(optarg); break;
			case 'A':
				statsgen.setLimitAdvancedmask(atoi(optarg)); break;
			case 'S':
+12 −0
Changes for Statsgen/src/statsgen.cpp: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ void Statsgen::setNbThread(int nb) {
	}
}

void Statsgen::setOutfile(string outfile){
	outfile_name = outfile;
}


void Statsgen::setSecurityRules() {
	wcout << "\nMinimal length of a password:" << endl;
@@ -259,6 +263,14 @@ void Statsgen::print_stats() {
	wcout << "\nStatistics relative to advancedmask: \n" << endl;
	showMap(stats_advancedmasks, top, total_counter, hiderare, count);

	if (outfile_name != ""){
		wofstream outfile_stream(outfile_name);
		for(auto it=stats_advancedmasks.begin();it!=stats_advancedmasks.end();it++){
			outfile_stream << it->first << "," << it->second << endl;
		}
		outfile_stream.close();
	}
	
	if (limitAdvancedmask > 0) {
		wcout << endl;
		readResult(stats_advancedmasks[L"othermasks"], L"othermasks", count, total_counter, hiderare);