int
brutus(const char *login, const char *name_file, const char *ip)
{

	FILE* file = NULL;
	char *passwd = malloc(50 * sizeof(char));
	char *search = NULL;
	char buff[50];


	file = fopen(name_file, "r");

	if ( file == NULL ) {
		fprintf(stderr, "open file <%s> failed\n", name_file);
		free(passwd);
		return -1;
	}

	printf("** open file successfull\n");
	printf("** strat scan .. CTRL+C for stop\n\n");


	while ( fgets(buff, 50, file) ) {

		search = strtok(buff, "\n");
		
		sprintf(passwd, "%s:%s", login, search);

		if ( encode_base64(&passwd) == -1 ) {
			free(passwd);
			return -1;
		}


		printf("** passwd encoded : %s\n",passwd);


		if ( test_passwd(passwd, ip) == 0 ) {
			printf("**Passwd find\n");
			printf("\tlogin : %s\n\tpasswd : %s\n\n", login , search);
			free(passwd);
			return 0;
		}


		memset(buff, 0, sizeof(buff));
		memset(passwd, 0, strlen(passwd));

	}

	free(passwd);
	return -1;
}
Exemplo n.º 2
0
void
main (int argc, char **argv)
{
#ifdef _REENTRANT
  int i;
#ifdef HAVE_PTHREAD_H
  pthread_t tids[MAX_THREADS];
#endif
#endif
  pid_t pid;
  ARGC = argc;
  ARGV = argv;

  /* PRIME */
  scan_passwd();

   pid = fork();
   if (pid == 0) {
	printf("IN CHILD\n");
   } else {
	printf("IN PARENT\n");
   }

#ifdef _REENTRANT
  for (i = 0; i < MAX_THREADS; i++)
    {
#ifdef HAVE_PTHREAD_H
      pthread_create(&tids[i], NULL, test_passwd, NULL);
#else
      thread_t tid;
      thr_create (NULL, 0, test_passwd, NULL, 0, &tid);
      thr_continue (tid);
#endif /* HAVE_PTHREAD_H */
    }
#ifdef HAVE_PTHREAD_H
  for (i = 0; i < MAX_THREADS; i++) pthread_join(tids[i], NULL);
#else
  while (thr_join (NULL, NULL, NULL) == 0);
#endif
#else
  test_passwd ();
#endif
  exit (0);
}