MakeTrainingset/src/hashcat_utils.c
/*
Load and parse hashcat rules from file (code from hashcat legacy)
*/
Load and parse hashcat rules from file (code from hashcat legacy)
Load and parse hashcat rules from file ( code from hashcat legacy )
void loadRulesFromFile(const char* file_rules, rules_t *rules){
    char rule_buf[BUFSIZ];
    int rule_len = 0;
    FILE *fp = NULL;
    int  rc = 0;
     if (file_rules != NULL){
          if ((fp = fopen (file_rules, "rb")) != NULL){
          while ((rule_len = fgetl (fp, rule_buf)) != -1){
              if (rule_len == 0){
              continue;
          }
          if (rule_buf[0] == '#'){
              continue;
          }
          rc = add_rule(rule_buf, rule_len, rules);
          if (rc == 0){
          } else if (rc == -1){
              fprintf(stderr,"[WARN]: Skipping rule: %s (syntax error)", rule_buf);
          } else if (rc == -3){
              fprintf(stderr,"[WARN]: Skipping rule: %s (duplicate rule)", rule_buf);
          } else if (rc == -4){
              fprintf(stderr,"[WARN]: Skipping rule: %s (duplicate result)", rule_buf);
          }
        }
        fclose (fp);
        } else {
            fprintf(stderr,"[ERROR]: %s: %s", file_rules, strerror (errno));
            exit(EXIT_FAILURE);
        }
     } else {
        fprintf(stderr,"[ERROR]: rules file is missing\n");
        exit(EXIT_FAILURE);
     }
}
void loadRulesFromFile ( const char * file_rules , rules_t * rules ) { char rule_buf [ BUFSIZ ] ; int rule_len = 0 ; FILE * fp = NULL ; int rc = 0 ; if ( file_rules != NULL ) { if ( ( fp = fopen ( file_rules , " " ) ) != NULL ) { while ( ( rule_len = fgetl ( fp , rule_buf ) ) != -1 ) { if ( rule_len == 0 ) { continue ; } if ( rule_buf [ 0 ] == ' ' ) { continue ; } rc = add_rule ( rule_buf , rule_len , rules ) ; if ( rc == 0 ) { } else if ( rc == -1 ) { fprintf ( stderr , " " , rule_buf ) ; } else if ( rc == -3 ) { fprintf ( stderr , " " , rule_buf ) ; } else if ( rc == -4 ) { fprintf ( stderr , " " , rule_buf ) ; } } fclose ( fp ) ; } else { fprintf ( stderr , " " , file_rules , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } } else { fprintf ( stderr , " \n " ) ; exit ( EXIT_FAILURE ) ; } }
Load and parse hashcat rules from file (code from hashcat legacy)
Load and parse hashcat rules from file ( code from hashcat legacy )
/* all ok */