SHARE
TWEET

Untitled

a guest Feb 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void brute(int *v,char *usable,int D,int d);
  6.  
  7. int main(int argc,char *argv[])
  8. {
  9.   char *chars;
  10.   unsigned int *v,
  11.                min_len,
  12.                max_len,
  13.                i = 0;
  14.   if(argc > 1)
  15.   {
  16.     printf("%s usage:\n"
  17.            " input (stdin):\n"
  18.            "  UsableChars\n  MinLen MaxLen\n"
  19.            " output (stdout):\n"
  20.            "  possible_passwords seperated by \'\\r\'s\n"
  21.            ,argv[0]);
  22.    return 0;
  23.   }
  24.   chars = malloc(1);
  25.   while(scanf("%c",&chars[i]) && chars[i] != '\r' && chars [i] != '\n')
  26.     chars = realloc(chars,(++i)+1);
  27.   chars[i] = '\0';
  28.  
  29.   scanf("%d %d",&min_len,&max_len);
  30.  
  31.   for(i = min_len; i <= max_len; i++)
  32.   {
  33.     v = malloc(sizeof(int)*i);
  34.     brute(v,chars,i,0);
  35.     free(v);
  36.     printf("\n");
  37.   }
  38.   free(chars);
  39.  
  40.   return 0;
  41. }
  42.  
  43. void brute(int *v,char *chars,int D,int d)
  44. {
  45.   int i;
  46.   for(v[d] = 0; v[d] < strlen(chars); v[d]++)
  47.   {
  48.     if(d+1 < D)
  49.       brute(v,chars,D,d+1);
  50.     else
  51.     {
  52.       for(i = 0; i < D; i++)
  53.         printf("%c",chars[v[i]]);
  54.       printf("\r");
  55.     }
  56.   }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top