int main(int argc, char **argv) {
  if(argc < 3) {
    printf("usage: %s <encrypted_file> <dict1> [dict2] ...\n",argv[0]);
    printf("  <encrypted_file> : encrypted password file, one per line\n");
    printf("  <dict1>          : dictionary to try for passwords for word 1\n");
    printf("  [dict2]          : additional dictionary to try for word 2\n");
    printf("                   : further dictionaries may be specified for more words\n");
    return 0;
  }

  //check env variable for number of threads
  int nthreads = 4;
  char *nthreads_str = getenv("PASSCRACK_NUMTHREADS");
  if(nthreads_str != NULL){
    nthreads = atoi(nthreads_str);
  }

  // Load the passwords from a file
  dict_t *passwords = dict_load(argv[1]);
  printf("found %d passwords to crack\n",dict_get_word_count(passwords));

  // Load all dictionaries of words
  char **dict_files = &(argv[2]);
  int dicts_len = argc-2;
  dict_t **dicts = dict_load_dicts(dict_files, dicts_len);

  // Show information on loaded dictionaries and compute the maximum
  // length of the temporary buffer required to accomodate all
  // possible passwords.
  int buflen = 0;
  for(int i=0; i<dicts_len; i++){
    printf("dict %d: %d words\n",i,dict_get_word_count(dicts[i]));
    buflen += dict_get_longest_word_length(dicts[i]);
  }
  char *buf = malloc(buflen * sizeof(char));

  // Loop through each password in the password file and attempt to
  // crack it.
  int successes = 0;
  for(int i=0; i<dict_get_word_count(passwords); i++){
    // int i = 0;
      char *encrypted = dict_get_word(passwords,i);
      int success = try_crackpthread(encrypted, dicts, dicts_len, 0,
				       buf, buflen, 0,nthreads);
      if(success == 1){
	printf("%3d: SUCCES: %s <-- %s\n",i,encrypted,buf);
	successes++;
      }
      else{
	printf("%3d: FAILED: %s <-- %s\n",i,encrypted,"???");
      }
    }
  printf("%d / %d passwords cracked\n",successes,dict_get_word_count(passwords));

  // Free up memory and bail out
  dict_free(passwords);
  dict_free_dicts(dicts, dicts_len);
  free(buf);
  return 0;
}
Пример #2
0
///////////////////////
//test <test.dict>
int main(int argc, char * argv[]) {
	struct mg_server * server;
	//
	if(argc < 2) {
		printf("demo: %s <test.dict>\n", argv[0]);
		exit(0);
	}
	//
	dbox = dict_init();
	dict_load(dbox, argv[1]);
	//
	server = mg_create_server(NULL, ev_handler);
	//
	mg_set_option(server, "listening_port", "8089");
	//
	for(;;) {
		mg_poll_server(server, 1000);
	}
	//
	mg_destroy_server(&server);
	//
	dict_free(dbox);
	//
	return 0;
}
Пример #3
0
/*******************************************************************
* NAME :            int main(int argc, char **argv)
*
* DESCRIPTION :     Punto de entrada principal. Abre el diccionario 
*                   principal, procesa el archivo especificado y 
*                   guarda los cambios realizados en el diccionario 
*                   principal.
*******************************************************************/
int main(int argc, char **argv) {
    char *dict;
    /* Verificamos el nro de argumentos. */
    if (argc < 2) {
        printf("spellchecker.c: nro de argumentos erroneo. Deben ser <documento> [<diccionario>].\n");
        return (1);
    }
    /* si se especifico un diccionario lo usamos,  */
    /* caso contrario usamos el diccionario por defecto */
    dict = (argc >=3) ? argv[2] : "dict.txt";
/* completar aca */
    dict_load(dict);    // Se carga el diccionario principal.
    process_document(argv[1]);    // Se procesa el documento.
    dict_save(dict);    // Se guarda el diccionario principal.
    printf("El documento %s ha sido procesado. Resultados en out.txt\n", argv[1]);
}
Пример #4
0
int main(int argc, char **argv){
  if(argc < 2){
    printf("usage: %s <passwdfile>\n",argv[0]);
    printf("  <passwdfile> : file containing passwords separated by lines\n");
    return 0;
  }

  char crypt [MD5CRYPT_SIZE];
  dict_t *passwords = dict_load(argv[1]);
  for(int i=0; i<dict_get_word_count(passwords); i++){
    char *plaintext = dict_get_word(passwords,i);
    md5crypt_r(plaintext, "1", "",crypt);
    printf("%s\n",crypt);
    // printf("%3d: %s <-- %s\n",i,crypt,plaintext);
  }

  dict_free(passwords);

  return 0;
    
}
Пример #5
0
void *load_dict_threaded(void *data)
{
    dict_load();
    return NULL;
}
Пример #6
0
int main (int argc, char *argv[])
{
  int i;
  wstack_type wstack;

  char buff[100];
  SenType sentence;

  printf("starting, loading dict \n");

  /* initial */
  if (dict_load() == -1)
  {
    printf("load dict err!\n");
    return 0;
  }
  dump_dict(&dicts[0], 1);


  printf("creating stack...\n");

  create_wstack(&wstack, 50);
  if (!wstack.array)
  {
    printf("stack alloc err!\n");
    goto MAINEND;
  }

  printf("get a input ...\n");
  
  /* reading sentence from a file or input */
  sentence.pdata = buff;
  sentence.len = sizeof(buff);
  if (0 > sentence_read(&sentence))
  {
    printf("reading err!\n");
    goto MAINEND;
  }

  printf("analyzing...\n");

  /* core algorithm of word segmentation */
  wdseg_full_type wdsegmnt;
  word_seg(sentence, &wdsegmnt, &wstack);


  printf("Done, size: %d \n", wdsegmnt.num);

  /* show result */
  for (i = 0; i < wdsegmnt.num; i++)
  {
    printf("the %dth anwser: \n", i);
    show_map(&wdsegmnt.psegmnt[i]);  
  }


MAINEND:
  if (wstack.array)
  {
    printf("free stack \n");
    free(wstack.array);
  }
  if(dicts[0].indexWdPool.pstart)
  {
    printf("free dict data \n");
    free(dicts[0].indexWdPool.pstart);
  }
  if (dicts[0].pindex)
  {
    printf("free dict wd \n");
    free(dicts[0].index);
  }

  return 0;
}