diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a010c8b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# top-most EditorConfig file, enforcing some of the code style +# +# See http://editorconfig.org for a plugin to your editor! +# +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index 110295a..f0bd061 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,21 @@ # C extensions *.so +*.o +CP.level +EP.level +IP.level +LN.level +alphabetCreator +charFrequency.txt +createConfig +enumNG +evalPW +results/ +src/cmdlineAlphabetCreator.c +src/cmdlineAlphabetCreator.h +src/cmdlineCreateNG.c +src/cmdlineCreateNG.h +src/cmdlineEnumNG.c +src/cmdlineEnumNG.h +src/cmdlineEvalPW.c +src/cmdlineEvalPW.h diff --git a/src/alphabetCreator.c b/src/alphabetCreator.c index bd63524..3d1c5bf 100644 --- a/src/alphabetCreator.c +++ b/src/alphabetCreator.c @@ -1,4 +1,4 @@ -/* +/* * alphabetCreator.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/alphabetCreator.h b/src/alphabetCreator.h index d6f4716..36c9900 100644 --- a/src/alphabetCreator.h +++ b/src/alphabetCreator.h @@ -1,4 +1,4 @@ -/* +/* * alphabetCreator.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -7,20 +7,20 @@ #ifndef ALPHABETCREATOR_H_ #define ALPHABETCREATOR_H_ -/* +/* * initializes all global parameters, setting them to their default value * !! this function must be called before any other operation !! */ void initialize (); -/* +/* * prints all Error-Messages (if any), clears the allocated memory of the * global variables and ends the application * !! this function is set via atexit() !! */ void exit_routine (); -/* +/* * prints the by arguments selected mode as well as the output and input filenames */ void print_settings (); diff --git a/src/attackSimulator.c b/src/attackSimulator.c index 9c421c2..b853081 100644 --- a/src/attackSimulator.c +++ b/src/attackSimulator.c @@ -1,4 +1,4 @@ -/* +/* * attackSimulator.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/attackSimulator.h b/src/attackSimulator.h index 5f49270..27c3934 100644 --- a/src/attackSimulator.h +++ b/src/attackSimulator.h @@ -1,4 +1,4 @@ -/* +/* * attackSimulator.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -15,7 +15,7 @@ extern uint64_t glbl_crackedCount; extern float glbl_crackedRatio; -/* +/* * Generates a "testing set" based on the passwords found in the * given @filename. If an error occurs FALSE is returned. * The passwords of the "testing set" are stored in the global variable @@ -26,19 +26,19 @@ bool simAtt_generateTestingSet (const char *filename, // filename to the file co const char *resultFolder, // folder for the result files int outputCycle); // every x crack try should be added to the graph -/* +/* * Frees any memory allocated by the attack simulator */ void simAtt_freeTestingSet (); -/* +/* * Checks if the "testing set" (glbl_testingSet) contains the given @password. * Returns TRUE, if the password is part of the testing set or false if not. */ bool simAtt_checkCandidate (const char *const password, // the password to be checked out int length); // the length of the password -/* +/* * This functions prints the results of a simulated attack * to the given file pointer (i.e. stdout or log-file). * If @additionalInfo is TRUE, the additional infomration will diff --git a/src/boosting.c b/src/boosting.c index 5f830fd..8121571 100644 --- a/src/boosting.c +++ b/src/boosting.c @@ -1,4 +1,4 @@ -/* +/* * boosting.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -286,7 +286,7 @@ void boost (nGram_struct * nGrams, const alphabet_struct * const alph, const int } } -/* +/* * undo the changes by boost() */ void deboost (nGram_struct * nGrams) diff --git a/src/boosting.h b/src/boosting.h index 1afbc5f..1c68795 100644 --- a/src/boosting.h +++ b/src/boosting.h @@ -1,4 +1,4 @@ -/* +/* * boosting.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -9,12 +9,12 @@ #include "commonStructs.h" -/* +/* * Reads boosting factor alpha from file in return array. */ int *read_alphas (char *filename, int *alpha_count); -/* +/* * Reads hints from file in return array. */ char **read_hints (char *filename, int alpha_count, int hint_count); diff --git a/src/cmdlineAlphabetCreator.c.in b/src/cmdlineAlphabetCreator.c.in index 961f8dc..f17917f 100644 --- a/src/cmdlineAlphabetCreator.c.in +++ b/src/cmdlineAlphabetCreator.c.in @@ -1,7 +1,7 @@ /* File autogenerated by gengetopt version 2.22.6 generated with the following command: - gengetopt -i cmdlineAlphabetCreator.ggo -c c.in -H h.in -F cmdlineAlphabetCreator --show-required + gengetopt -i cmdlineAlphabetCreator.ggo -c c.in -H h.in -F cmdlineAlphabetCreator --show-required The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -39,7 +39,7 @@ const char *gengetopt_args_info_help[] = { "\nInput Files:", " --pwList=filename Password list for creating the alphabet (mandatory)", " -s, --size=INT Defines the alphabet size. The value should be in\n range 1 to 256 (mandatory)", - " -a, --alphabet=filename Defines the file containing the alphabet (mandatory)", + " -a, --alphabet=filename Defines the file containing the input alphabet", " -o, --output=filename Defines the output file for the build alphabet\n (mandatory)", "\nOutput Modes:", " -w, --printWarnings prints warnings (default=off)", @@ -94,7 +94,7 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->output_orig = NULL; args_info->printWarnings_flag = 0; args_info->frequency_flag = 0; - + } static @@ -110,7 +110,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->output_help = gengetopt_args_info_help[6] ; args_info->printWarnings_help = gengetopt_args_info_help[8] ; args_info->frequency_help = gengetopt_args_info_help[9] ; - + } void @@ -160,7 +160,7 @@ void cmdline_parser_params_init(struct cmdline_parser_params *params) { if (params) - { + { params->override = 0; params->initialize = 1; params->check_required = 1; @@ -172,9 +172,9 @@ cmdline_parser_params_init(struct cmdline_parser_params *params) struct cmdline_parser_params * cmdline_parser_params_create(void) { - struct cmdline_parser_params *params = + struct cmdline_parser_params *params = (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); + cmdline_parser_params_init(params); return params; } @@ -200,8 +200,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->alphabet_orig)); free_string_field (&(args_info->output_arg)); free_string_field (&(args_info->output_orig)); - - + + clear_given (args_info); } @@ -246,7 +246,7 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "printWarnings", 0, 0 ); if (args_info->frequency_given) write_into_file(outfile, "frequency", 0, 0 ); - + i = EXIT_SUCCESS; return i; @@ -311,7 +311,7 @@ cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -320,7 +320,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i { int result; struct cmdline_parser_params params; - + params.override = override; params.initialize = initialize; params.check_required = check_required; @@ -334,7 +334,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -351,7 +351,7 @@ cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -367,26 +367,25 @@ cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *pro fprintf (stderr, "%s: '--pwList' option required%s\n", prog_name, (additional_error ? additional_error : "")); error_occurred = 1; } - + if (! args_info->size_given) { fprintf (stderr, "%s: '--size' ('-s') option required%s\n", prog_name, (additional_error ? additional_error : "")); error_occurred = 1; } - + if (! args_info->alphabet_given) { - fprintf (stderr, "%s: '--alphabet' ('-a') option required%s\n", prog_name, (additional_error ? additional_error : "")); - error_occurred = 1; + args_info->alphabet_arg = strdup("/dev/null"); } - + if (! args_info->output_given) { fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : "")); error_occurred = 1; } - - + + /* checks for dependences among options */ return error_occurred; @@ -415,7 +414,7 @@ static char *package_name = 0; */ static int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, + unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, @@ -437,18 +436,18 @@ int update_arg(void *field, char **orig_field, if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", + fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", package_name, long_opt, short_opt, (additional_error ? additional_error : "")); else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", + fprintf (stderr, "%s: `--%s' option given more than once%s\n", package_name, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ } FIX_UNUSED (default_value); - + if (field_given && *field_given && ! override) return 0; if (prev_given) @@ -519,14 +518,14 @@ cmdline_parser_internal ( int error_occurred = 0; struct gengetopt_args_info local_args_info; - + int override; int initialize; int check_required; int check_ambiguity; - + package_name = argv[0]; - + override = params->override; initialize = params->initialize; check_required = params->check_required; @@ -575,78 +574,78 @@ cmdline_parser_internal ( exit (EXIT_SUCCESS); case 's': /* Defines the alphabet size. The value should be in range 1 to 256. */ - - - if (update_arg( (void *)&(args_info->size_arg), + + + if (update_arg( (void *)&(args_info->size_arg), &(args_info->size_orig), &(args_info->size_given), &(local_args_info.size_given), optarg, 0, 0, ARG_INT, check_ambiguity, override, 0, 0, "size", 's', additional_error)) goto failure; - + break; case 'a': /* Defines the file containing the alphabet. */ - - - if (update_arg( (void *)&(args_info->alphabet_arg), + + + if (update_arg( (void *)&(args_info->alphabet_arg), &(args_info->alphabet_orig), &(args_info->alphabet_given), &(local_args_info.alphabet_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "alphabet", 'a', additional_error)) goto failure; - + break; case 'o': /* Defines the output file for the build alphabet. */ - - - if (update_arg( (void *)&(args_info->output_arg), + + + if (update_arg( (void *)&(args_info->output_arg), &(args_info->output_orig), &(args_info->output_given), &(local_args_info.output_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "output", 'o', additional_error)) goto failure; - + break; case 'w': /* prints warnings. */ - - + + if (update_arg((void *)&(args_info->printWarnings_flag), 0, &(args_info->printWarnings_given), &(local_args_info.printWarnings_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "printWarnings", 'w', additional_error)) goto failure; - + break; case 'f': /* Writes frequency. */ - - + + if (update_arg((void *)&(args_info->frequency_flag), 0, &(args_info->frequency_given), &(local_args_info.frequency_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "frequency", 'f', additional_error)) goto failure; - + break; case 0: /* Long option with no short option */ /* Password list for creating the alphabet. */ if (strcmp (long_options[option_index].name, "pwList") == 0) { - - - if (update_arg( (void *)&(args_info->pwList_arg), + + + if (update_arg( (void *)&(args_info->pwList_arg), &(args_info->pwList_orig), &(args_info->pwList_given), &(local_args_info.pwList_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "pwList", '-', additional_error)) goto failure; - + } - + break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -673,7 +672,7 @@ cmdline_parser_internal ( return 0; failure: - + cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } diff --git a/src/cmdlineAlphabetCreator.h b/src/cmdlineAlphabetCreator.h deleted file mode 100644 index 0853806..0000000 --- a/src/cmdlineAlphabetCreator.h +++ /dev/null @@ -1,204 +0,0 @@ -/** @file cmdlineAlphabetCreator.h.in - * @brief The header file for the command line option parser - * generated by GNU Gengetopt version 2.22.6 - * http://www.gnu.org/software/gengetopt. - * DO NOT modify this file, since it can be overwritten - * @author GNU Gengetopt by Lorenzo Bettini */ - -#ifndef CMDLINEALPHABETCREATOR_H -#define CMDLINEALPHABETCREATOR_H - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include /* for FILE */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifndef CMDLINE_PARSER_PACKAGE -/** @brief the program name (used for printing errors) */ -#define CMDLINE_PARSER_PACKAGE "alphabetCreator" -#endif - -#ifndef CMDLINE_PARSER_PACKAGE_NAME -/** @brief the complete program name (used for help and version) */ -#define CMDLINE_PARSER_PACKAGE_NAME "alphabetCreator" -#endif - -#ifndef CMDLINE_PARSER_VERSION -/** @brief the program version */ -#define CMDLINE_PARSER_VERSION "0.0.2" -#endif - -/** @brief Where the command line options are stored */ - struct gengetopt_args_info - { - const char *help_help; - /**< @brief Print help and exit help description. */ - const char *version_help; - /**< @brief Print version and exit help description. */ - char *pwList_arg; /**< @brief Password list for creating the alphabet. */ - char *pwList_orig;/**< @brief Password list for creating the alphabet original value given at command line. */ - const char *pwList_help; - /**< @brief Password list for creating the alphabet help description. */ - int size_arg; - /**< @brief Defines the alphabet size. The value should be in range 1 to 256. */ - char *size_orig;/**< @brief Defines the alphabet size. The value should be in range 1 to 256 original value given at command line. */ - const char *size_help; - /**< @brief Defines the alphabet size. The value should be in range 1 to 256 help description. */ - char *alphabet_arg; /**< @brief Defines the file containing the alphabet. */ - char *alphabet_orig;/**< @brief Defines the file containing the alphabet original value given at command line. */ - const char *alphabet_help; - /**< @brief Defines the file containing the alphabet help description. */ - char *output_arg; /**< @brief Defines the output file for the build alphabet. */ - char *output_orig;/**< @brief Defines the output file for the build alphabet original value given at command line. */ - const char *output_help; - /**< @brief Defines the output file for the build alphabet help description. */ - int printWarnings_flag; - /**< @brief prints warnings (default=off). */ - const char *printWarnings_help; - /**< @brief prints warnings help description. */ - int frequency_flag; - /**< @brief Writes frequency (default=off). */ - const char *frequency_help; - /**< @brief Writes frequency help description. */ - - unsigned int help_given;/**< @brief Whether help was given. */ - unsigned int version_given; /**< @brief Whether version was given. */ - unsigned int pwList_given;/**< @brief Whether pwList was given. */ - unsigned int size_given;/**< @brief Whether size was given. */ - unsigned int alphabet_given;/**< @brief Whether alphabet was given. */ - unsigned int output_given;/**< @brief Whether output was given. */ - unsigned int printWarnings_given; /**< @brief Whether printWarnings was given. */ - unsigned int frequency_given; /**< @brief Whether frequency was given. */ - - }; - -/** @brief The additional parameters to pass to parser functions */ - struct cmdline_parser_params - { - int override; - /**< @brief whether to override possibly already present options (default 0) */ - int initialize; - /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; - /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; - /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; - /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ - }; - -/** @brief the purpose string of the program */ - extern const char *gengetopt_args_info_purpose; -/** @brief the usage string of the program */ - extern const char *gengetopt_args_info_usage; -/** @brief the description string of the program */ - extern const char *gengetopt_args_info_description; -/** @brief all the lines making the help output */ - extern const char *gengetopt_args_info_help[]; - -/** - * The command line parser - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info); - -/** - * The command line parser (version with additional parameters - deprecated) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param override whether to override possibly already present options - * @param initialize whether to initialize the option structure my_args_info - * @param check_required whether to check that all required options were provided - * @return 0 if everything went fine, NON 0 if an error took place - * @deprecated use cmdline_parser_ext() instead - */ - int cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required); - -/** - * The command line parser (version with additional parameters) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param params additional parameters for the parser - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params); - -/** - * Save the contents of the option struct into an already open FILE stream. - * @param outfile the stream where to dump options - * @param args_info the option struct to dump - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_dump (FILE * outfile, struct gengetopt_args_info *args_info); - -/** - * Save the contents of the option struct into a (text) file. - * This file can be read by the config file parser (if generated by gengetopt) - * @param filename the file where to save - * @param args_info the option struct to save - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_file_save (const char *filename, struct gengetopt_args_info *args_info); - -/** - * Print the help - */ - void cmdline_parser_print_help (void); -/** - * Print the version - */ - void cmdline_parser_print_version (void); - -/** - * Initializes all the fields a cmdline_parser_params structure - * to their default values - * @param params the structure to initialize - */ - void cmdline_parser_params_init (struct cmdline_parser_params *params); - -/** - * Allocates dynamically a cmdline_parser_params structure and initializes - * all its fields to their default values - * @return the created and initialized cmdline_parser_params structure - */ - struct cmdline_parser_params *cmdline_parser_params_create (void); - -/** - * Initializes the passed gengetopt_args_info structure's fields - * (also set default values for options that have a default) - * @param args_info the structure to initialize - */ - void cmdline_parser_init (struct gengetopt_args_info *args_info); -/** - * Deallocates the string fields of the gengetopt_args_info structure - * (but does not deallocate the structure itself) - * @param args_info the structure to deallocate - */ - void cmdline_parser_free (struct gengetopt_args_info *args_info); - -/** - * Checks that all the required options were specified - * @param args_info the structure to check - * @param prog_name the name of the program that will be used to print - * possible errors - * @return - */ - int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* CMDLINEALPHABETCREATOR_H */ diff --git a/src/cmdlineAlphabetCreator.h.in b/src/cmdlineAlphabetCreator.h.in index a68cf4f..5e2d71d 100644 --- a/src/cmdlineAlphabetCreator.h.in +++ b/src/cmdlineAlphabetCreator.h.in @@ -55,7 +55,7 @@ struct gengetopt_args_info const char *printWarnings_help; /**< @brief prints warnings help description. */ int frequency_flag; /**< @brief Writes frequency (default=off). */ const char *frequency_help; /**< @brief Writes frequency help description. */ - + unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int pwList_given ; /**< @brief Whether pwList was given. */ @@ -152,7 +152,7 @@ void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); /** - * Initializes all the fields a cmdline_parser_params structure + * Initializes all the fields a cmdline_parser_params structure * to their default values * @param params the structure to initialize */ diff --git a/src/cmdlineCreateNG.c.in b/src/cmdlineCreateNG.c.in index 118536e..1758826 100644 --- a/src/cmdlineCreateNG.c.in +++ b/src/cmdlineCreateNG.c.in @@ -1,7 +1,7 @@ /* File autogenerated by gengetopt version 2.22.6 generated with the following command: - gengetopt -i cmdlineCreateNG.ggo -c c.in -H h.in -F cmdlineCreateNG --show-required + gengetopt -i cmdlineCreateNG.ggo -c c.in -H h.in -F cmdlineCreateNG --show-required The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -145,7 +145,7 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->verboseFile_flag = 0; args_info->printWarnings_flag = 0; args_info->withCount_flag = 0; - + } static @@ -173,7 +173,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->verboseFile_help = gengetopt_args_info_help[21] ; args_info->printWarnings_help = gengetopt_args_info_help[22] ; args_info->withCount_help = gengetopt_args_info_help[24] ; - + } void @@ -223,7 +223,7 @@ void cmdline_parser_params_init(struct cmdline_parser_params *params) { if (params) - { + { params->override = 0; params->initialize = 1; params->check_required = 1; @@ -235,9 +235,9 @@ cmdline_parser_params_init(struct cmdline_parser_params *params) struct cmdline_parser_params * cmdline_parser_params_create(void) { - struct cmdline_parser_params *params = + struct cmdline_parser_params *params = (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); + cmdline_parser_params_init(params); return params; } @@ -280,8 +280,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->fAlphabet_orig)); free_string_field (&(args_info->smoothing_arg)); free_string_field (&(args_info->smoothing_orig)); - - + + clear_given (args_info); } @@ -328,7 +328,7 @@ write_into_file(FILE *outfile, const char *opt, const char *arg, const char *val int found = -1; if (arg) { if (values) { - found = check_possible_values(arg, values); + found = check_possible_values(arg, values); } if (found >= 0) fprintf(outfile, "%s=\"%s\" # %s\n", opt, arg, values[found]); @@ -391,7 +391,7 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "printWarnings", 0, 0 ); if (args_info->withCount_given) write_into_file(outfile, "withCount", 0, 0 ); - + i = EXIT_SUCCESS; return i; @@ -456,7 +456,7 @@ cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -465,7 +465,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i { int result; struct cmdline_parser_params params; - + params.override = override; params.initialize = initialize; params.check_required = check_required; @@ -479,7 +479,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -496,7 +496,7 @@ cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -512,8 +512,8 @@ cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *pro fprintf (stderr, "%s: '--iPwdList' option required%s\n", prog_name, (additional_error ? additional_error : "")); error_occurred = 1; } - - + + /* checks for dependences among options */ return error_occurred; @@ -542,7 +542,7 @@ static char *package_name = 0; */ static int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, + unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, @@ -564,11 +564,11 @@ int update_arg(void *field, char **orig_field, if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", + fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", package_name, long_opt, short_opt, (additional_error ? additional_error : "")); else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", + fprintf (stderr, "%s: `--%s' option given more than once%s\n", package_name, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ @@ -577,16 +577,16 @@ int update_arg(void *field, char **orig_field, if (possible_values && (found = check_possible_values((value ? value : default_value), possible_values)) < 0) { if (short_opt != '-') - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s' (`-%c')%s\n", + fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s' (`-%c')%s\n", package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, short_opt, (additional_error ? additional_error : "")); else - fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s'%s\n", + fprintf (stderr, "%s: %s argument, \"%s\", for option `--%s'%s\n", package_name, (found == -2) ? "ambiguous" : "invalid", value, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ } - + if (field_given && *field_given && ! override) return 0; if (prev_given) @@ -657,14 +657,14 @@ cmdline_parser_internal ( int error_occurred = 0; struct gengetopt_args_info local_args_info; - + int override; int initialize; int check_required; int check_ambiguity; - + package_name = argv[0]; - + override = params->override; initialize = params->initialize; check_required = params->check_required; @@ -725,216 +725,216 @@ cmdline_parser_internal ( exit (EXIT_SUCCESS); case 'c': /* Changes output filename for conditional probabilities.. */ - - - if (update_arg( (void *)&(args_info->cPout_arg), + + + if (update_arg( (void *)&(args_info->cPout_arg), &(args_info->cPout_orig), &(args_info->cPout_given), &(local_args_info.cPout_given), optarg, 0, "CP", ARG_STRING, check_ambiguity, override, 0, 0, "cPout", 'c', additional_error)) goto failure; - + break; case 'i': /* Changes output filename for initial probabilities.. */ - - - if (update_arg( (void *)&(args_info->iPout_arg), + + + if (update_arg( (void *)&(args_info->iPout_arg), &(args_info->iPout_orig), &(args_info->iPout_given), &(local_args_info.iPout_given), optarg, 0, "IP", ARG_STRING, check_ambiguity, override, 0, 0, "iPout", 'i', additional_error)) goto failure; - + break; case 'e': /* Changes output filename for end probabilities. */ - - - if (update_arg( (void *)&(args_info->ePout_arg), + + + if (update_arg( (void *)&(args_info->ePout_arg), &(args_info->ePout_orig), &(args_info->ePout_given), &(local_args_info.ePout_given), optarg, 0, "EP", ARG_STRING, check_ambiguity, override, 0, 0, "ePout", 'e', additional_error)) goto failure; - + break; case 'l': /* Changes output filename for password lengths levels. */ - - - if (update_arg( (void *)&(args_info->lenout_arg), + + + if (update_arg( (void *)&(args_info->lenout_arg), &(args_info->lenout_orig), &(args_info->lenout_given), &(local_args_info.lenout_given), optarg, 0, "LN", ARG_STRING, check_ambiguity, override, 0, 0, "lenout", 'l', additional_error)) goto failure; - + break; case 'C': /* Changes config filename. */ - - - if (update_arg( (void *)&(args_info->config_arg), + + + if (update_arg( (void *)&(args_info->config_arg), &(args_info->config_orig), &(args_info->config_given), &(local_args_info.config_given), optarg, 0, "createConfig", ARG_STRING, check_ambiguity, override, 0, 0, "config", 'C', additional_error)) goto failure; - + break; case 'p': /* Adds given prefix to all output files. */ - - - if (update_arg( (void *)&(args_info->prefix_arg), + + + if (update_arg( (void *)&(args_info->prefix_arg), &(args_info->prefix_orig), &(args_info->prefix_given), &(local_args_info.prefix_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "prefix", 'p', additional_error)) goto failure; - + break; case 's': /* Adds given suffix to all output files. */ - - - if (update_arg( (void *)&(args_info->suffix_arg), + + + if (update_arg( (void *)&(args_info->suffix_arg), &(args_info->suffix_orig), &(args_info->suffix_given), &(local_args_info.suffix_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "suffix", 's', additional_error)) goto failure; - + break; case 'd': /* Adds the current date and time as suffix to all output files. */ - - + + if (update_arg((void *)&(args_info->datefix_flag), 0, &(args_info->datefix_given), &(local_args_info.datefix_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "datefix", 'd', additional_error)) goto failure; - + break; case 'n': /* Changes the size of the nGram n. */ - - - if (update_arg( (void *)&(args_info->ngram_arg), + + + if (update_arg( (void *)&(args_info->ngram_arg), &(args_info->ngram_orig), &(args_info->ngram_given), &(local_args_info.ngram_given), optarg, cmdline_parser_ngram_values, "4", ARG_INT, check_ambiguity, override, 0, 0, "ngram", 'n', additional_error)) goto failure; - + break; case 'm': /* Changes the maximum level in range 2 to 101. */ - - - if (update_arg( (void *)&(args_info->maxLevel_arg), + + + if (update_arg( (void *)&(args_info->maxLevel_arg), &(args_info->maxLevel_orig), &(args_info->maxLevel_given), &(local_args_info.maxLevel_given), optarg, 0, "11", ARG_INT, check_ambiguity, override, 0, 0, "maxLevel", 'm', additional_error)) goto failure; - + break; case 'a': /* Changes the used alphabet to the given . */ - - - if (update_arg( (void *)&(args_info->alphabet_arg), + + + if (update_arg( (void *)&(args_info->alphabet_arg), &(args_info->alphabet_orig), &(args_info->alphabet_given), &(local_args_info.alphabet_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "alphabet", 'a', additional_error)) goto failure; - + break; case 'A': /* Changes the used alphabet to the alphabet found in .. */ - - - if (update_arg( (void *)&(args_info->fAlphabet_arg), + + + if (update_arg( (void *)&(args_info->fAlphabet_arg), &(args_info->fAlphabet_orig), &(args_info->fAlphabet_given), &(local_args_info.fAlphabet_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "fAlphabet", 'A', additional_error)) goto failure; - + break; case 'S': /* Changes the used smoothing function to the one defined in .. */ - - - if (update_arg( (void *)&(args_info->smoothing_arg), + + + if (update_arg( (void *)&(args_info->smoothing_arg), &(args_info->smoothing_orig), &(args_info->smoothing_given), &(local_args_info.smoothing_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "smoothing", 'S', additional_error)) goto failure; - + break; case 'v': /* Gain information about settings and results during run time.. */ - - + + if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given), &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "verbose", 'v', additional_error)) goto failure; - + break; case 'F': /* Gain detailed information in the output files.. */ - - + + if (update_arg((void *)&(args_info->verboseFile_flag), 0, &(args_info->verboseFile_given), &(local_args_info.verboseFile_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "verboseFile", 'F', additional_error)) goto failure; - + break; case 'w': /* Prints any warning (if verbose mode is active).. */ - - + + if (update_arg((void *)&(args_info->printWarnings_flag), 0, &(args_info->printWarnings_given), &(local_args_info.printWarnings_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "printWarnings", 'w', additional_error)) goto failure; - + break; case 'u': /* The given password list is counted (like this: #count password).. */ - - + + if (update_arg((void *)&(args_info->withCount_flag), 0, &(args_info->withCount_given), &(local_args_info.withCount_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "withCount", 'u', additional_error)) goto failure; - + break; case 0: /* Long option with no short option */ /* Password list to create nGrams.. */ if (strcmp (long_options[option_index].name, "iPwdList") == 0) { - - - if (update_arg( (void *)&(args_info->iPwdList_arg), + + + if (update_arg( (void *)&(args_info->iPwdList_arg), &(args_info->iPwdList_orig), &(args_info->iPwdList_given), &(local_args_info.iPwdList_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "iPwdList", '-', additional_error)) goto failure; - + } - + break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -961,7 +961,7 @@ cmdline_parser_internal ( return 0; failure: - + cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } diff --git a/src/cmdlineCreateNG.h.in b/src/cmdlineCreateNG.h.in index a06ae17..95a88f9 100644 --- a/src/cmdlineCreateNG.h.in +++ b/src/cmdlineCreateNG.h.in @@ -88,7 +88,7 @@ struct gengetopt_args_info const char *printWarnings_help; /**< @brief Prints any warning (if verbose mode is active). help description. */ int withCount_flag; /**< @brief The given password list is counted (like this: #count password). (default=off). */ const char *withCount_help; /**< @brief The given password list is counted (like this: #count password). help description. */ - + unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int iPwdList_given ; /**< @brief Whether iPwdList was given. */ @@ -197,7 +197,7 @@ void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); /** - * Initializes all the fields a cmdline_parser_params structure + * Initializes all the fields a cmdline_parser_params structure * to their default values * @param params the structure to initialize */ diff --git a/src/cmdlineEnumNG.c.in b/src/cmdlineEnumNG.c.in index 965e96a..e133a4b 100644 --- a/src/cmdlineEnumNG.c.in +++ b/src/cmdlineEnumNG.c.in @@ -1,7 +1,7 @@ /* File autogenerated by gengetopt version 2.22.6 generated with the following command: - gengetopt -i cmdlineEnumNG.ggo -c c.in -H h.in -F cmdlineEnumNG --show-required + gengetopt -i cmdlineEnumNG.ggo -c c.in -H h.in -F cmdlineEnumNG --show-required The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -133,7 +133,7 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->printWarnings_flag = 0; args_info->config_arg = NULL; args_info->config_orig = NULL; - + } static @@ -160,7 +160,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->verboseFile_help = gengetopt_args_info_help[19] ; args_info->printWarnings_help = gengetopt_args_info_help[20] ; args_info->config_help = gengetopt_args_info_help[22] ; - + } void @@ -210,7 +210,7 @@ void cmdline_parser_params_init(struct cmdline_parser_params *params) { if (params) - { + { params->override = 0; params->initialize = 1; params->check_required = 1; @@ -222,9 +222,9 @@ cmdline_parser_params_init(struct cmdline_parser_params *params) struct cmdline_parser_params * cmdline_parser_params_create(void) { - struct cmdline_parser_params *params = + struct cmdline_parser_params *params = (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); + cmdline_parser_params_init(params); return params; } @@ -257,8 +257,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->maxattempts_orig)); free_string_field (&(args_info->config_arg)); free_string_field (&(args_info->config_orig)); - - + + clear_given (args_info); } @@ -325,7 +325,7 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "printWarnings", 0, 0 ); if (args_info->config_given) write_into_file(outfile, "config", args_info->config_orig, 0); - + i = EXIT_SUCCESS; return i; @@ -390,7 +390,7 @@ cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -399,7 +399,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i { int result; struct cmdline_parser_params params; - + params.override = override; params.initialize = initialize; params.check_required = check_required; @@ -413,7 +413,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -448,7 +448,7 @@ static char *package_name = 0; */ static int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, + unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, @@ -470,18 +470,18 @@ int update_arg(void *field, char **orig_field, if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", + fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", package_name, long_opt, short_opt, (additional_error ? additional_error : "")); else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", + fprintf (stderr, "%s: `--%s' option given more than once%s\n", package_name, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ } FIX_UNUSED (default_value); - + if (field_given && *field_given && ! override) return 0; if (prev_given) @@ -556,14 +556,14 @@ cmdline_parser_internal ( int error_occurred = 0; struct gengetopt_args_info local_args_info; - + int override; int initialize; int check_required; int check_ambiguity; - + package_name = argv[0]; - + override = params->override; initialize = params->initialize; check_required = params->check_required; @@ -623,198 +623,198 @@ cmdline_parser_internal ( exit (EXIT_SUCCESS); case 'u': /* Activate username mode using the data in the given file. */ - - - if (update_arg( (void *)&(args_info->username_arg), + + + if (update_arg( (void *)&(args_info->username_arg), &(args_info->username_orig), &(args_info->username_given), &(local_args_info.username_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "username", 'u', additional_error)) goto failure; - + break; case 's': /* Execute a simulated attack against the given target file. */ - - - if (update_arg( (void *)&(args_info->simAtt_arg), + + + if (update_arg( (void *)&(args_info->simAtt_arg), &(args_info->simAtt_orig), &(args_info->simAtt_given), &(local_args_info.simAtt_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "simAtt", 's', additional_error)) goto failure; - + break; case 'p': /* Only print generated Passwords and nothing else (overrides any other mode!). */ - - + + if (update_arg((void *)&(args_info->pipeMode_flag), 0, &(args_info->pipeMode_given), &(local_args_info.pipeMode_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "pipeMode", 'p', additional_error)) goto failure; - + break; case 'a': /* Apply boosting factor alpha. Read alpha values from filename. Alphas need to be in the same order as the hints.. */ - - - if (update_arg( (void *)&(args_info->alpha_arg), + + + if (update_arg( (void *)&(args_info->alpha_arg), &(args_info->alpha_orig), &(args_info->alpha_given), &(local_args_info.alpha_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "alpha", 'a', additional_error)) goto failure; - + break; case 'H': /* File containing the hints for alpha boosting. Need to be in the same order as the alpha values.. */ - - - if (update_arg( (void *)&(args_info->hint_arg), + + + if (update_arg( (void *)&(args_info->hint_arg), &(args_info->hint_orig), &(args_info->hint_given), &(local_args_info.hint_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "hint", 'H', additional_error)) goto failure; - + break; case 'L': /* Apply the given level length factor. Factor should be in range 0.0 to 10.0. */ - - - if (update_arg( (void *)&(args_info->llFactor_arg), + + + if (update_arg( (void *)&(args_info->llFactor_arg), &(args_info->llFactor_orig), &(args_info->llFactor_given), &(local_args_info.llFactor_given), optarg, 0, "0.0", ARG_FLOAT, check_ambiguity, override, 0, 0, "llFactor", 'L', additional_error)) goto failure; - + break; case 'S': /* Set all length level to the given value. Values should be in range 0 to 101. */ - - - if (update_arg( (void *)&(args_info->llSet_arg), + + + if (update_arg( (void *)&(args_info->llSet_arg), &(args_info->llSet_orig), &(args_info->llSet_given), &(local_args_info.llSet_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "llSet", 'S', additional_error)) goto failure; - + break; case 'O': /* Activate optimized length scheduling. */ - - + + if (update_arg((void *)&(args_info->optimizedLS_flag), 0, &(args_info->optimizedLS_given), &(local_args_info.optimizedLS_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "optimizedLS", 'O', additional_error)) goto failure; - + break; case 'l': /* Only generate Passwords of the given length between 3 and 19. Default disabled.. */ - - - if (update_arg( (void *)&(args_info->fixedLength_arg), + + + if (update_arg( (void *)&(args_info->fixedLength_arg), &(args_info->fixedLength_orig), &(args_info->fixedLength_given), &(local_args_info.fixedLength_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "fixedLength", 'l', additional_error)) goto failure; - + break; case 'm': /* Set the amount of passwords created. The value should be in range 10^-1 to 10^12. */ - - - if (update_arg( (void *)&(args_info->maxattempts_arg), + + + if (update_arg( (void *)&(args_info->maxattempts_arg), &(args_info->maxattempts_orig), &(args_info->maxattempts_given), &(local_args_info.maxattempts_given), optarg, 0, 0, ARG_INT, check_ambiguity, override, 0, 0, "maxattempts", 'm', additional_error)) goto failure; - + break; case 'e': /* Generate all possible passwords (this may take a while). */ - - + + if (update_arg((void *)&(args_info->endless_flag), 0, &(args_info->endless_given), &(local_args_info.endless_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "endless", 'e', additional_error)) goto failure; - + break; case 'E': /* Ignore the endProbs while generating Passwords. */ - - + + if (update_arg((void *)&(args_info->ignoreEP_flag), 0, &(args_info->ignoreEP_given), &(local_args_info.ignoreEP_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "ignoreEP", 'E', additional_error)) goto failure; - + break; case 'v': /* Gain information about settings and results during run time. */ - - + + if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given), &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "verbose", 'v', additional_error)) goto failure; - + break; case 'F': /* Stores the generated passwords on hard drive disc (independent of the used mode). */ - - + + if (update_arg((void *)&(args_info->verboseFile_flag), 0, &(args_info->verboseFile_given), &(local_args_info.verboseFile_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "verboseFile", 'F', additional_error)) goto failure; - + break; case 'w': /* Prints any warning (if verbose mode is active).. */ - - + + if (update_arg((void *)&(args_info->printWarnings_flag), 0, &(args_info->printWarnings_given), &(local_args_info.printWarnings_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "printWarnings", 'w', additional_error)) goto failure; - + break; case 'C': /* Change the used config file. */ - - - if (update_arg( (void *)&(args_info->config_arg), + + + if (update_arg( (void *)&(args_info->config_arg), &(args_info->config_orig), &(args_info->config_given), &(local_args_info.config_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "config", 'C', additional_error)) goto failure; - + break; case 0: /* Long option with no short option */ /* Controls wether EPs are boosted or not.. */ if (strcmp (long_options[option_index].name, "boostEP") == 0) { - - + + if (update_arg((void *)&(args_info->boostEP_flag), 0, &(args_info->boostEP_given), &(local_args_info.boostEP_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "boostEP", '-', additional_error)) goto failure; - + } - + break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -838,7 +838,7 @@ cmdline_parser_internal ( return 0; failure: - + cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } diff --git a/src/cmdlineEnumNG.h.in b/src/cmdlineEnumNG.h.in index 54773e4..ee53f3e 100644 --- a/src/cmdlineEnumNG.h.in +++ b/src/cmdlineEnumNG.h.in @@ -82,7 +82,7 @@ struct gengetopt_args_info char * config_arg; /**< @brief Change the used config file. */ char * config_orig; /**< @brief Change the used config file original value given at command line. */ const char *config_help; /**< @brief Change the used config file help description. */ - + unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int username_given ; /**< @brief Whether username was given. */ @@ -190,7 +190,7 @@ void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); /** - * Initializes all the fields a cmdline_parser_params structure + * Initializes all the fields a cmdline_parser_params structure * to their default values * @param params the structure to initialize */ diff --git a/src/cmdlineEvalPW.c.in b/src/cmdlineEvalPW.c.in index 301dc55..95b57b7 100644 --- a/src/cmdlineEvalPW.c.in +++ b/src/cmdlineEvalPW.c.in @@ -1,7 +1,7 @@ /* File autogenerated by gengetopt version 2.22.6 generated with the following command: - gengetopt -i cmdlineEvalPW.ggo -c c.in -H h.in -F cmdlineEvalPW --show-required + gengetopt -i cmdlineEvalPW.ggo -c c.in -H h.in -F cmdlineEvalPW --show-required The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -87,7 +87,7 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->printWarnings_flag = 0; args_info->config_arg = NULL; args_info->config_orig = NULL; - + } static @@ -101,7 +101,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->verbose_help = gengetopt_args_info_help[5] ; args_info->printWarnings_help = gengetopt_args_info_help[6] ; args_info->config_help = gengetopt_args_info_help[8] ; - + } void @@ -151,7 +151,7 @@ void cmdline_parser_params_init(struct cmdline_parser_params *params) { if (params) - { + { params->override = 0; params->initialize = 1; params->check_required = 1; @@ -163,9 +163,9 @@ cmdline_parser_params_init(struct cmdline_parser_params *params) struct cmdline_parser_params * cmdline_parser_params_create(void) { - struct cmdline_parser_params *params = + struct cmdline_parser_params *params = (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); - cmdline_parser_params_init(params); + cmdline_parser_params_init(params); return params; } @@ -188,8 +188,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->pw_orig)); free_string_field (&(args_info->config_arg)); free_string_field (&(args_info->config_orig)); - - + + clear_given (args_info); } @@ -230,7 +230,7 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "printWarnings", 0, 0 ); if (args_info->config_given) write_into_file(outfile, "config", args_info->config_orig, 0); - + i = EXIT_SUCCESS; return i; @@ -295,7 +295,7 @@ cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -304,7 +304,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i { int result; struct cmdline_parser_params params; - + params.override = override; params.initialize = initialize; params.check_required = check_required; @@ -318,7 +318,7 @@ cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, i cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -335,7 +335,7 @@ cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog cmdline_parser_free (args_info); exit (EXIT_FAILURE); } - + return result; } @@ -351,8 +351,8 @@ cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *pro fprintf (stderr, "%s: '--pw' option required%s\n", prog_name, (additional_error ? additional_error : "")); error_occurred = 1; } - - + + /* checks for dependences among options */ return error_occurred; @@ -381,7 +381,7 @@ static char *package_name = 0; */ static int update_arg(void *field, char **orig_field, - unsigned int *field_given, unsigned int *prev_given, + unsigned int *field_given, unsigned int *prev_given, char *value, const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, @@ -403,18 +403,18 @@ int update_arg(void *field, char **orig_field, if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { if (short_opt != '-') - fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", + fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", package_name, long_opt, short_opt, (additional_error ? additional_error : "")); else - fprintf (stderr, "%s: `--%s' option given more than once%s\n", + fprintf (stderr, "%s: `--%s' option given more than once%s\n", package_name, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ } FIX_UNUSED (default_value); - + if (field_given && *field_given && ! override) return 0; if (prev_given) @@ -471,14 +471,14 @@ cmdline_parser_internal ( int error_occurred = 0; struct gengetopt_args_info local_args_info; - + int override; int initialize; int check_required; int check_ambiguity; - + package_name = argv[0]; - + override = params->override; initialize = params->initialize; check_required = params->check_required; @@ -525,54 +525,54 @@ cmdline_parser_internal ( exit (EXIT_SUCCESS); case 'v': /* Gain information about settings and results during run time. */ - - + + if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given), &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "verbose", 'v', additional_error)) goto failure; - + break; case 'w': /* print warnings. */ - - + + if (update_arg((void *)&(args_info->printWarnings_flag), 0, &(args_info->printWarnings_given), &(local_args_info.printWarnings_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "printWarnings", 'w', additional_error)) goto failure; - + break; case 'C': /* Change the used config file. */ - - - if (update_arg( (void *)&(args_info->config_arg), + + + if (update_arg( (void *)&(args_info->config_arg), &(args_info->config_orig), &(args_info->config_given), &(local_args_info.config_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "config", 'C', additional_error)) goto failure; - + break; case 0: /* Long option with no short option */ /* Password to evaluate. */ if (strcmp (long_options[option_index].name, "pw") == 0) { - - - if (update_arg( (void *)&(args_info->pw_arg), + + + if (update_arg( (void *)&(args_info->pw_arg), &(args_info->pw_orig), &(args_info->pw_given), &(local_args_info.pw_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "pw", '-', additional_error)) goto failure; - + } - + break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -599,7 +599,7 @@ cmdline_parser_internal ( return 0; failure: - + cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } diff --git a/src/cmdlineEvalPW.h b/src/cmdlineEvalPW.h deleted file mode 100644 index feeebf1..0000000 --- a/src/cmdlineEvalPW.h +++ /dev/null @@ -1,193 +0,0 @@ -/** @file cmdlineEvalPW.h.in - * @brief The header file for the command line option parser - * generated by GNU Gengetopt version 2.22.6 - * http://www.gnu.org/software/gengetopt. - * DO NOT modify this file, since it can be overwritten - * @author GNU Gengetopt by Lorenzo Bettini */ - -#ifndef CMDLINEEVALPW_H -#define CMDLINEEVALPW_H - -/* If we use autoconf. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include /* for FILE */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifndef CMDLINE_PARSER_PACKAGE -/** @brief the program name (used for printing errors) */ -#define CMDLINE_PARSER_PACKAGE "evalPW" -#endif - -#ifndef CMDLINE_PARSER_PACKAGE_NAME -/** @brief the complete program name (used for help and version) */ -#define CMDLINE_PARSER_PACKAGE_NAME "evalPW" -#endif - -#ifndef CMDLINE_PARSER_VERSION -/** @brief the program version */ -#define CMDLINE_PARSER_VERSION "0.0.2" -#endif - -/** @brief Where the command line options are stored */ - struct gengetopt_args_info - { - const char *help_help; - /**< @brief Print help and exit help description. */ - const char *version_help; - /**< @brief Print version and exit help description. */ - char *pw_arg; /**< @brief Password to evaluate. */ - char *pw_orig;/**< @brief Password to evaluate original value given at command line. */ - const char *pw_help; - /**< @brief Password to evaluate help description. */ - int verbose_flag; - /**< @brief Gain information about settings and results during run time (default=off). */ - const char *verbose_help; - /**< @brief Gain information about settings and results during run time help description. */ - int printWarnings_flag; - /**< @brief print warnings (default=off). */ - const char *printWarnings_help; - /**< @brief print warnings help description. */ - char *config_arg; /**< @brief Change the used config file. */ - char *config_orig;/**< @brief Change the used config file original value given at command line. */ - const char *config_help; - /**< @brief Change the used config file help description. */ - - unsigned int help_given;/**< @brief Whether help was given. */ - unsigned int version_given; /**< @brief Whether version was given. */ - unsigned int pw_given;/**< @brief Whether pw was given. */ - unsigned int verbose_given; /**< @brief Whether verbose was given. */ - unsigned int printWarnings_given; /**< @brief Whether printWarnings was given. */ - unsigned int config_given;/**< @brief Whether config was given. */ - - }; - -/** @brief The additional parameters to pass to parser functions */ - struct cmdline_parser_params - { - int override; - /**< @brief whether to override possibly already present options (default 0) */ - int initialize; - /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ - int check_required; - /**< @brief whether to check that all required options were provided (default 1) */ - int check_ambiguity; - /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ - int print_errors; - /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ - }; - -/** @brief the purpose string of the program */ - extern const char *gengetopt_args_info_purpose; -/** @brief the usage string of the program */ - extern const char *gengetopt_args_info_usage; -/** @brief the description string of the program */ - extern const char *gengetopt_args_info_description; -/** @brief all the lines making the help output */ - extern const char *gengetopt_args_info_help[]; - -/** - * The command line parser - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info); - -/** - * The command line parser (version with additional parameters - deprecated) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param override whether to override possibly already present options - * @param initialize whether to initialize the option structure my_args_info - * @param check_required whether to check that all required options were provided - * @return 0 if everything went fine, NON 0 if an error took place - * @deprecated use cmdline_parser_ext() instead - */ - int cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required); - -/** - * The command line parser (version with additional parameters) - * @param argc the number of command line options - * @param argv the command line options - * @param args_info the structure where option information will be stored - * @param params additional parameters for the parser - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params); - -/** - * Save the contents of the option struct into an already open FILE stream. - * @param outfile the stream where to dump options - * @param args_info the option struct to dump - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_dump (FILE * outfile, struct gengetopt_args_info *args_info); - -/** - * Save the contents of the option struct into a (text) file. - * This file can be read by the config file parser (if generated by gengetopt) - * @param filename the file where to save - * @param args_info the option struct to save - * @return 0 if everything went fine, NON 0 if an error took place - */ - int cmdline_parser_file_save (const char *filename, struct gengetopt_args_info *args_info); - -/** - * Print the help - */ - void cmdline_parser_print_help (void); -/** - * Print the version - */ - void cmdline_parser_print_version (void); - -/** - * Initializes all the fields a cmdline_parser_params structure - * to their default values - * @param params the structure to initialize - */ - void cmdline_parser_params_init (struct cmdline_parser_params *params); - -/** - * Allocates dynamically a cmdline_parser_params structure and initializes - * all its fields to their default values - * @return the created and initialized cmdline_parser_params structure - */ - struct cmdline_parser_params *cmdline_parser_params_create (void); - -/** - * Initializes the passed gengetopt_args_info structure's fields - * (also set default values for options that have a default) - * @param args_info the structure to initialize - */ - void cmdline_parser_init (struct gengetopt_args_info *args_info); -/** - * Deallocates the string fields of the gengetopt_args_info structure - * (but does not deallocate the structure itself) - * @param args_info the structure to deallocate - */ - void cmdline_parser_free (struct gengetopt_args_info *args_info); - -/** - * Checks that all the required options were specified - * @param args_info the structure to check - * @param prog_name the name of the program that will be used to print - * possible errors - * @return - */ - int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* CMDLINEEVALPW_H */ diff --git a/src/cmdlineEvalPW.h.in b/src/cmdlineEvalPW.h.in index ce1497e..0fc4b58 100644 --- a/src/cmdlineEvalPW.h.in +++ b/src/cmdlineEvalPW.h.in @@ -49,7 +49,7 @@ struct gengetopt_args_info char * config_arg; /**< @brief Change the used config file. */ char * config_orig; /**< @brief Change the used config file original value given at command line. */ const char *config_help; /**< @brief Change the used config file help description. */ - + unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int pw_given ; /**< @brief Whether pw was given. */ @@ -144,7 +144,7 @@ void cmdline_parser_print_help(void); void cmdline_parser_print_version(void); /** - * Initializes all the fields a cmdline_parser_params structure + * Initializes all the fields a cmdline_parser_params structure * to their default values * @param params the structure to initialize */ diff --git a/src/common.c b/src/common.c index e24e3fc..f6c7c05 100644 --- a/src/common.c +++ b/src/common.c @@ -1,4 +1,4 @@ -/* +/* * common.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -15,7 +15,7 @@ #include "commonStructs.h" #include "errorHandler.h" -/* +/* * Abbreviations in common use: * - len = length * - nG = nGram diff --git a/src/common.h b/src/common.h index c911051..7a64726 100644 --- a/src/common.h +++ b/src/common.h @@ -1,4 +1,4 @@ -/* +/* * common.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -21,7 +21,7 @@ // === common enums === -/* +/* * Used by the read_array function. * It is used to determine the type of an given array. */ @@ -39,19 +39,19 @@ extern const char arrayType_names[ARRAY_TYPES_COUNT][3]; // === common functions === -/* +/* * Sets @position to the position of char @c in the given @alphabet. * Returns FALSE if @c isn't a part of the alphabet. */ bool get_positionInAlphabet (int *position, char c, const char *alphabet, int sizeOf_alphabet); -/* +/* * Sets @c to the char at @position in the given @alphabet. * Returns FALSE if @position >= @sizeOf_alphabet. */ bool get_charAtPosition (char *c, int position, const char *alphabet, int sizeOf_alphabet); -/* +/* * Sets @position to the actual position of the given @nGram * in an array storing nGrams with at least @sizeOfN characters. * The calculation is based on the given @alphabet with a length @@ -60,7 +60,7 @@ bool get_charAtPosition (char *c, int position, const char *alphabet, int sizeOf */ bool get_positionFromNGram (int *position, const char nGram[], int sizeOf_N, int sizeOf_alphabet, const char *alphabet); -/* +/* * Sets @position to the actual position of the given @nGramAsInt * in an array storing the corresponding integer of a nGram with * at least @sizeOfN characters. @@ -68,7 +68,7 @@ bool get_positionFromNGram (int *position, const char nGram[], int sizeOf_N, int */ void get_positionFromNGramAsInt (int *position, const int nGramAsInt[], int sizeOf_N, int sizeOf_alphabet); -/* +/* * Fills @nGram with the actual character according to the * given position @position, based on the given @alphabet * with a length of @szieOf_alphabet. @@ -76,7 +76,7 @@ void get_positionFromNGramAsInt (int *position, const int nGramAsInt[], int size */ void get_nGramFromPosition (char *nGram, int position, int sizeOf_N, int sizeOf_alphabet, const char *alphabet); -/* +/* * Fills @nGramAsInt with the positions in the alphabet to * the corresponding nGram according to the given position * @position, based on the given @alphabet with a length of @@ -85,32 +85,32 @@ void get_nGramFromPosition (char *nGram, int position, int sizeOf_N, int sizeOf_ */ void get_nGramAsIntFromPosition (int *nGramAsInt, int position, int sizeOf_N, int sizeOf_alphabet); -/* +/* * allocates (or reallocates) @*str and copies the c-string @src */ bool str_allocCpy (char **str, const char *src); -/* +/* * Appends the given @prefix to the given @str */ bool str_appendPrefix (char **str, const char *prefix); -/* +/* * Appends the given @suffix to given @str */ bool str_appendSuffix (char **str, const char *suffix); -/* +/* * Replaces all chars @oldChar in @str with @newChar */ void str_replace (char *str, const char oldChar, const char newChar); -/* +/* * Prints a time stamp with the given title */ void print_timestamp (const char *title); -/* +/* * Prints timestamp with time different between now and the first time * this function has been called (or just the timestamp, if it's the first time) * This function automatically prints a title in addition to the timestamp @@ -125,14 +125,14 @@ void set_timestampWithDiff (FILE * fp, // write information to the given FILE ( bool printStamp, // if FALSE the timestamp is just set and not printed bool rePrintStartTime); // re prints the start time -/* +/* * Creates a formated string containing the current date and time. The string * is formated like this: "Year-Month-Day_Houre.Minute" with 2 digits each. Therefore * the given pointer to a c-string must be able to store at least 15 chars. */ void get_formatedTime (char (*timeStr)[15]); // 15 = 9: date(YY-MM-DD_) + 5: time(HH.MM) + 1: (\0) -/* +/* * Prints default information. * The information can be written to stdout or to a log-file * (set by @fp) @@ -143,7 +143,7 @@ void print_settings_default (FILE * fp, // write information to the given FILE ( unsigned int maxLevel, // selected max level bool verboseFileMode); // is verboseFileMode active? -/* +/* * Opens the file under the given @filename adding the @attachment. * The file is opened with the rights given by @type. * True is returned, if the file could be opened successful. @@ -157,7 +157,7 @@ bool open_file (FILE ** fp, // file pointer const char *type); // write or read mode -/* +/* * Changes output filename for any given filename. * Reallocates memory for filename and copies content. * If the filename is to long, an error is set to the @errorHandler, diff --git a/src/commonStructs.c b/src/commonStructs.c index 00d7619..69c97b4 100644 --- a/src/commonStructs.c +++ b/src/commonStructs.c @@ -1,4 +1,4 @@ -/* +/* * commonStructs.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/commonStructs.h b/src/commonStructs.h index b3a5d5b..b6f4625 100644 --- a/src/commonStructs.h +++ b/src/commonStructs.h @@ -1,4 +1,4 @@ -/* +/* * commonStructs.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -17,7 +17,7 @@ // TODO: rewrite this in c++ (allows easier optimizations) // === common structs === -/* +/* * Encapsulates the input or output filenames for conditionalProb, * initalProb, length and config. */ @@ -32,7 +32,7 @@ typedef struct filename_struct char *smoo; // filename for smoothing function } filename_struct; -/* +/* * Encapsulates the different nGram and length arrays * for the counts and the level as well as the size of * the nGram 'n'. The data is stored as follows: @@ -58,7 +58,7 @@ typedef struct nGram_struct int sizeOf_N; // size of the nGram 'n' (size of iP and eP equals sizeOf_N - 1) } nGram_struct; -/* +/* * Contains the alphabet as c-string an the size of this * alphabet. */ @@ -68,7 +68,7 @@ typedef struct alphabet_struct int sizeOf_alphabet; // strlen(alphabet) + 1 } alphabet_struct; -/* +/* * Contains a 2 dimensional array @lastGram where any last gram is sorted by * the leading gram (the so called mGram). Once set, the 1st dimension equals * the first (n-1) of a cP and the 2nd dimension increases dynamically @@ -85,7 +85,7 @@ typedef struct sortedLastGram_struct int *indexMax; // max value for 2nd dimensions of @lastGrams ( (if indexCur == indexMax) -> reallocate lastGrams[i]) } sortedLastGram_struct; -/* +/* * Contains a 1 dimensional array @iP where the 1st dimension increases dynamically * (using @indexCur and @indexMax), containing the position of the according initialProb. * The struct is used to store the iPs sorted by level (using an array of @@ -99,7 +99,7 @@ typedef struct sortedIP_struct int indexMax; // maximal index of iP( (if indexCur == indexMax) -> reallocate iP) } sortedIP_struct; -/* +/* * Contains two 1 dimensional arrays (@level and @length), which are correlated to each other. * The @length at index x has the level stored in @level at index x. * @lengthMin stores the minimum level which equals the sizeOf_N - 1 (there can be now PW @@ -113,7 +113,7 @@ typedef struct sortedLength_struct } sortedLength_struct; // === struct function === -/* +/* * The functions allocate memory for the given struct and * set each value to NULL. * If the allocation for the struct fails, this function @@ -133,7 +133,7 @@ void struct_sortedIP_initialize (int maxLevel, struct sortedIP_struct **sortedIP void struct_sortedLength_initialize (struct sortedLength_struct **sortedLength); -/* +/* * These functions allocate memory for the content of the given struct * setting them to the default values. * If the allocation for the content fails, this function @@ -143,7 +143,7 @@ void struct_filenames_allocateDefaults (struct filename_struct *filenames); void struct_alphabet_allocateDefaults (struct alphabet_struct *alphabet); -/* +/* * These functions calculate the sizes of the arrays in @nGrams based * on the size of the given @alphabet and allocate the needed nGram arrays. * The alphabet must be set before using this function! @@ -152,7 +152,7 @@ void struct_alphabet_allocateDefaults (struct alphabet_struct *alphabet); */ void struct_nGrams_allocate (struct nGram_struct *nGrams, struct alphabet_struct *alphabet); -/* +/* * This function copies the content of the nGram_struct @src to * the nGram_struct @dest. * (dest must be initialized) @@ -160,7 +160,7 @@ void struct_nGrams_allocate (struct nGram_struct *nGrams, struct alphabet_struct void struct_nGrams_copyArrays (struct nGram_struct *dest, // destination (must be initialized) struct nGram_struct *src); // source -/* +/* * These functions free any memory allocated by the structs (including the struct) */ void struct_nGrams_free (struct nGram_struct **arrays); @@ -175,7 +175,7 @@ void struct_sortedIP_free (int maxLevel, struct sortedIP_struct **sortedIPStruct void struct_sortedLength_free (struct sortedLength_struct **sortedLength); -/* +/* * Fills the @sortedLastGram struct with the positions found * in @source, where @sortedLastGram[x] contains all positions with Level x. * Therefore the size of @sortedLastGram must be at least MAX_LEVEL. @@ -186,7 +186,7 @@ void struct_sortedLastGram_fill (int maxLevel, struct sortedLastGram_struct *sor int sizeOf_N, // size of the nGram n int sizeOf_alphabet); // size of the used alphabet -/* +/* * Fills the @sortedIP struct with the positions found * in @source, where @sortedIP[x] contains all positions with Level x. * Therefore the size of @sortedIP must be at least MAX_LEVEL. @@ -195,7 +195,7 @@ void struct_sortedIP_fill (int maxLevel, struct sortedIP_struct *sortedIP, // d int *source, // source (unsorted iP array) int source_size); // size of source array -/* +/* * Sorts the given length array @source, storing it in the @sortedLength struct. * The minimum level equals sizeOf_N - 1 (because there can be now PW shorter than that). * The @levelModifire works as follows: the level of each length is adjusted by the actual @@ -210,7 +210,7 @@ void struct_sortedLength_fill (struct sortedLength_struct *sortedLength, // des float levelModifire, // this value defines how much the actual length modified the level of each length int levelSet); // if != -1, set all level to this value before applying the levelModifire -/* +/* * This functions returns the index of the first item stored in @sortedLength * with a level larger then @level. The lengths stored in @sortedLength must be sorted * by level before calling this function (using struct_fill_sortedLength). diff --git a/src/createNG.c b/src/createNG.c index dc21f9f..d7ebfdf 100644 --- a/src/createNG.c +++ b/src/createNG.c @@ -1,4 +1,4 @@ -/* +/* * createNG.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/createNG.h b/src/createNG.h index ad8ca55..fbf2a3d 100644 --- a/src/createNG.h +++ b/src/createNG.h @@ -1,4 +1,4 @@ -/* +/* * createNG.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -14,7 +14,7 @@ #include "errorHandler.h" #include "smoothing.h" -/* +/* * Used by the write_*ToFile functions. * - if writeMode is nonVerbose: only the counts and levels are written into the file * - if writeMode is numeric: the array index is written into the file as well @@ -27,7 +27,7 @@ enum writeModes }; // === intern functions === -/* +/* * These functions are used to adjust the according array based on the given file or length: * void adjust_length(); * void adjust_initialProb(); @@ -41,13 +41,13 @@ enum writeModes // === public functions === -/* +/* * initializes all global parameters, setting them to their default value * !! this function must be called before any other operation !! */ void initialize (); -/* +/* * prints all Error-Messages (if any), clears the allocated memory of the * global variables and ends the application * the char* exit_msg is printed out on the command line @@ -55,7 +55,7 @@ void initialize (); */ void exit_routine (); -/* +/* * evaluates given command line arguments using the getopt-library * there has to be at least 1 argument: the input filename * additional arguments are evaluated in this method an the @@ -64,7 +64,7 @@ void exit_routine (); */ bool evaluate_arguments (struct gengetopt_args_info *args_info); -/* +/* * main process: calls evaluate_InputFile and the Write-Methods * returns TRUE, if the creation was successful (no Errors occurred) * otherwise FALSE is returned and the occurred Errors can be viewed using @@ -72,7 +72,7 @@ bool evaluate_arguments (struct gengetopt_args_info *args_info); */ bool run_creation (); -/* +/* * evaluates the input file, reading the 3grams, initial probabilities and the pwd lengths * and storing them in the associated global variables * 1. counts the occurrence of any n-gram in the input file (stored in glbl_nGramCount->nG) @@ -81,7 +81,7 @@ bool run_creation (); */ bool evaluate_inputFile (const char *filenameIn); -/* +/* * Writes header and additional information into the given file * the additional information are chosen filenames * header syntax: @@ -90,7 +90,7 @@ bool evaluate_inputFile (const char *filenameIn); */ bool write_config (const char *filenameConfig); -/* +/* * Opens the given files and writes data according to the given * @arrayType. This may be: * - arrayType_nGram @@ -101,13 +101,13 @@ bool write_config (const char *filenameConfig); */ bool write_array (const char *filename, enum arrayTypes arrayType); -/* +/* * Prints the by arguments selected mode as well as the output and input filenames * to the given file pointer @fp. */ void print_settings_createNG (FILE * fp); -/* +/* * Sets @alphabet according to file under the filename @filename * and adjust @sizeOf_alphabet to the size of the new alphabet. * If there are problems opening or reading the file, an error @@ -118,7 +118,7 @@ bool alphabetFromFile (char **alphabet, // pointer to the (old) alphabet int *sizeOf_alphabet, // pointer to the size of the (old) alphabet const char *filename); // new alphabet -/* +/* * Appends any given @prefix, @suffix or the current date (if @dateSuffix is TRUE) * as suffix to all output filenames. * The allocated memory for the char* is freed by this function. diff --git a/src/defines.h b/src/defines.h index c64f1ea..08eb575 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,4 +1,4 @@ -/* +/* * defines.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -6,7 +6,7 @@ #ifndef DEFINES_H__ #define DEFINES_H__ -/* +/* * DEBUG mode * - 1: debug mode (print debug information to stdout) * - 0: release mode (don't print any debug information) @@ -15,25 +15,25 @@ // === common defines === -/* +/* * clean operation, which checks, if the given is not NULL before calling free */ #define CHECKED_FREE(ptr) if (ptr != NULL) { free(ptr); ptr = NULL; } -/* +/* * Wrapper arround exit(int) to gain access to the exit status in the exit_routine */ extern int exit_status; #define exit(x) (exit)(exit_status = (x)); -/* +/* * If given pointer equals NULL, * exit application printing an "Out of Memory" error */ #define EXIT_IF_NULL(ptr) if (ptr == NULL) { printf("Critical Error: Out of Memory\n"); exit(1); } -/* +/* * default names, attachment and lengths for the the output files */ // default output file for ngram @@ -56,7 +56,7 @@ extern int exit_status; #define MAX_ATTACHMENT_LENGTH ((strlen(DEFAULT_FILE_ATTACHMENT_LEVEL) >= strlen(DEFAULT_FILE_ATTACHMENT_COUNT)) ? \ strlen(DEFAULT_FILE_ATTACHMENT_LEVEL) : strlen(DEFAULT_FILE_ATTACHMENT_COUNT)) -/* +/* * alphabet, alphabet sizes and the corresponding nGram sizes */ // default alphabet @@ -72,7 +72,7 @@ extern int exit_status; // size of 3-gram using default alphabet #define DEFAULT_SIZE_3_GRAM (DEFAULT_ALPHABET_SIZE * DEFAULT_ALPHABET_SIZE * DEFAULT_ALPHABET_SIZE) -/* +/* * password length and level bounds */ // maximum password length diff --git a/src/enumNG.c b/src/enumNG.c index a04a1fa..c6e789c 100644 --- a/src/enumNG.c +++ b/src/enumNG.c @@ -1,4 +1,4 @@ -/* +/* * enumNG.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/enumNG.h b/src/enumNG.h index 3e5c3da..7139fda 100644 --- a/src/enumNG.h +++ b/src/enumNG.h @@ -1,4 +1,4 @@ -/* +/* * enumNG.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -19,7 +19,7 @@ #define DEFAULT_OUTPUT_CYCLE_FACTOR 1000 #define DEFAULT_MAX_ATTEMPTS 1000000000 #define MAX_MAX_ATTEMPTS 1000000000000000 -/* +/* * These variables are needed for the attackSimulator functions * and are therefore declared as extern. */ @@ -28,13 +28,13 @@ extern uint64_t glbl_createdLengths[MAX_PASSWORD_LENGTH]; // counting the length // === public functions === -/* +/* * initializes all global parameters, setting them to their default value * !! this function must be called before any other operation !! */ void initialize (); -/* +/* * prints all Error-Messages (if any), clears the allocated memory of the * global variables and ends the application * the char* exit_msg is printed out on the command line @@ -42,7 +42,7 @@ void initialize (); */ void exit_routine (); -/* +/* * Evaluates given command line arguments * there has to be at least 1 argument: the input filename * additional arguments are evaluated in this method an the @@ -51,7 +51,7 @@ void exit_routine (); */ bool evaluate_arguments (struct gengetopt_args_info *args_info); -/* +/* * Reads any needed input file using the nGramIO-functions and * sets all needed variables accordingly. * Returns TRUE on success and FALSE if something went wrong. @@ -59,7 +59,7 @@ bool evaluate_arguments (struct gengetopt_args_info *args_info); bool apply_settings (); bool sort_ngrams (); -/* +/* * main process: runs the password enumeration * Generates levelChains using the generate_levelChain_live function. * Once a levelChain is found, the actual passwords are generated @@ -72,7 +72,7 @@ void run_enumeration (); void run_enumeration_fixedLenghts (); void run_enumeration_optimizedLengths (); -/* +/* * Generates the next levelChain based on the given @levelChain, with * a @length and a level of @levelMax. * To generate a levelChain with different length or level, reset each value @@ -88,7 +88,7 @@ bool getNext_levelChain (int levelChain[MAX_PASSWORD_LENGTH], // next levelChain int levelMax, // sum level for the next levelChain bool newChain); // new chain? or create one on based the given levelChain? -/* +/* * Generates the first chars of a new Password. The used initialProbs * have a level equal to @iP_level. Calls the intern function * enumerate_password_recursivly to generate the rest of each password. @@ -97,7 +97,7 @@ bool getNext_levelChain (int levelChain[MAX_PASSWORD_LENGTH], // next levelChain bool enumerate_password (int levelChain[MAX_PASSWORD_LENGTH], // levelChain specifying the level of each char in the passwords int lengthMax); // length of the passwords to be generated -/* +/* * Creates a new result folder under the subfolder "results". The created * folder is named after the current date and time ("Year-Mon-Day_Hou.Min"). * If the folder all ready exist, an incrementing integer is appended. @@ -107,19 +107,19 @@ bool enumerate_password (int levelChain[MAX_PASSWORD_LENGTH], // levelChain spec */ void create_resultFolder (); -/* +/* * Prints the by arguments selected mode as well as the output and input filenames * to the given file pointer @fp. */ void print_settings_enumNG (FILE * fp); -/* +/* * Prints the results of the current run through if the verboseMode is active * to the given file pointer @fp. */ void print_report_enumNG (FILE * fp); -/* +/* * Prints a log file under. * Returns TRUE if the log file creation was successful, FALSE if not. */ @@ -129,7 +129,7 @@ bool boost_allHints (); bool boostingMode (); -/* +/* * Handles signal "ctrl + c" for application abortion */ void sigint_handler (int s); diff --git a/src/errorHandler.c b/src/errorHandler.c index 280af6b..ce455b3 100644 --- a/src/errorHandler.c +++ b/src/errorHandler.c @@ -1,4 +1,4 @@ -/* +/* * errorHandler.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/errorHandler.h b/src/errorHandler.h index bd8a073..a58c78c 100644 --- a/src/errorHandler.h +++ b/src/errorHandler.h @@ -1,4 +1,4 @@ -/* +/* * errorHandler.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -26,7 +26,7 @@ #include "common.h" -/* +/* * Used to identify an error. */ enum errorTypes diff --git a/src/evalPW.c b/src/evalPW.c index 6667678..bb2d324 100644 --- a/src/evalPW.c +++ b/src/evalPW.c @@ -1,4 +1,4 @@ -/* +/* * evalPW.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum diff --git a/src/evalPW.h b/src/evalPW.h index a9d0504..9b49e26 100644 --- a/src/evalPW.h +++ b/src/evalPW.h @@ -1,4 +1,4 @@ -/* +/* * evalPW.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -12,13 +12,13 @@ #include "common.h" -/* +/* * initializes all global parameters, setting them to their default value * !! this function must be called before any other operation !! */ void initialize (); -/* +/* * prints all Error-Messages (if any), clears the allocated memory of the * global variables and ends the application * the char* exit_msg is printed out on the command line @@ -26,12 +26,12 @@ void initialize (); */ void exit_routine (); -/* +/* * prints the by arguments selected mode as well as the output and input filenames */ void print_settings (); -/* +/* * Evaluates given command line arguments using the getopt-library * there has to be at least 1 argument: the input filename * additional arguments are evaluated in this method an the @@ -40,14 +40,14 @@ void print_settings (); */ bool evaluate_arguments (struct gengetopt_args_info *args_info); -/* +/* * Reads any needed input file using the nGramIO-functions and * sets all needed variables accordingly. * Returns TRUE on success and FALSE if something went wrong. */ bool apply_settings (); -/* +/* * Evaluates the password given by command line argument and * prints the overall level. * Returns FALSE, if the password is to short. diff --git a/src/nGramReader.c b/src/nGramReader.c index fe2ce58..7a95227 100644 --- a/src/nGramReader.c +++ b/src/nGramReader.c @@ -1,4 +1,4 @@ -/* +/* * nGramReader.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -33,7 +33,7 @@ bool read_config (struct nGram_struct *nGrams, struct alphabet_struct *alphabet, while (fgets (curLine, sizeof (curLine) - 1, fp) != NULL) { sscanf (curLine, "# -%s %s", argName, argValue); - /* + /* * known header options: * alphabet %s * alphabetsize %i diff --git a/src/nGramReader.h b/src/nGramReader.h index 4e0e570..8446de5 100644 --- a/src/nGramReader.h +++ b/src/nGramReader.h @@ -1,4 +1,4 @@ -/* +/* * nGramReader.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -16,7 +16,7 @@ // === intern functions === -/* +/* * // reads config file * BOOL read_config(); * @@ -35,7 +35,7 @@ // === public funtions === -/* +/* * Reads all needed input files (levels for nGram and initalProb, count and levels for lengths) * based on the config file that must be set in filenames, creating the filenames (attaching * the default file ending) and sets the corresponding @nGrams and @alphabet variables using the diff --git a/src/smoothing.c b/src/smoothing.c index 561aefc..4fb78ee 100644 --- a/src/smoothing.c +++ b/src/smoothing.c @@ -1,4 +1,4 @@ -/* +/* * smoothing.c * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -18,7 +18,7 @@ // the (extern) smoo_selection smoo_selection_struct smoo_selection; -/* +/* * Begin: additive smoothing * Simple +1 smoothing. Just add delta (= 1 default) to any n-Gram count and * adjust the denominator accordingly. @@ -131,7 +131,7 @@ void smoo_additive_funct_conditional (char *level, // level to be set *level = maxLevel - 1; } -/* +/* * The additive smoothing supports a different levelAdjustFactor and delta * for each arrayType. These are a wrapper around the actual * smoothing function selecting thchare according parameter. diff --git a/src/smoothing.h b/src/smoothing.h index 7479681..adddc1e 100644 --- a/src/smoothing.h +++ b/src/smoothing.h @@ -1,4 +1,4 @@ -/* +/* * smoothing.h * @authors: Fabian Angelstorf, Franziska Juckel * @copyright: Horst Goertz Institute for IT-Security, Ruhr-University Bochum @@ -14,7 +14,7 @@ #include #include "common.h" -/* +/* * How to implement new smoothings: * * Every smoothing needs a own struct to store the different parameters @@ -52,13 +52,13 @@ int, int, char, \ int) -/* +/* * enum used to identify the selected smoothing function */ enum smooTypes { smooType_additive = 0 }; // additve smoothing (default) -/* +/* * smoo_selection_struct stores the pointer to the selected smoothing functions. * It is declared as extern, so createNG can directly call the smoothing functions */ @@ -74,13 +74,13 @@ typedef struct smoo_selection_struct extern smoo_selection_struct smoo_selection; -/* +/* * Sets the variables of all smoothings to their default value. * The smoo_selection is set to the additve smoothing. */ void smoo_initialize (); -/* +/* * Opens the given file, checks which smoothing has been * selected and calls the according read function. * The input file must be an file formated like explained above. @@ -88,7 +88,7 @@ void smoo_initialize (); */ bool smoo_readInput (const char *filename); -/* +/* * Uses smoo_types enum to identify the selected array * and calls the according print function */ diff --git a/src/uthash.h b/src/uthash.h index 1fc8ead..46edea0 100644 --- a/src/uthash.h +++ b/src/uthash.h @@ -1071,4 +1071,4 @@ typedef struct UT_hash_handle { unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; -#endif /* UTHASH_H */ \ No newline at end of file +#endif /* UTHASH_H */